MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/wallet_basic.py:55–708  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53 return self.nodes[0].decoderawtransaction(txn)['vsize']
54
55 def run_test(self):
56
57 # Check that there's no UTXO on none of the nodes
58 assert_equal(len(self.nodes[0].listunspent()), 0)
59 assert_equal(len(self.nodes[1].listunspent()), 0)
60 assert_equal(len(self.nodes[2].listunspent()), 0)
61
62 self.log.info("Mining blocks...")
63
64 self.generate(self.nodes[0], 1, sync_fun=self.no_op)
65
66 walletinfo = self.nodes[0].getwalletinfo()
67 assert_equal(walletinfo['immature_balance']['bitcoin'], 50)
68 assert_equal(walletinfo['balance']['bitcoin'], 0)
69
70 self.sync_all(self.nodes[0:3])
71 self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
72
73 assert_equal(self.nodes[0].getbalance()['bitcoin'], 50)
74 assert_equal(self.nodes[1].getbalance()['bitcoin'], 50)
75 assert_equal(self.nodes[2].getbalance()['bitcoin'], 0)
76
77 # Check that only first and second nodes have UTXOs
78 utxos = self.nodes[0].listunspent()
79 assert_equal(len(utxos), 1)
80 assert_equal(len(self.nodes[1].listunspent()), 1)
81 assert_equal(len(self.nodes[2].listunspent()), 0)
82
83 self.log.info("Test gettxout")
84 confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
85 # First, outputs that are unspent both in the chain and in the
86 # mempool should appear with or without include_mempool
87 txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=False)
88 assert_equal(txout['value'], 50)
89 txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=True)
90 assert_equal(txout['value'], 50)
91
92 # Send 21 BTC from 0 to 2 using sendtoaddress call.
93 self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
94 mempool_txid = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
95
96 self.log.info("Test gettxout (second part)")
97 # utxo spent in mempool should be visible if you exclude mempool
98 # but invisible if you include mempool
99 txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False)
100 assert_equal(txout['value'], 50)
101 txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index) # by default include_mempool=True
102 assert txout is None
103 txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True)
104 assert txout is None
105 # new utxo from mempool should be invisible if you exclude mempool
106 # but visible if you include mempool
107 txout = self.nodes[0].gettxout(mempool_txid, 0, False)
108 assert txout is None
109 txout1 = self.nodes[0].gettxout(mempool_txid, 0, True)
110 txout2 = self.nodes[0].gettxout(mempool_txid, 1, True)
111 # note the mempool tx will have randomly assigned indices
112 # but 10 will go to node2 and the rest will go to node0

Callers

nothing calls this directly

Calls 15

check_fee_amountMethod · 0.95
get_vsizeMethod · 0.95
assert_equalFunction · 0.90
assert_raises_rpc_errorFunction · 0.90
find_vout_for_addressFunction · 0.90
assert_fee_amountFunction · 0.90
assert_array_resultFunction · 0.90
test_addressFunction · 0.90
infoMethod · 0.80
connect_nodesMethod · 0.80
sendrawtransactionMethod · 0.80
sync_mempoolsMethod · 0.80

Tested by

no test coverage detected