aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_abandonconflict.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_abandonconflict.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_abandonconflict.py')
-rwxr-xr-xtest/functional/wallet_abandonconflict.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py
index 2b684349ce..0c3c247694 100755
--- a/test/functional/wallet_abandonconflict.py
+++ b/test/functional/wallet_abandonconflict.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 abandontransaction RPC.
@@ -13,7 +13,15 @@
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes, sync_blocks, sync_mempools
+from test_framework.util import (
+ assert_equal,
+ assert_raises_rpc_error,
+ connect_nodes,
+ disconnect_nodes,
+ sync_blocks,
+ sync_mempools,
+)
+
class AbandonConflictTest(BitcoinTestFramework):
def set_test_params(self):
@@ -41,21 +49,21 @@ class AbandonConflictTest(BitcoinTestFramework):
sync_blocks(self.nodes)
newbalance = self.nodes[0].getbalance()
- assert(balance - newbalance < Decimal("0.001")) #no more than fees lost
+ assert balance - newbalance < Decimal("0.001") #no more than fees lost
balance = newbalance
# Disconnect nodes so node0's transactions don't get into node1's mempool
disconnect_nodes(self.nodes[0], 1)
# Identify the 10btc outputs
- nA = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txA, 1)["vout"]) if vout["value"] == Decimal("10"))
- nB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txB, 1)["vout"]) if vout["value"] == Decimal("10"))
- nC = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txC, 1)["vout"]) if vout["value"] == Decimal("10"))
+ nA = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txA)["details"] if tx_out["amount"] == Decimal("10"))
+ nB = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txB)["details"] if tx_out["amount"] == Decimal("10"))
+ nC = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txC)["details"] if tx_out["amount"] == Decimal("10"))
- inputs =[]
+ inputs = []
# spend 10btc outputs from txA and txB
- inputs.append({"txid":txA, "vout":nA})
- inputs.append({"txid":txB, "vout":nB})
+ inputs.append({"txid": txA, "vout": nA})
+ inputs.append({"txid": txB, "vout": nB})
outputs = {}
outputs[self.nodes[0].getnewaddress()] = Decimal("14.99998")
@@ -64,12 +72,12 @@ class AbandonConflictTest(BitcoinTestFramework):
txAB1 = self.nodes[0].sendrawtransaction(signed["hex"])
# Identify the 14.99998btc output
- nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txAB1, 1)["vout"]) if vout["value"] == Decimal("14.99998"))
+ nAB = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txAB1)["details"] if tx_out["amount"] == Decimal("14.99998"))
#Create a child tx spending AB1 and C
inputs = []
- inputs.append({"txid":txAB1, "vout":nAB})
- inputs.append({"txid":txC, "vout":nC})
+ inputs.append({"txid": txAB1, "vout": nAB})
+ inputs.append({"txid": txC, "vout": nC})
outputs = {}
outputs[self.nodes[0].getnewaddress()] = Decimal("24.9996")
signed2 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs))
@@ -77,8 +85,8 @@ class AbandonConflictTest(BitcoinTestFramework):
# Create a child tx spending ABC2
signed3_change = Decimal("24.999")
- inputs = [ {"txid":txABC2, "vout":0} ]
- outputs = { self.nodes[0].getnewaddress(): signed3_change }
+ inputs = [{"txid": txABC2, "vout": 0}]
+ outputs = {self.nodes[0].getnewaddress(): signed3_change}
signed3 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs))
# note tx is never directly referenced, only abandoned as a child of the above
self.nodes[0].sendrawtransaction(signed3["hex"])
@@ -106,7 +114,7 @@ class AbandonConflictTest(BitcoinTestFramework):
unconfbalance = self.nodes[0].getunconfirmedbalance() + self.nodes[0].getbalance()
assert_equal(unconfbalance, newbalance)
# Also shouldn't show up in listunspent
- assert(not txABC2 in [utxo["txid"] for utxo in self.nodes[0].listunspent(0)])
+ assert not txABC2 in [utxo["txid"] for utxo in self.nodes[0].listunspent(0)]
balance = newbalance
# Abandon original transaction and verify inputs are available again
@@ -146,8 +154,8 @@ class AbandonConflictTest(BitcoinTestFramework):
# Create a double spend of AB1 by spending again from only A's 10 output
# Mine double spend from node 1
- inputs =[]
- inputs.append({"txid":txA, "vout":nA})
+ inputs = []
+ inputs.append({"txid": txA, "vout": nA})
outputs = {}
outputs[self.nodes[1].getnewaddress()] = Decimal("9.9999")
tx = self.nodes[0].createrawtransaction(inputs, outputs)
@@ -173,5 +181,6 @@ class AbandonConflictTest(BitcoinTestFramework):
self.log.info("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
self.log.info(str(balance) + " -> " + str(newbalance) + " ?")
+
if __name__ == '__main__':
AbandonConflictTest().main()