fullblocktests: Add tests for early final state.

This adds tests for the new consensus check which ensures the final
state is zero prior to stake validation height.
This commit is contained in:
Dave Collins 2018-02-14 19:44:20 -06:00
parent 693fc12e39
commit 305a88cc4d
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -549,13 +549,16 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
// allowing the immature tickets to mature and thus become live.
//
// While doing so, also generate blocks that have the required early
// vote unset to ensure they are properly rejected.
// vote unset and other that have a non-zero early final state to ensure
// they are properly rejected.
//
// ... -> bse# -> bsv0 -> bsv1 -> ... -> bsv#
// \ \ \ \-> bevbad#
// | | \-> bevbad2
// | \-> bevbad1
// \-> bevbad0
// | \-> bevbad1 \-> befsbad#
// \-> bevbad0 \-> befsbad2
// | \-> befsbad1
// \-> befsbad0
// ---------------------------------------------------------------------
testInstances = nil
@ -575,6 +578,20 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
g.SetTip(prevTip)
}
// Until stake validation height is reached, test that any
// blocks without a zero final state are rejected.
if int64(g.Tip().Header.Height) < stakeValidationHeight-1 {
prevTip := g.TipName()
blockName := fmt.Sprintf("befsbad%d", i)
g.NextBlock(blockName, nil, nil, func(b *wire.MsgBlock) {
b.Header.FinalState = [6]byte{0x01}
})
testInstances = append(testInstances, rejectBlock(
g.TipName(), g.Tip(),
blockchain.ErrInvalidEarlyFinalState))
g.SetTip(prevTip)
}
// Only purchase tickets until the target ticket pool size is
// reached.
outs := g.OldestCoinbaseOuts()