From 943d435cd278328b183a79d07c841580bf7b5adb Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 7 May 2020 21:46:28 +0300 Subject: [PATCH] core: ensure we produce correct blocks for tests Blocks must have at least one transaction and we should check for correct merkle root generation. --- pkg/core/helper_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index f1e8e1657..f6300c492 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -59,6 +59,9 @@ func newBlock(cfg config.ProtocolConfiguration, index uint32, prev util.Uint256, witness := transaction.Witness{ VerificationScript: valScript, } + if len(txs) == 0 { + txs = []*transaction.Transaction{newMinerTX()} + } b := &block.Block{ Base: block.Base{ Version: 0, @@ -71,7 +74,10 @@ func newBlock(cfg config.ProtocolConfiguration, index uint32, prev util.Uint256, }, Transactions: txs, } - _ = b.RebuildMerkleRoot() + err := b.RebuildMerkleRoot() + if err != nil { + panic(err) + } invScript := make([]byte, 0) for _, wif := range privNetKeys {