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
10 changes: 9 additions & 1 deletion ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,17 @@ func TestLedgerBlockHeaders(t *testing.T) {
}
a.NotEmpty(wrongVersion)
badBlock.BlockHeader.CurrentProtocol = wrongVersion
if !config.Consensus[wrongVersion].EnableSha512BlockHash {
// Handle Branch512 field mismatch between correctHeader and wrongVersion's expectations
// We want to set the Branch512 header to match wrongVersion so that PreCheck will reach
// the intended "UpgradeState mismatch" error, which happens after the Branch512 check.
if !proto.EnableSha512BlockHash && config.Consensus[wrongVersion].EnableSha512BlockHash {
// correctHeader has empty Branch512, but wrongVersion expects it during validation
badBlock.BlockHeader.Branch512 = lastBlock.Hash512()
} else if proto.EnableSha512BlockHash && !config.Consensus[wrongVersion].EnableSha512BlockHash {
Comment thread
cce marked this conversation as resolved.
Comment thread
cce marked this conversation as resolved.
// correctHeader has non-zero Branch512, but wrongVersion doesn't support it
badBlock.BlockHeader.Branch512 = crypto.Sha512Digest{}
}
// Otherwise, Branch512 is already correct (both support or both don't support SHA512)
a.ErrorContains(l.appendUnvalidated(badBlock), "UpgradeState mismatch")

badBlock = bookkeeping.Block{BlockHeader: correctHeader}
Expand Down
Loading