Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/impl/dgb/test/work_source_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <impl/dgb/coin/header_chain.hpp>
#include <impl/dgb/coin/mempool.hpp>
#include <impl/dgb/config_coin.hpp> // dgb::CoinParams::subsidy (oracle SSOT)
#include <impl/dgb/params.hpp> // dgb::make_coin_params -- the LIVE production binding

#include <core/pow.hpp> // core::SubsidyFunc

Expand Down Expand Up @@ -458,6 +459,28 @@ TEST(DgbWorkSource, CoinbaseValueHonorsGbtVerbatim)
}


// Production-binding guard. The era-boundary tests above trust kSubsidyFunc, a
// hand-written DUPLICATE of params.hpp p.subsidy_func: they pin the schedule
// math but are blind to a regression in the ACTUAL wiring. If make_coin_params()
// shipped subsidy_func unbound (the work source then logs subsidy_func=UNSET and
// the embedded coinbasevalue silently falls through to the GBT-only path) or
// bound it to the wrong function, every test above would still pass off its
// private copy. Pin the LIVE production binding directly.
TEST(DgbCoinParams, SubsidyFuncBoundToOracleScheduleInProduction)
{
const core::CoinParams p = dgb::make_coin_params(/*testnet=*/false);
ASSERT_TRUE(static_cast<bool>(p.subsidy_func))
<< "make_coin_params shipped subsidy_func UNSET -- embedded coinbasevalue "
"would silently degrade to the external-GBT-only path";
for (const auto& v : kEraBoundaries) {
EXPECT_EQ(p.subsidy_func(v.height), v.subsidy)
<< "production subsidy_func diverged from oracle subsidy at " << v.era;
EXPECT_EQ(p.subsidy_func(v.height), kSubsidyFunc(v.height))
<< "production binding diverged from the schedule under test at " << v.era;
}
}


// previousblockhash: emitted as GBT-conventional big-endian display hex ONLY
// when the HeaderChain carries a real tip hash (tip_hash() accessor). With a
// known tip block_hash, the template surfaces it MSB-limb-first; bits stays
Expand Down
Loading