Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet.py
Show All 14 Lines | def set_test_params(self): | ||||
self.extra_args = [ | self.extra_args = [ | ||||
['-usehd={:d}'.format(i % 2 == 0)] for i in range(4)] | ['-usehd={:d}'.format(i % 2 == 0)] for i in range(4)] | ||||
def setup_network(self): | def setup_network(self): | ||||
self.add_nodes(4, self.extra_args) | self.add_nodes(4, self.extra_args) | ||||
self.start_node(0) | self.start_node(0) | ||||
self.start_node(1) | self.start_node(1) | ||||
self.start_node(2) | self.start_node(2) | ||||
connect_nodes_bi(self.nodes, 0, 1) | connect_nodes_bi(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes, 1, 2) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes, 0, 2) | connect_nodes_bi(self.nodes[0], self.nodes[2]) | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size): | def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size): | ||||
"""Return curr_balance after asserting the fee was in range""" | """Return curr_balance after asserting the fee was in range""" | ||||
fee = balance_with_fee - curr_balance | fee = balance_with_fee - curr_balance | ||||
assert_fee_amount(fee, tx_size, fee_per_byte * 1000) | assert_fee_amount(fee, tx_size, fee_per_byte * 1000) | ||||
return curr_balance | return curr_balance | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Create a couple of transactions, then start up a fourth | # Create a couple of transactions, then start up a fourth | ||||
# node (nodes[3]) and ask nodes[0] to rebroadcast. | # node (nodes[3]) and ask nodes[0] to rebroadcast. | ||||
# EXPECT: nodes[3] should have those transactions in its mempool. | # EXPECT: nodes[3] should have those transactions in its mempool. | ||||
txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1) | txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1) | ||||
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) | txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) | ||||
sync_mempools(self.nodes[0:2]) | sync_mempools(self.nodes[0:2]) | ||||
self.start_node(3) | self.start_node(3) | ||||
connect_nodes_bi(self.nodes, 0, 3) | connect_nodes_bi(self.nodes[0], self.nodes[3]) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
relayed = self.nodes[0].resendwallettransactions() | relayed = self.nodes[0].resendwallettransactions() | ||||
assert_equal(set(relayed), {txid1, txid2}) | assert_equal(set(relayed), {txid1, txid2}) | ||||
sync_mempools(self.nodes) | sync_mempools(self.nodes) | ||||
assert(txid1 in self.nodes[3].getrawmempool()) | assert(txid1 in self.nodes[3].getrawmempool()) | ||||
Show All 32 Lines | def run_test(self): | ||||
assert_equal(uTx['amount'], Decimal('0')) | assert_equal(uTx['amount'], Decimal('0')) | ||||
assert(found) | assert(found) | ||||
# do some -walletbroadcast tests | # do some -walletbroadcast tests | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.start_node(0, ["-walletbroadcast=0"]) | self.start_node(0, ["-walletbroadcast=0"]) | ||||
self.start_node(1, ["-walletbroadcast=0"]) | self.start_node(1, ["-walletbroadcast=0"]) | ||||
self.start_node(2, ["-walletbroadcast=0"]) | self.start_node(2, ["-walletbroadcast=0"]) | ||||
connect_nodes_bi(self.nodes, 0, 1) | connect_nodes_bi(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes, 1, 2) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes, 0, 2) | connect_nodes_bi(self.nodes[0], self.nodes[2]) | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress( | txIdNotBroadcasted = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 2) | self.nodes[2].getnewaddress(), 2) | ||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted) | txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted) | ||||
self.nodes[1].generate(1) # mine a block, tx should not be in there | self.nodes[1].generate(1) # mine a block, tx should not be in there | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
# should not be changed because tx was not broadcasted | # should not be changed because tx was not broadcasted | ||||
Show All 11 Lines | def run_test(self): | ||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress( | txIdNotBroadcasted = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 2) | self.nodes[2].getnewaddress(), 2) | ||||
# restart the nodes with -walletbroadcast=1 | # restart the nodes with -walletbroadcast=1 | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.start_node(0) | self.start_node(0) | ||||
self.start_node(1) | self.start_node(1) | ||||
self.start_node(2) | self.start_node(2) | ||||
connect_nodes_bi(self.nodes, 0, 1) | connect_nodes_bi(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes, 1, 2) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes, 0, 2) | connect_nodes_bi(self.nodes[0], self.nodes[2]) | ||||
sync_blocks(self.nodes[0:3]) | sync_blocks(self.nodes[0:3]) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
sync_blocks(self.nodes[0:3]) | sync_blocks(self.nodes[0:3]) | ||||
node_2_bal += 2 | node_2_bal += 2 | ||||
# tx should be added to balance because after restarting the nodes tx should be broadcasted | # tx should be added to balance because after restarting the nodes tx should be broadcasted | ||||
assert_equal(self.nodes[2].getbalance(), node_2_bal) | assert_equal(self.nodes[2].getbalance(), node_2_bal) | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |