Skip to content

Commit

Permalink
test: Check submitblock return values
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Apr 22, 2020
1 parent a7a6f1f commit fa26271
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/functional/feature_bip68_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
block.solve()
tip = block.sha256
height += 1
self.nodes[0].submitblock(ToHex(block))
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(ToHex(block)))
cur_time += 1

mempool = self.nodes[0].getrawmempool()
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_bip68_not_consensus(self):
add_witness_commitment(block)
block.solve()

self.nodes[0].submitblock(block.serialize().hex())
assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
assert_equal(self.nodes[0].getbestblockhash(), block.hash)

def activateCSV(self):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def block_submit(self, node, txs, witness=False, accept=False):
witness and add_witness_commitment(block)
block.rehash()
block.solve()
node.submitblock(block.serialize().hex())
assert_equal(None if accept else 'block-validation-failed', node.submitblock(block.serialize().hex()))
if (accept):
assert_equal(node.getbestblockhash(), block.hash)
self.tip = block.sha256
Expand Down
10 changes: 5 additions & 5 deletions test/functional/p2p_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,13 +862,13 @@ def test_block_malleability(self):

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

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

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

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

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

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

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

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

Expand Down

0 comments on commit fa26271

Please sign in to comment.