Skip to content

Commit 854ffca

Browse files
author
MarcoFalke
committed
Merge #16078: test: replace tx hash with txid in rawtransaction test
0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007) a65dafa replace tx hash with txid in test rawtransaction (LongShao007) Pull request description: The transaction hash is different from txid for witness transactions, so we should use txid instead of hash. ACKs for commit 0784af: Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
2 parents fe47ae1 + 0784af1 commit 854ffca

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

test/functional/rpc_rawtransaction.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ class RawTransactionsTest(BitcoinTestFramework):
4242
def set_test_params(self):
4343
self.setup_clean_chain = True
4444
self.num_nodes = 3
45-
self.extra_args = [["-addresstype=legacy", "-txindex"], ["-addresstype=legacy", "-txindex"], ["-addresstype=legacy", "-txindex"]]
45+
self.extra_args = [
46+
["-txindex"],
47+
["-txindex"],
48+
["-txindex"],
49+
]
4650

4751
def skip_test_if_missing_module(self):
4852
self.skip_if_no_wallet()
@@ -361,30 +365,30 @@ def run_test(self):
361365

362366
# getrawtransaction tests
363367
# 1. valid parameters - only supply txid
364-
txHash = rawTx["hash"]
365-
assert_equal(self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex'])
368+
txId = rawTx["txid"]
369+
assert_equal(self.nodes[0].getrawtransaction(txId), rawTxSigned['hex'])
366370

367371
# 2. valid parameters - supply txid and 0 for non-verbose
368-
assert_equal(self.nodes[0].getrawtransaction(txHash, 0), rawTxSigned['hex'])
372+
assert_equal(self.nodes[0].getrawtransaction(txId, 0), rawTxSigned['hex'])
369373

370374
# 3. valid parameters - supply txid and False for non-verbose
371-
assert_equal(self.nodes[0].getrawtransaction(txHash, False), rawTxSigned['hex'])
375+
assert_equal(self.nodes[0].getrawtransaction(txId, False), rawTxSigned['hex'])
372376

373377
# 4. valid parameters - supply txid and 1 for verbose.
374378
# We only check the "hex" field of the output so we don't need to update this test every time the output format changes.
375-
assert_equal(self.nodes[0].getrawtransaction(txHash, 1)["hex"], rawTxSigned['hex'])
379+
assert_equal(self.nodes[0].getrawtransaction(txId, 1)["hex"], rawTxSigned['hex'])
376380

377381
# 5. valid parameters - supply txid and True for non-verbose
378-
assert_equal(self.nodes[0].getrawtransaction(txHash, True)["hex"], rawTxSigned['hex'])
382+
assert_equal(self.nodes[0].getrawtransaction(txId, True)["hex"], rawTxSigned['hex'])
379383

380384
# 6. invalid parameters - supply txid and string "Flase"
381-
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txHash, "Flase")
385+
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txId, "Flase")
382386

383387
# 7. invalid parameters - supply txid and empty array
384-
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txHash, [])
388+
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txId, [])
385389

386390
# 8. invalid parameters - supply txid and empty dict
387-
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txHash, {})
391+
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txId, {})
388392

389393
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 1000}]
390394
outputs = { self.nodes[0].getnewaddress() : 1 }
@@ -438,17 +442,17 @@ def run_test(self):
438442
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
439443
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
440444
assert_equal(rawTxSigned['complete'], True)
441-
# 1000 sat fee, ~200 b transaction, fee rate should land around 5 sat/b = 0.00005000 BTC/kB
445+
# 1000 sat fee, ~100 b transaction, fee rate should land around 10 sat/b = 0.00010000 BTC/kB
442446
# Thus, testmempoolaccept should reject
443447
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']], 0.00001000)[0]
444448
assert_equal(testres['allowed'], False)
445449
assert_equal(testres['reject-reason'], '256: absurdly-high-fee')
446450
# and sendrawtransaction should throw
447451
assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'], 0.00001000)
448452
# And below calls should both succeed
449-
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.00007000')[0]
453+
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.00070000')[0]
450454
assert_equal(testres['allowed'], True)
451-
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.00007000')
455+
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.00070000')
452456

453457

454458
if __name__ == '__main__':

0 commit comments

Comments
 (0)