Skip to content

Commit 29637a5

Browse files
author
MarcoFalke
committed
Merge #18745: test: Check submitblock return values
fa26271 test: Check submitblock return values (MarcoFalke) Pull request description: Add `assert_equal` in some tests to check the `submitblock` return value ACKs for top commit: robot-visions: ACK fa26271 Tree-SHA512: 25d9effe82a4f6852184b9ac848f96336cc2cafb0bb07edb2792f00cd363f0759575bc9c164dd62f64425d3754028b4acd0675600c07d51277aa80bf66c6f960
2 parents 8c0f86f + fa26271 commit 29637a5

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

test/functional/feature_bip68_sequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
324324
block.solve()
325325
tip = block.sha256
326326
height += 1
327-
self.nodes[0].submitblock(ToHex(block))
327+
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(ToHex(block)))
328328
cur_time += 1
329329

330330
mempool = self.nodes[0].getrawmempool()
@@ -381,7 +381,7 @@ def test_bip68_not_consensus(self):
381381
add_witness_commitment(block)
382382
block.solve()
383383

384-
self.nodes[0].submitblock(block.serialize().hex())
384+
assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
385385
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
386386

387387
def activateCSV(self):

test/functional/feature_nulldummy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def block_submit(self, node, txs, witness=False, accept=False):
111111
witness and add_witness_commitment(block)
112112
block.rehash()
113113
block.solve()
114-
node.submitblock(block.serialize().hex())
114+
assert_equal(None if accept else 'block-validation-failed', node.submitblock(block.serialize().hex()))
115115
if (accept):
116116
assert_equal(node.getbestblockhash(), block.hash)
117117
self.tip = block.sha256

test/functional/p2p_segwit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,13 @@ def test_block_malleability(self):
862862

863863
# We can't send over the p2p network, because this is too big to relay
864864
# TODO: repeat this test with a block that can be relayed
865-
self.nodes[0].submitblock(block.serialize().hex())
865+
assert_equal('bad-witness-nonce-size', self.nodes[0].submitblock(block.serialize().hex()))
866866

867867
assert self.nodes[0].getbestblockhash() != block.hash
868868

869869
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.pop()
870870
assert get_virtual_size(block) < MAX_BLOCK_BASE_SIZE
871-
self.nodes[0].submitblock(block.serialize().hex())
871+
assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
872872

873873
assert self.nodes[0].getbestblockhash() == block.hash
874874

@@ -975,14 +975,14 @@ def test_submit_block(self):
975975
add_witness_commitment(block, nonce=1)
976976
block.vtx[0].wit = CTxWitness() # drop the nonce
977977
block.solve()
978-
self.nodes[0].submitblock(block.serialize().hex())
978+
assert_equal('bad-witness-merkle-match', self.nodes[0].submitblock(block.serialize().hex()))
979979
assert self.nodes[0].getbestblockhash() != block.hash
980980

981981
# Now redo commitment with the standard nonce, but let bitcoind fill it in.
982982
add_witness_commitment(block, nonce=0)
983983
block.vtx[0].wit = CTxWitness()
984984
block.solve()
985-
self.nodes[0].submitblock(block.serialize().hex())
985+
assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
986986
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
987987

988988
# This time, add a tx with non-empty witness, but don't supply
@@ -997,7 +997,7 @@ def test_submit_block(self):
997997
block_2.vtx[0].vout.pop()
998998
block_2.vtx[0].wit = CTxWitness()
999999

1000-
self.nodes[0].submitblock(block_2.serialize().hex())
1000+
assert_equal('bad-txnmrklroot', self.nodes[0].submitblock(block_2.serialize().hex()))
10011001
# Tip should not advance!
10021002
assert self.nodes[0].getbestblockhash() != block_2.hash
10031003

0 commit comments

Comments
 (0)