Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show All 10 Lines | |||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_array_result, | assert_array_result, | ||||
assert_equal, | assert_equal, | ||||
assert_fee_amount, | assert_fee_amount, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
connect_nodes_bi, | connect_nodes_bi, | ||||
count_bytes, | count_bytes, | ||||
sync_blocks, | sync_blocks, | ||||
sync_mempools, | |||||
wait_until, | wait_until, | ||||
) | ) | ||||
class WalletTest(BitcoinTestFramework): | class WalletTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 4 | self.num_nodes = 4 | ||||
self.extra_args = [ | self.extra_args = [ | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[2].generate(1) | self.nodes[2].generate(1) | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
node_2_bal -= Decimal('10') | node_2_bal -= Decimal('10') | ||||
assert_equal(self.nodes[2].getbalance(), node_2_bal) | assert_equal(self.nodes[2].getbalance(), node_2_bal) | ||||
ctx = FromHex(CTransaction(), self.nodes[2].getrawtransaction(txid)) | ctx = FromHex(CTransaction(), self.nodes[2].getrawtransaction(txid)) | ||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance( | node_0_bal = self.check_fee_amount(self.nodes[0].getbalance( | ||||
), node_0_bal + Decimal('10'), fee_per_byte, ctx.billable_size()) | ), node_0_bal + Decimal('10'), fee_per_byte, ctx.billable_size()) | ||||
# Test ResendWalletTransactions: | |||||
# Create a couple of transactions, then start up a fourth | |||||
# node (nodes[3]) and ask nodes[0] to rebroadcast. | |||||
# EXPECT: nodes[3] should have those transactions in its mempool. | |||||
txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1) | |||||
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) | |||||
sync_mempools(self.nodes[0:2]) | |||||
self.start_node(3, self.extra_args[3]) | self.start_node(3, self.extra_args[3]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[3]) | connect_nodes_bi(self.nodes[0], self.nodes[3]) | ||||
sync_blocks(self.nodes) | self.sync_all() | ||||
relayed = self.nodes[0].resendwallettransactions() | |||||
assert_equal(set(relayed), {txid1, txid2}) | |||||
sync_mempools(self.nodes) | |||||
assert txid1 in self.nodes[3].getrawmempool() | |||||
# check if we can list zero value tx as available coins | # check if we can list zero value tx as available coins | ||||
# 1. create rawtx | # 1. create rawtx | ||||
# 2. hex-changed one output to 0.0 | # 2. hex-changed one output to 0.0 | ||||
# 3. sign and send | # 3. sign and send | ||||
# 4. check if recipient (node0) can list the zero value tx | # 4. check if recipient (node0) can list the zero value tx | ||||
usp = self.nodes[1].listunspent() | usp = self.nodes[1].listunspent() | ||||
inputs = [{"txid": usp[0]['txid'], "vout":usp[0]['vout']}] | inputs = [{"txid": usp[0]['txid'], "vout":usp[0]['vout']}] | ||||
▲ Show 20 Lines • Show All 291 Lines • Show Last 20 Lines |