Skip to content

Commit 71e32ef

Browse files
committed
fix: use bool for getrawtransaction verbose param in Dash tests
The RPC type checking backported in this PR (bitcoin#26039) enforces strict type checking for RPC parameters. The getrawtransaction 'verbose' parameter is declared as RPCArg::Type::BOOL, so passing integer 1 instead of True now raises a type error. Fix all 29 occurrences across 13 test files where getrawtransaction was called with integer 1 instead of boolean True.
1 parent d1f478f commit 71e32ef

13 files changed

+29
-29
lines changed

test/functional/feature_asset_locks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def test_asset_locks(self, node_wallet, node, pubkey):
285285
self.check_mempool_result(tx=asset_lock_tx, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
286286
self.validate_credit_pool_balance(0)
287287
txid_in_block = self.send_tx(asset_lock_tx)
288-
rpc_tx = node.getrawtransaction(txid_in_block, 1)
288+
rpc_tx = node.getrawtransaction(txid_in_block, True)
289289
assert_equal(len(rpc_tx["assetLockTx"]["creditOutputs"]), 2)
290290
assert_equal(rpc_tx["assetLockTx"]["creditOutputs"][0]["valueSat"] + rpc_tx["assetLockTx"]["creditOutputs"][1]["valueSat"], locked_1)
291291
assert_equal(rpc_tx["assetLockTx"]["creditOutputs"][0]["scriptPubKey"]["hex"], key_to_p2pkh_script(pubkey).hex())
@@ -395,8 +395,8 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
395395
for node in self.nodes:
396396
self.wait_for_instantlock(is_id, node)
397397

398-
rawtx = node.getrawtransaction(txid, 1)
399-
rawtx_is = node.getrawtransaction(is_id, 1)
398+
rawtx = node.getrawtransaction(txid, True)
399+
rawtx_is = node.getrawtransaction(is_id, True)
400400
assert_equal(rawtx["instantlock"], False)
401401
assert_equal(rawtx_is["instantlock"], True)
402402
assert_equal(rawtx["chainlock"], False)
@@ -406,20 +406,20 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
406406
self.log.info("Reset IS spork")
407407
self.set_sporks()
408408

409-
assert "assetUnlockTx" in node.getrawtransaction(txid, 1)
409+
assert "assetUnlockTx" in node.getrawtransaction(txid, True)
410410

411411
self.mempool_size += 2
412412
self.check_mempool_size()
413413
self.validate_credit_pool_balance(locked)
414414
self.generate(node, 1)
415415
assert_equal(rawtx["instantlock"], False)
416416
assert_equal(rawtx["chainlock"], False)
417-
rawtx = node.getrawtransaction(txid, 1)
417+
rawtx = node.getrawtransaction(txid, True)
418418
assert_equal(rawtx["confirmations"], 1)
419419
self.validate_credit_pool_balance(locked - COIN)
420420
self.mempool_size -= 2
421421
self.check_mempool_size()
422-
block_asset_unlock = node.getrawtransaction(asset_unlock_tx.rehash(), 1)['blockhash']
422+
block_asset_unlock = node.getrawtransaction(asset_unlock_tx.rehash(), True)['blockhash']
423423
self.log.info("Checking rpc `getblock` and `getblockstats` succeeds as they use own fee calculation mechanism")
424424
assert_equal(node.getblockstats(node.getblockcount())['maxfee'], tiny_amount)
425425
node.getblock(block_asset_unlock, 2)

test/functional/feature_dip3_deterministicmns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def run_test(self):
181181
self.generate(self.nodes[0], 1)
182182
if expected_payee == multisig:
183183
block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
184-
cbtx = self.nodes[0].getrawtransaction(block['tx'][0], 1)
184+
cbtx = self.nodes[0].getrawtransaction(block['tx'][0], True)
185185
for out in cbtx['vout']:
186186
if 'address' in out['scriptPubKey']:
187187
if expected_payee in out['scriptPubKey']['address'] and out['valueSat'] == expected_amount:

test/functional/feature_dip3_v19.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ def test_revoke_protx(self, node_idx, revoke_mn: MasternodeInfo):
135135
fund_txid = self.nodes[0].sendtoaddress(funds_address, 1)
136136
self.bump_mocktime(10 * 60 + 1) # to make tx safe to include in block
137137
tip = self.generate(self.nodes[0], 1)[0]
138-
assert_equal(self.nodes[0].getrawtransaction(fund_txid, 1, tip)['confirmations'], 1)
138+
assert_equal(self.nodes[0].getrawtransaction(fund_txid, True, tip)['confirmations'], 1)
139139

140140
protx_result = revoke_mn.revoke(self.nodes[0], submit=True, reason=1, fundsAddr=funds_address)
141141
self.bump_mocktime(10 * 60 + 1) # to make tx safe to include in block
142142
tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
143-
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
143+
assert_equal(self.nodes[0].getrawtransaction(protx_result, True, tip)['confirmations'], 1)
144144
# Revoking a MN results in disconnects. Wait for disconnects to actually happen
145145
# and then reconnect the corresponding node back to let sync_blocks finish correctly.
146146
self.wait_until(lambda: self.nodes[node_idx].getconnectioncount() == 0)
@@ -156,12 +156,12 @@ def test_update_service_protx(self, mn: MasternodeInfo):
156156
fund_txid = self.nodes[0].sendtoaddress(mn.fundsAddr, 1)
157157
self.bump_mocktime(10 * 60 + 1) # to make tx safe to include in block
158158
tip = self.generate(self.nodes[0], 1)[0]
159-
assert_equal(self.nodes[0].getrawtransaction(fund_txid, 1, tip)['confirmations'], 1)
159+
assert_equal(self.nodes[0].getrawtransaction(fund_txid, True, tip)['confirmations'], 1)
160160

161161
protx_result = mn.update_service(self.nodes[0], submit=True, addrs_core_p2p=[f'127.0.0.2:{mn.nodePort}'])
162162
self.bump_mocktime(10 * 60 + 1) # to make tx safe to include in block
163163
tip = self.generate(self.nodes[0], 1)[0]
164-
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
164+
assert_equal(self.nodes[0].getrawtransaction(protx_result, True, tip)['confirmations'], 1)
165165

166166
for node in self.nodes:
167167
protx_info = node.protx('info', mn.proTxHash)

test/functional/feature_llmq_chainlocks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def run_test(self):
208208
self.log.info("Assert that after block generation these TXs are NOT included (as they are \"unsafe\")")
209209
node0_tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[-1]
210210
for txid in txs:
211-
tx = self.nodes[0].getrawtransaction(txid, 1)
211+
tx = self.nodes[0].getrawtransaction(txid, True)
212212
assert "confirmations" not in tx
213213

214214
def test_cb(self):
@@ -226,7 +226,7 @@ def test_cb(self):
226226
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 0)
227227
self.log.info("Assert that TXs got included now")
228228
for txid in txs:
229-
tx = self.nodes[0].getrawtransaction(txid, 1)
229+
tx = self.nodes[0].getrawtransaction(txid, True)
230230
assert "confirmations" in tx and tx["confirmations"] > 0
231231
# Enable network on first node again, which will cause the blocks to propagate and IS locks to happen retroactively
232232
# for the mined TXs, which will then allow the network to create a CLSIG
@@ -256,7 +256,7 @@ def test_cb(self):
256256

257257
def create_chained_txs(self, node, amount):
258258
txid = node.sendtoaddress(node.getnewaddress(), amount)
259-
tx = node.getrawtransaction(txid, 1)
259+
tx = node.getrawtransaction(txid, True)
260260
inputs = []
261261
valueIn = 0
262262
for txout in tx["vout"]:

test/functional/feature_mnehf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def check_fork(self, expected):
9999

100100
def ensure_tx_is_not_mined(self, tx_id):
101101
try:
102-
assert_equal(self.nodes[0].getrawtransaction(tx_id, 1)['height'], -1)
102+
assert_equal(self.nodes[0].getrawtransaction(tx_id, True)['height'], -1)
103103
raise AssertionError("Transaction should not be mined")
104104
except KeyError:
105105
# KeyError is expected

test/functional/feature_spentindex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def run_test(self):
9797
self.log.info("Testing getrawtransaction method...")
9898

9999
# Check that verbose raw transaction includes spent info
100-
txVerbose = self.nodes[3].getrawtransaction(unspent[0]["txid"], 1)
100+
txVerbose = self.nodes[3].getrawtransaction(unspent[0]["txid"], True)
101101
assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentTxId"], txid)
102102
assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentIndex"], 0)
103103
assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentHeight"], 106)
104104

105105
# Check that verbose raw transaction includes input values
106-
txVerbose2 = self.nodes[3].getrawtransaction(txid, 1)
106+
txVerbose2 = self.nodes[3].getrawtransaction(txid, True)
107107
assert_equal(txVerbose2["vin"][0]["value"], Decimal(unspent[0]["amount"]))
108108
assert_equal(txVerbose2["vin"][0]["valueSat"] - tx_fee_sat, amount)
109109

@@ -121,15 +121,15 @@ def run_test(self):
121121

122122
# Check the mempool index
123123
self.sync_all()
124-
txVerbose3 = self.nodes[1].getrawtransaction(txid2, 1)
124+
txVerbose3 = self.nodes[1].getrawtransaction(txid2, True)
125125
assert_equal(txVerbose3["vin"][0]["address"], address2)
126126
assert_equal(txVerbose3["vin"][0]["value"], Decimal(unspent[0]["amount"]) - tx_fee)
127127
assert_equal(txVerbose3["vin"][0]["valueSat"], amount)
128128

129129
# Check the database index
130130
self.generate(self.nodes[0], 1)
131131

132-
txVerbose4 = self.nodes[3].getrawtransaction(txid2, 1)
132+
txVerbose4 = self.nodes[3].getrawtransaction(txid2, True)
133133
assert_equal(txVerbose4["vin"][0]["address"], address2)
134134
assert_equal(txVerbose4["vin"][0]["value"], Decimal(unspent[0]["amount"]) - tx_fee)
135135
assert_equal(txVerbose4["vin"][0]["valueSat"], amount)

test/functional/feature_txindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def run_test(self):
6969
self.generate(self.nodes[0], 1)
7070

7171
# Check verbose raw transaction results
72-
verbose = self.nodes[3].getrawtransaction(txid, 1)
72+
verbose = self.nodes[3].getrawtransaction(txid, True)
7373
assert_equal(verbose["vout"][0]["valueSat"], 50000000000 - tx_fee_sat)
7474
assert_equal(verbose["vout"][0]["value"] * 100000000, 50000000000 - tx_fee_sat)
7575

test/functional/p2p_instantsend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def test_block_doublespend(self):
6969
# generate block on isolated node with doublespend transaction
7070
self.bump_mocktime(599)
7171
wrong_early_block = self.generate(isolated, 1, sync_fun=self.no_op)[0]
72-
assert not "confirmation" in isolated.getrawtransaction(dblspnd_txid, 1)
72+
assert not "confirmation" in isolated.getrawtransaction(dblspnd_txid, True)
7373
isolated.invalidateblock(wrong_early_block)
7474
self.bump_mocktime(1)
7575
wrong_block = self.generate(isolated, 1, sync_fun=self.no_op)[0]
76-
assert_equal(isolated.getrawtransaction(dblspnd_txid, 1)["confirmations"], 1)
76+
assert_equal(isolated.getrawtransaction(dblspnd_txid, True)["confirmations"], 1)
7777
# connect isolated block to network
7878
self.reconnect_isolated_node(self.isolated_idx, 0)
7979
# check doublespend block is rejected by other nodes

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ class MasternodeInfo:
11831183

11841184
def bury_tx(self, test: BitcoinTestFramework, genIdx: int, txid: str, depth: int):
11851185
chain_tip = test.generate(test.nodes[genIdx], depth)[0]
1186-
assert_equal(test.nodes[genIdx].getrawtransaction(txid, 1, chain_tip)['confirmations'], depth)
1186+
assert_equal(test.nodes[genIdx].getrawtransaction(txid, True, chain_tip)['confirmations'], depth)
11871187

11881188
def generate_addresses(self, node: TestNode, force_all: bool = False):
11891189
if not self.collateral_address or force_all:
@@ -1205,7 +1205,7 @@ def get_collateral_value(self) -> int:
12051205
return EVONODE_COLLATERAL if self.evo else MASTERNODE_COLLATERAL
12061206

12071207
def get_collateral_vout(self, node: TestNode, txid: str, should_throw: bool = True) -> int:
1208-
for txout in node.getrawtransaction(txid, 1)['vout']:
1208+
for txout in node.getrawtransaction(txid, True)['vout']:
12091209
if txout['value'] == self.get_collateral_value():
12101210
return txout['n']
12111211
if should_throw:

test/functional/test_framework/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def find_output(node, txid, amount, *, blockhash=None):
585585
Return index to output of txid with value amount
586586
Raises exception if there is none.
587587
"""
588-
txdata = node.getrawtransaction(txid, 1, blockhash)
588+
txdata = node.getrawtransaction(txid, True, blockhash)
589589
for i in range(len(txdata["vout"])):
590590
if txdata["vout"][i]["value"] == amount:
591591
return i

0 commit comments

Comments
 (0)