Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-replay-protection.py
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
activation_blocks = [] | activation_blocks = [] | ||||
for i in range(5): | for i in range(5): | ||||
block(5100 + i) | block(5100 + i) | ||||
activation_blocks.append(self.tip) | activation_blocks.append(self.tip) | ||||
node.p2p.send_blocks_and_test(activation_blocks, node) | node.p2p.send_blocks_and_test(activation_blocks, node) | ||||
# Check we are just before the activation time | # Check we are just before the activation time | ||||
assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], | assert_equal( | ||||
node.getblockchaininfo()['mediantime'], | |||||
REPLAY_PROTECTION_START_TIME - 1) | REPLAY_PROTECTION_START_TIME - 1) | ||||
# We are just before the fork, replay protected txns still are rejected | # We are just before the fork, replay protected txns still are rejected | ||||
assert_raises_rpc_error(-26, RPC_INVALID_SIGNATURE_ERROR, | assert_raises_rpc_error(-26, RPC_INVALID_SIGNATURE_ERROR, | ||||
node.sendrawtransaction, ToHex(replay_txns[1])) | node.sendrawtransaction, ToHex(replay_txns[1])) | ||||
block(3) | block(3) | ||||
update_block(3, replay_txns) | update_block(3, replay_txns) | ||||
node.p2p.send_blocks_and_test( | node.p2p.send_blocks_and_test( | ||||
[self.tip], node, success=False, reject_reason='blk-bad-inputs') | [self.tip], node, success=False, reject_reason='blk-bad-inputs') | ||||
# Rewind bad block | # Rewind bad block | ||||
tip(5104) | tip(5104) | ||||
# Send some non replay protected txns in the mempool to check | # Send some non replay protected txns in the mempool to check | ||||
# they get cleaned at activation. | # they get cleaned at activation. | ||||
txns = create_fund_and_spend_tx(out[2]) | txns = create_fund_and_spend_tx(out[2]) | ||||
send_transaction_to_mempool(txns[0]) | send_transaction_to_mempool(txns[0]) | ||||
tx_id = send_transaction_to_mempool(txns[1]) | tx_id = send_transaction_to_mempool(txns[1]) | ||||
# Activate the replay protection | # Activate the replay protection | ||||
block(5556) | block(5556) | ||||
node.p2p.send_blocks_and_test([self.tip], node) | node.p2p.send_blocks_and_test([self.tip], node) | ||||
# Check we just activated the replay protection | # Check we just activated the replay protection | ||||
assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], | assert_equal( | ||||
node.getblockchaininfo()['mediantime'], | |||||
REPLAY_PROTECTION_START_TIME) | REPLAY_PROTECTION_START_TIME) | ||||
# Non replay protected transactions are not valid anymore, | # Non replay protected transactions are not valid anymore, | ||||
# so they should be removed from the mempool. | # so they should be removed from the mempool. | ||||
assert tx_id not in set(node.getrawmempool()) | assert tx_id not in set(node.getrawmempool()) | ||||
# Good old transactions are now invalid. | # Good old transactions are now invalid. | ||||
send_transaction_to_mempool(txns[0]) | send_transaction_to_mempool(txns[0]) | ||||
assert_raises_rpc_error(-26, RPC_INVALID_SIGNATURE_ERROR, | assert_raises_rpc_error(-26, RPC_INVALID_SIGNATURE_ERROR, | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |