fullblocktests: Add coinbase nulldata tests.

This adds two new consensus tests to the full block tests for the
coinbase nulldata height commitment.  The first new test ensures
coinbase transactions with the wrong script version are rejected and the
second test ensures data pushes that exceed the maximum allowed number
of bytes for the coinbase nulldata push are rejected.
This commit is contained in:
Dave Collins 2019-06-17 21:26:39 -05:00
parent 893aa30dce
commit e62a21858b
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -2477,10 +2477,21 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
})
rejected(blockchain.ErrFirstTxNotCoinbase)
// Create block with an invalid script version in the coinbase block
// commitment output.
//
// ... -> bsb2(18)
// \-> bcb2a(19)
g.SetTip("bsb2")
g.NextBlock("bcb2a", outs[19], ticketOuts[19], func(b *wire.MsgBlock) {
b.Transactions[0].TxOut[1].Version = ^uint16(0)
})
rejected(blockchain.ErrFirstTxNotCoinbase)
// Create block with too few bytes for the coinbase height commitment.
//
// ... -> bsb2(18)
// \-> bcb2(19)
// \-> bcb3(19)
g.SetTip("bsb2")
g.NextBlock("bcb3", outs[19], ticketOuts[19], func(b *wire.MsgBlock) {
script := opReturnScript(repeatOpcode(0x00, 3))
@ -2488,6 +2499,17 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
})
rejected(blockchain.ErrFirstTxNotCoinbase)
// Create block with too many bytes for the coinbase height commitment.
//
// ... -> bsb2(18)
// \-> bcb3a(19)
g.SetTip("bsb2")
g.NextBlock("bcb3a", outs[19], ticketOuts[19], func(b *wire.MsgBlock) {
script := opReturnScript(repeatOpcode(0x00, 257))
b.Transactions[0].TxOut[1].PkScript = script
})
rejected(blockchain.ErrFirstTxNotCoinbase)
// Create block with invalid block height in the coinbase commitment.
//
// ... -> bsb2(18)