fix: no crashes allowed

This commit is contained in:
UdjinM6 2024-10-01 21:13:02 +03:00
parent a4cd1d6423
commit c91ba8ac14
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9

View File

@ -75,16 +75,9 @@ class DIP0020ActivationTest(BitcoinTestFramework):
self.log.info("Transactions spending coins with new opcodes aren't accepted before DIP0020 activation") self.log.info("Transactions spending coins with new opcodes aren't accepted before DIP0020 activation")
assert not softfork_active(node, 'dip0020') assert not softfork_active(node, 'dip0020')
try: assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, node.sendrawtransaction, tx0_hex)
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, node.sendrawtransaction, tx0_hex) helper_peer = node.add_p2p_connection(P2PDataStore())
except: helper_peer.send_txs_and_test([tx0], node, success=False, reject_reason=DISABLED_OPCODE_ERROR)
self.start_node(0)
try:
helper_peer = node.add_p2p_connection(P2PDataStore())
helper_peer.send_txs_and_test([tx0], node, success=False, reject_reason=DISABLED_OPCODE_ERROR)
except:
self.start_node(0)
helper_peer = node.add_p2p_connection(P2PDataStore())
tip = node.getblock(node.getbestblockhash(), 1) tip = node.getblock(node.getbestblockhash(), 1)
test_block = self.create_test_block([tx0], tip["hash"], tip["height"], tip["time"]) test_block = self.create_test_block([tx0], tip["hash"], tip["height"], tip["time"])
helper_peer.send_blocks_and_test([test_block], node, success=False, reject_reason='block-validation-failed', expect_disconnect=True) helper_peer.send_blocks_and_test([test_block], node, success=False, reject_reason='block-validation-failed', expect_disconnect=True)
@ -100,25 +93,15 @@ class DIP0020ActivationTest(BitcoinTestFramework):
# Still need 1 more block for mempool to accept txes spending new opcodes # Still need 1 more block for mempool to accept txes spending new opcodes
self.log.info("Transactions spending coins with new opcodes aren't accepted at DIP0020 activation block") self.log.info("Transactions spending coins with new opcodes aren't accepted at DIP0020 activation block")
try: assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, node.sendrawtransaction, tx0_hex)
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, node.sendrawtransaction, tx0_hex) helper_peer = node.add_p2p_connection(P2PDataStore())
except: helper_peer.send_txs_and_test([tx0], node, success=False, reject_reason=DISABLED_OPCODE_ERROR)
self.start_node(0)
try:
helper_peer = node.add_p2p_connection(P2PDataStore())
helper_peer.send_txs_and_test([tx0], node, success=False, reject_reason=DISABLED_OPCODE_ERROR)
except:
self.start_node(0)
helper_peer = node.add_p2p_connection(P2PDataStore())
# A block containing new opcodes is accepted however # A block containing new opcodes is accepted however
tip = node.getblock(node.getbestblockhash(), 1) tip = node.getblock(node.getbestblockhash(), 1)
test_block = self.create_test_block([tx0], tip["hash"], tip["height"], tip["time"]) test_block = self.create_test_block([tx0], tip["hash"], tip["height"], tip["time"])
helper_peer.send_blocks_and_test([test_block], node, success=True) helper_peer.send_blocks_and_test([test_block], node, success=True)
try: # txes spending new opcodes still won't be accepted into mempool if we roll back to the previous tip
# txes spending new opcodes still won't be accepted into mempool if we roll back to the previous tip node.invalidateblock(node.getbestblockhash())
node.invalidateblock(node.getbestblockhash())
except:
self.start_node(0)
assert tx0id not in set(node.getrawmempool()) assert tx0id not in set(node.getrawmempool())
node.generate(1) node.generate(1)