diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-03-15 16:04:14 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-03-15 16:04:17 +0100 |
commit | 7b83c7d609ba61c5726650208b53111eb11a4b0e (patch) | |
tree | f761f2ac2fb295333b472e5e5e314e26ea152ad7 /test | |
parent | 28bdaa3f7697eef6c3d97e952228ce92e5d18aae (diff) | |
parent | 7573789925f6b5c3d73f43d2ebf8c732945c1824 (diff) | |
download | bitcoin-7b83c7d609ba61c5726650208b53111eb11a4b0e.tar.xz |
Merge bitcoin/bitcoin#24510: test: check for importprunedfunds RPC errors
7573789925f6b5c3d73f43d2ebf8c732945c1824 test: check for importprunedfunds RPC errors (Sebastian Falbesoner)
Pull request description:
This PR adds missing test coverage for the following errors of the `importprunedfunds` RPC:
https://github.com/bitcoin/bitcoin/blob/7003b6ab24f6adfffd71d7b7d4182afde52ff859/src/wallet/rpc/backup.cpp#L320-L322
https://github.com/bitcoin/bitcoin/blob/7003b6ab24f6adfffd71d7b7d4182afde52ff859/src/wallet/rpc/backup.cpp#L332-L334
https://github.com/bitcoin/bitcoin/blob/7003b6ab24f6adfffd71d7b7d4182afde52ff859/src/wallet/rpc/backup.cpp#L338-L340
https://github.com/bitcoin/bitcoin/blob/7003b6ab24f6adfffd71d7b7d4182afde52ff859/src/wallet/rpc/backup.cpp#L343-L345
ACKs for top commit:
MarcoFalke:
review ACK 7573789925f6b5c3d73f43d2ebf8c732945c1824
Tree-SHA512: b054520d102e5940bdeed2456ca644e91afb187d169b751b1262ce34480e4e9fbe1616ab184a78777c184350dced23508c3d367ed5825cab78bb5ad687fd7dac
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/wallet_importprunedfunds.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index cdb5823109..2a4d0981c7 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -5,9 +5,13 @@ """Test the importprunedfunds and removeprunedfunds RPCs.""" from decimal import Decimal -from test_framework.blocktools import COINBASE_MATURITY from test_framework.address import key_to_p2wpkh +from test_framework.blocktools import COINBASE_MATURITY from test_framework.key import ECKey +from test_framework.messages import ( + CMerkleBlock, + from_hex, +) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -15,6 +19,7 @@ from test_framework.util import ( ) from test_framework.wallet_util import bytes_to_wif + class ImportPrunedFundsTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True @@ -124,5 +129,18 @@ class ImportPrunedFundsTest(BitcoinTestFramework): w1.removeprunedfunds(txnid3) assert not [tx for tx in w1.listtransactions(include_watchonly=True) if tx['txid'] == txnid3] + # Check various RPC parameter validation errors + assert_raises_rpc_error(-22, "TX decode failed", w1.importprunedfunds, b'invalid tx'.hex(), proof1) + assert_raises_rpc_error(-5, "Transaction given doesn't exist in proof", w1.importprunedfunds, rawtxn2, proof1) + + mb = from_hex(CMerkleBlock(), proof1) + mb.header.hashMerkleRoot = 0xdeadbeef # cause mismatch between merkle root and merkle block + assert_raises_rpc_error(-5, "Something wrong with merkleblock", w1.importprunedfunds, rawtxn1, mb.serialize().hex()) + + mb = from_hex(CMerkleBlock(), proof1) + mb.header.nTime += 1 # modify arbitrary block header field to change block hash + assert_raises_rpc_error(-5, "Block not found in chain", w1.importprunedfunds, rawtxn1, mb.serialize().hex()) + + if __name__ == '__main__': ImportPrunedFundsTest().main() |