Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_invalid_tx.py
Show All 26 Lines | from test_framework.util import ( | ||||
wait_until, | wait_until, | ||||
) | ) | ||||
class InvalidTxRequestTest(BitcoinTestFramework): | class InvalidTxRequestTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [ | |||||
["-acceptnonstdtxn=1", ] | |||||
] | |||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
def bootstrap_p2p(self, *, num_connections=1): | def bootstrap_p2p(self, *, num_connections=1): | ||||
"""Add a P2P connection to the node. | """Add a P2P connection to the node. | ||||
Helper to connect and wait for version handshake.""" | Helper to connect and wait for version handshake.""" | ||||
for _ in range(num_connections): | for _ in range(num_connections): | ||||
self.nodes[0].add_p2p_connection(P2PDataStore()) | self.nodes[0].add_p2p_connection(P2PDataStore()) | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# p2ps[1] is no longer connected | # p2ps[1] is no longer connected | ||||
wait_until(lambda: 1 == len(node.getpeerinfo()), timeout=12) | wait_until(lambda: 1 == len(node.getpeerinfo()), timeout=12) | ||||
assert_equal(expected_mempool, set(node.getrawmempool())) | assert_equal(expected_mempool, set(node.getrawmempool())) | ||||
# restart node with sending BIP61 messages disabled, check that it | # restart node with sending BIP61 messages disabled, check that it | ||||
# disconnects without sending the reject message | # disconnects without sending the reject message | ||||
self.log.info( | self.log.info( | ||||
'Test a transaction that is rejected, with BIP61 disabled') | 'Test a transaction that is rejected, with BIP61 disabled') | ||||
self.restart_node(0, ['-enablebip61=0', '-persistmempool=0']) | self.restart_node( | ||||
0, self.extra_args[0] + ['-enablebip61=0', '-persistmempool=0']) | |||||
self.reconnect_p2p(num_connections=1) | self.reconnect_p2p(num_connections=1) | ||||
node.p2p.send_txs_and_test( | node.p2p.send_txs_and_test( | ||||
[tx1], node, success=False, reject_reason="{} from peer=0 was not accepted: mandatory-script-verify-flag-failed (Invalid OP_IF construction) (code 16)".format(tx1.hash), expect_disconnect=True) | [tx1], node, success=False, reject_reason="{} from peer=0 was not accepted: mandatory-script-verify-flag-failed (Invalid OP_IF construction) (code 16)".format(tx1.hash), expect_disconnect=True) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
InvalidTxRequestTest().main() | InvalidTxRequestTest().main() |