Skip to content

Commit 5546422

Browse files
committed
Tests: minor fixes for mining_pos_reorg_py
- no need to check "spendable" utxos (as we are not dealing with watch-only). - no need to catch `bad-txns-inputs-spent` exception with sendrawtransaction (as we are not dealing with zPIVs anymore) - double check that the double-spend is not on chain/mempool with getrawtransaction
1 parent dc7eb08 commit 5546422

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

test/functional/mining_pos_reorg.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def findUtxoInList(txid, vout, utxo_list):
9696

9797
# The stake input was unspent 1 block ago, now it's not
9898
res, utxo = findUtxoInList(stakeinput["txid"], stakeinput["vout"], initial_unspent_0)
99-
assert (res and utxo["spendable"])
99+
assert (res)
100100
res, utxo = findUtxoInList(stakeinput["txid"], stakeinput["vout"], self.nodes[0].listunspent())
101-
assert (not res or not utxo["spendable"])
101+
assert (not res)
102102
self.log.info("Coinstake input %s...%s-%d is no longer spendable." % (
103103
stakeinput["txid"][:9], stakeinput["txid"][-4:], stakeinput["vout"]))
104104

@@ -123,17 +123,11 @@ def findUtxoInList(txid, vout, utxo_list):
123123
{"xxncEuJK27ygNh7imNfaX8JV6ZQUnoBqzN": (stakeinput_amount-0.01)})
124124
rawtx = self.nodes[0].signrawtransaction(rawtx_unsigned)
125125
assert(rawtx["complete"])
126-
try:
127-
self.nodes[0].sendrawtransaction(rawtx["hex"])
128-
except JSONRPCException as e:
129-
# JSONRPCException was thrown as expected. Check the code and message values are correct.
130-
if e.error["code"] not in [-26, -25]:
131-
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
132-
if ([x for x in ["bad-txns-inputs-spent", "Missing inputs"] if x in e.error['message']] == []):
133-
raise e
134-
except Exception as e:
135-
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
136-
self.log.info("GOOD: v2 spend was not possible.")
126+
assert_raises_rpc_error(-25, "Missing inputs", self.nodes[0].sendrawtransaction, rawtx["hex"])
127+
txid = self.nodes[0].decoderawtransaction(rawtx["hex"])["txid"]
128+
assert_raises_rpc_error(-5, "No such mempool or blockchain transaction",
129+
self.nodes[0].getrawtransaction, txid)
130+
self.log.info("GOOD: spending the stake input was not possible.")
137131

138132
# Stake 12 blocks with node-1
139133
set_node_times(self.nodes, block_time_1)

0 commit comments

Comments
 (0)