Skip to content

Commit 0ccdfff

Browse files
authored
Merge pull request #315 from frstrtr/dgb/fix-reconstruct-coinbasefirst
fix(dgb): P0 master-red — pin reconstruct test merkle_root to actual tx-vector root
2 parents b04649b + a3e4935 commit 0ccdfff

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/impl/dgb/test/reconstruct_won_block_test.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,20 @@ TEST(DgbReconstructWonBlock, CoinbaseFirstThenRefOrder)
196196
BlockType blk;
197197
ps >> blk;
198198

199-
EXPECT_EQ(blk.m_merkle_root, gh); // empty link => root == gentx_hash
200199
ASSERT_EQ(blk.m_txs.size(), 3u); // gentx + 2 others
200+
// Header merkle_root is recomputed over the ACTUAL block tx vector
201+
// ([gentx_hash] ++ each other-tx txid), per the #303 bad-txnmrklroot fix --
202+
// NOT the empty-merkle_link walk (which would yield gentx_hash alone). Pin
203+
// header/body consistency via the same build_block_merkle_root SSOT.
204+
{
205+
std::vector<uint256> expect_txids = {
206+
gh,
207+
dgb::coin::compute_txid(blk.m_txs[1]),
208+
dgb::coin::compute_txid(blk.m_txs[2]),
209+
};
210+
EXPECT_EQ(blk.m_merkle_root,
211+
dgb::coin::build_block_merkle_root(expect_txids));
212+
}
201213
EXPECT_EQ(blk.m_txs[0].vin[0].prevout.index, 0xffffffffu); // coinbase at 0
202214
EXPECT_TRUE(blk.m_txs[0].vin[0].prevout.hash.IsNull());
203215
EXPECT_EQ(blk.m_txs[1].vout[0].value, 11); // c1 -> make_tx(11), ref order

0 commit comments

Comments
 (0)