Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_reorg.py
Show All 11 Lines | |||||
from test_framework.util import * | from test_framework.util import * | ||||
# Create one-input, one-output, no-fee transaction: | # Create one-input, one-output, no-fee transaction: | ||||
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 = [ | self.extra_args = [["-checkmempool"]] * 2 | ||||
["-checkmempool", "-deprecatedrpc=signrawtransaction"]] * 2 | |||||
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 | ||||
assert_equal(self.nodes[0].getblockcount(), 200) | assert_equal(self.nodes[0].getblockcount(), 200) | ||||
# Mine four blocks. After this, nodes[0] blocks | # Mine four blocks. After this, nodes[0] blocks | ||||
Show All 21 Lines | def run_test(self): | ||||
# Create a transaction which is time-locked to two blocks in the future | # Create a transaction which is time-locked to two blocks in the future | ||||
timelock_tx = self.nodes[0].createrawtransaction( | timelock_tx = self.nodes[0].createrawtransaction( | ||||
[{"txid": coinbase_txids[0], "vout": 0}], {node0_address: 49.99}) | [{"txid": coinbase_txids[0], "vout": 0}], {node0_address: 49.99}) | ||||
# Set the time lock | # Set the time lock | ||||
timelock_tx = timelock_tx.replace("ffffffff", "11111191", 1) | timelock_tx = timelock_tx.replace("ffffffff", "11111191", 1) | ||||
timelock_tx = timelock_tx[:-8] + \ | timelock_tx = timelock_tx[:-8] + \ | ||||
hex(self.nodes[0].getblockcount() + 2)[2:] + "000000" | hex(self.nodes[0].getblockcount() + 2)[2:] + "000000" | ||||
timelock_tx = self.nodes[0].signrawtransaction(timelock_tx)["hex"] | timelock_tx = self.nodes[0].signrawtransactionwithwallet(timelock_tx)[ | ||||
"hex"] | |||||
# This will raise an exception because the timelock transaction is too immature to spend | # This will raise an exception because the timelock transaction is too immature to spend | ||||
assert_raises_rpc_error(-26, "bad-txns-nonfinal", | assert_raises_rpc_error(-26, "bad-txns-nonfinal", | ||||
self.nodes[0].sendrawtransaction, timelock_tx) | self.nodes[0].sendrawtransaction, timelock_tx) | ||||
# Broadcast and mine spend_102 and 103: | # Broadcast and mine spend_102 and 103: | ||||
spend_102_id = self.nodes[0].sendrawtransaction(spend_102_raw) | spend_102_id = self.nodes[0].sendrawtransaction(spend_102_raw) | ||||
spend_103_id = self.nodes[0].sendrawtransaction(spend_103_raw) | spend_103_id = self.nodes[0].sendrawtransaction(spend_103_raw) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |