aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2019-09-15 13:27:15 +0200
committerJon Atack <jon@atack.com>2019-09-15 18:53:16 +0200
commit1b41c2c8a126ef4be183e1d800a17d85cab8837b (patch)
treef340c5e3053828d5f4d0f74d9667a12b4bd191f0 /test/functional
parent0f34f54888f680bfbe7a29ac278636d7178a99bb (diff)
downloadbitcoin-1b41c2c8a126ef4be183e1d800a17d85cab8837b.tar.xz
test: improve gettransaction test coverage
- Test gettransaction response without verbose, with verbose=False, and with verbose=True. - In each case, test presence of expected fields in the output, including absence of the "decoded" field when `verbose` is not passed or false. - Test that the "details" field contains the expected receive vout in each case.
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/wallet_basic.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py
index 40ad9081ae..ce04110240 100755
--- a/test/functional/wallet_basic.py
+++ b/test/functional/wallet_basic.py
@@ -499,10 +499,35 @@ class WalletTest(BitcoinTestFramework):
self.nodes[0].setlabel(change, 'foobar')
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
- # Test "decoded" field value in gettransaction `verbose` response.
- self.log.info("Testing verbose gettransaction...")
+ # Test gettransaction response with different arguments.
+ self.log.info("Testing gettransaction response with different arguments...")
+ self.nodes[0].setlabel(change, 'baz')
+ baz = self.nodes[0].listtransactions(label="baz", count=1)[0]
+ expected_receive_vout = {"label": "baz",
+ "address": baz["address"],
+ "amount": baz["amount"],
+ "category": baz["category"],
+ "vout": baz["vout"]}
+ expected_fields = frozenset({'amount', 'bip125-replaceable', 'confirmations', 'details', 'fee',
+ 'hex', 'time', 'timereceived', 'trusted', 'txid', 'walletconflicts'})
+ verbose_field = "decoded"
+ expected_verbose_fields = expected_fields | {verbose_field}
+
+ self.log.debug("Testing gettransaction response without verbose")
+ tx = self.nodes[0].gettransaction(txid=txid)
+ assert_equal(set([*tx]), expected_fields)
+ assert_array_result(tx["details"], {"category": "receive"}, expected_receive_vout)
+
+ self.log.debug("Testing gettransaction response with verbose set to False")
+ tx = self.nodes[0].gettransaction(txid=txid, verbose=False)
+ assert_equal(set([*tx]), expected_fields)
+ assert_array_result(tx["details"], {"category": "receive"}, expected_receive_vout)
+
+ self.log.debug("Testing gettransaction response with verbose set to True")
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)
- assert_equal(tx["decoded"], self.nodes[0].decoderawtransaction(tx["hex"]))
+ assert_equal(set([*tx]), expected_verbose_fields)
+ assert_array_result(tx["details"], {"category": "receive"}, expected_receive_vout)
+ assert_equal(tx[verbose_field], self.nodes[0].decoderawtransaction(tx["hex"]))
if __name__ == '__main__':