Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_reorg.py
Show All 10 Lines | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.blocktools import create_raw_transaction | from test_framework.blocktools import create_raw_transaction | ||||
from test_framework.util import assert_equal, assert_raises_rpc_error | from test_framework.util import assert_equal, assert_raises_rpc_error | ||||
class MempoolCoinbaseTest(BitcoinTestFramework): | class MempoolCoinbaseTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [ | |||||
# immediate tx relay | |||||
['-whitelist=noban@127.0.0.1', ], | |||||
[] | |||||
] | |||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_wallet() | self.skip_if_no_wallet() | ||||
alert_filename = None # Set by setup_network | alert_filename = None # Set by setup_network | ||||
def run_test(self): | def run_test(self): | ||||
# Start with a 200 block chain | # Start with a 200 block chain | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
spend_102_1_raw = create_raw_transaction( | spend_102_1_raw = create_raw_transaction( | ||||
self.nodes[0], spend_102_id, node1_address, amount=49.98) | self.nodes[0], spend_102_id, node1_address, amount=49.98) | ||||
spend_103_1_raw = create_raw_transaction( | spend_103_1_raw = create_raw_transaction( | ||||
self.nodes[0], spend_103_id, node1_address, amount=49.98) | self.nodes[0], spend_103_id, node1_address, amount=49.98) | ||||
# Broadcast and mine 103_1: | # Broadcast and mine 103_1: | ||||
spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw) | spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw) | ||||
last_block = self.nodes[0].generate(1) | last_block = self.nodes[0].generate(1) | ||||
# Sync blocks, so that peer 1 gets the block before timelock_tx | |||||
# Otherwise, peer 1 would put the timelock_tx in recentRejects | |||||
self.sync_all() | |||||
# Time-locked transaction can now be spent | # Time-locked transaction can now be spent | ||||
timelock_tx_id = self.nodes[0].sendrawtransaction(timelock_tx) | timelock_tx_id = self.nodes[0].sendrawtransaction(timelock_tx) | ||||
# ... now put spend_101 and spend_102_1 in memory pools: | # ... now put spend_101 and spend_102_1 in memory pools: | ||||
spend_101_id = self.nodes[0].sendrawtransaction(spend_101_raw) | spend_101_id = self.nodes[0].sendrawtransaction(spend_101_raw) | ||||
spend_102_1_id = self.nodes[0].sendrawtransaction(spend_102_1_raw) | spend_102_1_id = self.nodes[0].sendrawtransaction(spend_102_1_raw) | ||||
self.sync_all() | self.sync_all() | ||||
Show All 25 Lines |