1
1
#!/usr/bin/env python3
2
- # Copyright (c) 2014-2018 The Bitcoin Core developers
2
+ # Copyright (c) 2014-2019 The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test the wallet."""
19
19
wait_until ,
20
20
)
21
21
22
+
22
23
class WalletTest (BitcoinTestFramework ):
23
24
def set_test_params (self ):
24
25
self .num_nodes = 4
@@ -196,7 +197,7 @@ def run_test(self):
196
197
txid = self .nodes [2 ].sendtoaddress (address , 10 , "" , "" , False )
197
198
self .nodes [2 ].generate (1 )
198
199
self .sync_all ([self .nodes [0 :3 ]])
199
- node_2_bal = self .check_fee_amount (self .nodes [2 ].getbalance (), Decimal ('84' ), fee_per_byte , self .get_vsize (self .nodes [2 ].getrawtransaction (txid )))
200
+ node_2_bal = self .check_fee_amount (self .nodes [2 ].getbalance (), Decimal ('84' ), fee_per_byte , self .get_vsize (self .nodes [2 ].gettransaction (txid )[ 'hex' ] ))
200
201
assert_equal (self .nodes [0 ].getbalance (), Decimal ('10' ))
201
202
202
203
# Send 10 BTC with subtract fee from amount
@@ -205,14 +206,14 @@ def run_test(self):
205
206
self .sync_all ([self .nodes [0 :3 ]])
206
207
node_2_bal -= Decimal ('10' )
207
208
assert_equal (self .nodes [2 ].getbalance (), node_2_bal )
208
- node_0_bal = self .check_fee_amount (self .nodes [0 ].getbalance (), Decimal ('20' ), fee_per_byte , self .get_vsize (self .nodes [2 ].getrawtransaction (txid )))
209
+ node_0_bal = self .check_fee_amount (self .nodes [0 ].getbalance (), Decimal ('20' ), fee_per_byte , self .get_vsize (self .nodes [2 ].gettransaction (txid )[ 'hex' ] ))
209
210
210
211
# Sendmany 10 BTC
211
212
txid = self .nodes [2 ].sendmany ('' , {address : 10 }, 0 , "" , [])
212
213
self .nodes [2 ].generate (1 )
213
214
self .sync_all ([self .nodes [0 :3 ]])
214
215
node_0_bal += Decimal ('10' )
215
- node_2_bal = self .check_fee_amount (self .nodes [2 ].getbalance (), node_2_bal - Decimal ('10' ), fee_per_byte , self .get_vsize (self .nodes [2 ].getrawtransaction (txid )))
216
+ node_2_bal = self .check_fee_amount (self .nodes [2 ].getbalance (), node_2_bal - Decimal ('10' ), fee_per_byte , self .get_vsize (self .nodes [2 ].gettransaction (txid )[ 'hex' ] ))
216
217
assert_equal (self .nodes [0 ].getbalance (), node_0_bal )
217
218
218
219
# Sendmany 10 BTC with subtract fee from amount
@@ -221,7 +222,7 @@ def run_test(self):
221
222
self .sync_all ([self .nodes [0 :3 ]])
222
223
node_2_bal -= Decimal ('10' )
223
224
assert_equal (self .nodes [2 ].getbalance (), node_2_bal )
224
- node_0_bal = self .check_fee_amount (self .nodes [0 ].getbalance (), node_0_bal + Decimal ('10' ), fee_per_byte , self .get_vsize (self .nodes [2 ].getrawtransaction (txid )))
225
+ node_0_bal = self .check_fee_amount (self .nodes [0 ].getbalance (), node_0_bal + Decimal ('10' ), fee_per_byte , self .get_vsize (self .nodes [2 ].gettransaction (txid )[ 'hex' ] ))
225
226
226
227
# Test ResendWalletTransactions:
227
228
# Create a couple of transactions, then start up a fourth
@@ -239,7 +240,7 @@ def run_test(self):
239
240
assert_equal (set (relayed ), {txid1 , txid2 })
240
241
sync_mempools (self .nodes )
241
242
242
- assert ( txid1 in self .nodes [3 ].getrawmempool () )
243
+ assert txid1 in self .nodes [3 ].getrawmempool ()
243
244
244
245
# check if we can list zero value tx as available coins
245
246
# 1. create raw_tx
@@ -266,7 +267,7 @@ def run_test(self):
266
267
if uTx ['txid' ] == zero_value_txid :
267
268
found = True
268
269
assert_equal (uTx ['amount' ], Decimal ('0' ))
269
- assert ( found )
270
+ assert found
270
271
271
272
# do some -walletbroadcast tests
272
273
self .stop_nodes ()
@@ -343,7 +344,7 @@ def run_test(self):
343
344
self .nodes [1 ].importaddress (address_to_import )
344
345
345
346
# 3. Validate that the imported address is watch-only on node1
346
- assert ( self .nodes [1 ].getaddressinfo (address_to_import )["iswatchonly" ])
347
+ assert self .nodes [1 ].getaddressinfo (address_to_import )["iswatchonly" ]
347
348
348
349
# 4. Check that the unspents after import are not spendable
349
350
assert_array_result (self .nodes [1 ].listunspent (),
@@ -385,7 +386,7 @@ def run_test(self):
385
386
addr = self .nodes [0 ].getnewaddress ()
386
387
self .nodes [0 ].setlabel (addr , label )
387
388
assert_equal (self .nodes [0 ].getaddressinfo (addr )['label' ], label )
388
- assert ( label in self .nodes [0 ].listlabels () )
389
+ assert label in self .nodes [0 ].listlabels ()
389
390
self .nodes [0 ].rpc .ensure_ascii = True # restore to default
390
391
391
392
# maintenance tests
@@ -444,8 +445,8 @@ def run_test(self):
444
445
# Without walletrejectlongchains, we will still generate a txid
445
446
# The tx will be stored in the wallet but not accepted to the mempool
446
447
extra_txid = self .nodes [0 ].sendtoaddress (sending_addr , Decimal ('0.0001' ))
447
- assert ( extra_txid not in self .nodes [0 ].getrawmempool () )
448
- assert ( extra_txid in [tx ["txid" ] for tx in self .nodes [0 ].listtransactions ()])
448
+ assert extra_txid not in self .nodes [0 ].getrawmempool ()
449
+ assert extra_txid in [tx ["txid" ] for tx in self .nodes [0 ].listtransactions ()]
449
450
self .nodes [0 ].abandontransaction (extra_txid )
450
451
total_txs = len (self .nodes [0 ].listtransactions ("*" , 99999 ))
451
452
@@ -482,7 +483,7 @@ def run_test(self):
482
483
self .nodes [0 ].generate (1 )
483
484
destination = self .nodes [1 ].getnewaddress ()
484
485
txid = self .nodes [0 ].sendtoaddress (destination , 0.123 )
485
- tx = self .nodes [0 ].decoderawtransaction (self .nodes [0 ].getrawtransaction (txid ))
486
+ tx = self .nodes [0 ].decoderawtransaction (self .nodes [0 ].gettransaction (txid )[ 'hex' ] )
486
487
output_addresses = [vout ['scriptPubKey' ]['addresses' ][0 ] for vout in tx ["vout" ]]
487
488
assert len (output_addresses ) > 1
488
489
for address in output_addresses :
@@ -493,5 +494,6 @@ def run_test(self):
493
494
self .nodes [0 ].setlabel (change , 'foobar' )
494
495
assert_equal (self .nodes [0 ].getaddressinfo (change )['ischange' ], False )
495
496
497
+
496
498
if __name__ == '__main__' :
497
499
WalletTest ().main ()
0 commit comments