aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_basic.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-02-01 09:35:08 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-02-01 09:35:14 -0500
commit5c99bb00470057f573f1d76b76e744a6ccd65b08 (patch)
tree4013d90cacf3cb145fb62bd8304ce65a4cabd765 /test/functional/wallet_basic.py
parent3e38d4087379edd1c0730d058902f527d5da6358 (diff)
parentfa5278a4196cf0b560f5eeb1fb5f9c5e98219ec4 (diff)
downloadbitcoin-5c99bb00470057f573f1d76b76e744a6ccd65b08.tar.xz
Merge #15247: qa: Use wallet to retrieve raw transactions
fa5278a419 qa: Use wallet to retrieve raw transactions (MarcoFalke) fa2198328e qa: Style-only fixes in touched files (MarcoFalke) Pull request description: Instead of asking the coin database and block storage about a transaction, pull it directly from the wallet in wallet related tests. This refactoring only makes sense in light of #15159. <sub>This product may contain minor stylistic cleanups Tree-SHA512: ec34c7150d873da9f19fead3f7e3f758baba5ef10061942384c470a47a6f320690109be9c5160f0c8bc228272a729653d44c78471455337318f657d6c164ba23
Diffstat (limited to 'test/functional/wallet_basic.py')
-rwxr-xr-xtest/functional/wallet_basic.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py
index daae2ed3c0..673eb718e6 100755
--- a/test/functional/wallet_basic.py
+++ b/test/functional/wallet_basic.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright (c) 2014-2018 The Bitcoin Core developers
+# Copyright (c) 2014-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the wallet."""
@@ -19,6 +19,7 @@ from test_framework.util import (
wait_until,
)
+
class WalletTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
@@ -196,7 +197,7 @@ class WalletTest(BitcoinTestFramework):
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
self.nodes[2].generate(1)
self.sync_all([self.nodes[0:3]])
- node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, self.get_vsize(self.nodes[2].getrawtransaction(txid)))
+ 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']))
assert_equal(self.nodes[0].getbalance(), Decimal('10'))
# Send 10 BTC with subtract fee from amount
@@ -205,14 +206,14 @@ class WalletTest(BitcoinTestFramework):
self.sync_all([self.nodes[0:3]])
node_2_bal -= Decimal('10')
assert_equal(self.nodes[2].getbalance(), node_2_bal)
- node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].getrawtransaction(txid)))
+ 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']))
# Sendmany 10 BTC
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
self.nodes[2].generate(1)
self.sync_all([self.nodes[0:3]])
node_0_bal += Decimal('10')
- 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)))
+ 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']))
assert_equal(self.nodes[0].getbalance(), node_0_bal)
# Sendmany 10 BTC with subtract fee from amount
@@ -221,7 +222,7 @@ class WalletTest(BitcoinTestFramework):
self.sync_all([self.nodes[0:3]])
node_2_bal -= Decimal('10')
assert_equal(self.nodes[2].getbalance(), node_2_bal)
- 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)))
+ 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']))
# Test ResendWalletTransactions:
# Create a couple of transactions, then start up a fourth
@@ -239,7 +240,7 @@ class WalletTest(BitcoinTestFramework):
assert_equal(set(relayed), {txid1, txid2})
sync_mempools(self.nodes)
- assert(txid1 in self.nodes[3].getrawmempool())
+ assert txid1 in self.nodes[3].getrawmempool()
# check if we can list zero value tx as available coins
# 1. create raw_tx
@@ -266,7 +267,7 @@ class WalletTest(BitcoinTestFramework):
if uTx['txid'] == zero_value_txid:
found = True
assert_equal(uTx['amount'], Decimal('0'))
- assert(found)
+ assert found
# do some -walletbroadcast tests
self.stop_nodes()
@@ -343,7 +344,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[1].importaddress(address_to_import)
# 3. Validate that the imported address is watch-only on node1
- assert(self.nodes[1].getaddressinfo(address_to_import)["iswatchonly"])
+ assert self.nodes[1].getaddressinfo(address_to_import)["iswatchonly"]
# 4. Check that the unspents after import are not spendable
assert_array_result(self.nodes[1].listunspent(),
@@ -385,7 +386,7 @@ class WalletTest(BitcoinTestFramework):
addr = self.nodes[0].getnewaddress()
self.nodes[0].setlabel(addr, label)
assert_equal(self.nodes[0].getaddressinfo(addr)['label'], label)
- assert(label in self.nodes[0].listlabels())
+ assert label in self.nodes[0].listlabels()
self.nodes[0].rpc.ensure_ascii = True # restore to default
# maintenance tests
@@ -444,8 +445,8 @@ class WalletTest(BitcoinTestFramework):
# Without walletrejectlongchains, we will still generate a txid
# The tx will be stored in the wallet but not accepted to the mempool
extra_txid = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001'))
- assert(extra_txid not in self.nodes[0].getrawmempool())
- assert(extra_txid in [tx["txid"] for tx in self.nodes[0].listtransactions()])
+ assert extra_txid not in self.nodes[0].getrawmempool()
+ assert extra_txid in [tx["txid"] for tx in self.nodes[0].listtransactions()]
self.nodes[0].abandontransaction(extra_txid)
total_txs = len(self.nodes[0].listtransactions("*", 99999))
@@ -482,7 +483,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[0].generate(1)
destination = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(destination, 0.123)
- tx = self.nodes[0].decoderawtransaction(self.nodes[0].getrawtransaction(txid))
+ tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])
output_addresses = [vout['scriptPubKey']['addresses'][0] for vout in tx["vout"]]
assert len(output_addresses) > 1
for address in output_addresses:
@@ -493,5 +494,6 @@ class WalletTest(BitcoinTestFramework):
self.nodes[0].setlabel(change, 'foobar')
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
+
if __name__ == '__main__':
WalletTest().main()