Skip to content

Commit 3699786

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23835: test: check for invalid listtransactions RPC parameters
c27bba9 test: check for invalid listtransactions RPC parameters (Sebastian Falbesoner) Pull request description: This PR adds missing test coverage for RPC errors that are thrown if invalid parameters are passed to `listtransactions`: https://github.com/bitcoin/bitcoin/blob/887796a5ffcbafcd281b920f8d55fcb6e8347584/src/wallet/rpc/transactions.cpp#L508 https://github.com/bitcoin/bitcoin/blob/887796a5ffcbafcd281b920f8d55fcb6e8347584/src/wallet/rpc/transactions.cpp#L524 https://github.com/bitcoin/bitcoin/blob/887796a5ffcbafcd281b920f8d55fcb6e8347584/src/wallet/rpc/transactions.cpp#L526 ACKs for top commit: shaavan: ACK c27bba9 Tree-SHA512: e5a23590186b4d9663261ff6cea52ac45e9bf2f2ef693c22b3452bb07af9b800fdabc2a94fd2852c686c28214a496d7afe296e41831759f2182feac2482635d0
2 parents dada92f + c27bba9 commit 3699786

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/wallet_listtransactions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from test_framework.util import (
1717
assert_array_result,
1818
assert_equal,
19+
assert_raises_rpc_error,
1920
)
2021

2122

@@ -107,6 +108,7 @@ def run_test(self):
107108

108109
self.run_rbf_opt_in_test()
109110
self.run_externally_generated_address_test()
111+
self.run_invalid_parameters_test()
110112

111113
def run_rbf_opt_in_test(self):
112114
"""Test the opt-in-rbf flag for sent and received transactions."""
@@ -275,6 +277,13 @@ def normalize_list(txs):
275277
assert_equal(['pizza2'], self.nodes[0].getaddressinfo(addr2)['labels'])
276278
assert_equal(['pizza3'], self.nodes[0].getaddressinfo(addr3)['labels'])
277279

280+
def run_invalid_parameters_test(self):
281+
self.log.info("Test listtransactions RPC parameter validity")
282+
assert_raises_rpc_error(-8, 'Label argument must be a valid label name or "*".', self.nodes[0].listtransactions, label="")
283+
self.nodes[0].listtransactions(label="*")
284+
assert_raises_rpc_error(-8, "Negative count", self.nodes[0].listtransactions, count=-1)
285+
assert_raises_rpc_error(-8, "Negative from", self.nodes[0].listtransactions, skip=-1)
286+
278287

279288
if __name__ == '__main__':
280289
ListTransactionsTest().main()

0 commit comments

Comments
 (0)