Changeset View
Changeset View
Standalone View
Standalone View
test/functional/txn_clone.py
Show All 14 Lines | class TxnMallTest(BitcoinTestFramework): | ||||
def add_options(self, parser): | def add_options(self, parser): | ||||
parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true", | parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true", | ||||
help="Test double-spend of 1-confirmed transaction") | help="Test double-spend of 1-confirmed transaction") | ||||
def setup_network(self): | def setup_network(self): | ||||
# Start with split network: | # Start with split network: | ||||
super(TxnMallTest, self).setup_network() | super(TxnMallTest, self).setup_network() | ||||
disconnect_nodes(self.nodes[1], 2) | disconnect_nodes(self.nodes[1], self.nodes[2]) | ||||
disconnect_nodes(self.nodes[2], 1) | disconnect_nodes(self.nodes[2], self.nodes[1]) | ||||
def run_test(self): | def run_test(self): | ||||
# All nodes should start with 1,250 BTC: | # All nodes should start with 1,250 BTC: | ||||
starting_balance = 1250 | starting_balance = 1250 | ||||
for i in range(4): | for i in range(4): | ||||
assert_equal(self.nodes[i].getbalance(), starting_balance) | assert_equal(self.nodes[i].getbalance(), starting_balance) | ||||
# bug workaround, coins generated assigned to first getnewaddress! | # bug workaround, coins generated assigned to first getnewaddress! | ||||
self.nodes[i].getnewaddress("") | self.nodes[i].getnewaddress("") | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Send clone and its parent to miner | # Send clone and its parent to miner | ||||
self.nodes[2].sendrawtransaction(fund_foo_tx["hex"]) | self.nodes[2].sendrawtransaction(fund_foo_tx["hex"]) | ||||
txid1_clone = self.nodes[2].sendrawtransaction(tx1_clone["hex"]) | txid1_clone = self.nodes[2].sendrawtransaction(tx1_clone["hex"]) | ||||
# ... mine a block... | # ... mine a block... | ||||
self.nodes[2].generate(1) | self.nodes[2].generate(1) | ||||
# Reconnect the split network, and sync chain: | # Reconnect the split network, and sync chain: | ||||
connect_nodes(self.nodes[1], 2) | connect_nodes(self.nodes[1], self.nodes[2]) | ||||
self.nodes[2].sendrawtransaction(fund_bar_tx["hex"]) | self.nodes[2].sendrawtransaction(fund_bar_tx["hex"]) | ||||
self.nodes[2].sendrawtransaction(tx2["hex"]) | self.nodes[2].sendrawtransaction(tx2["hex"]) | ||||
self.nodes[2].generate(1) # Mine another block to make sure we sync | self.nodes[2].generate(1) # Mine another block to make sure we sync | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# Re-fetch transaction info: | # Re-fetch transaction info: | ||||
tx1 = self.nodes[0].gettransaction(txid1) | tx1 = self.nodes[0].gettransaction(txid1) | ||||
tx1_clone = self.nodes[0].gettransaction(txid1_clone) | tx1_clone = self.nodes[0].gettransaction(txid1_clone) | ||||
Show All 37 Lines |