|
8 | 8 | from test_framework.address import key_to_p2pkh |
9 | 9 | from test_framework.blocktools import COINBASE_MATURITY |
10 | 10 | from test_framework.key import ECKey |
| 11 | +from test_framework.messages import ( |
| 12 | + CMerkleBlock, |
| 13 | + from_hex, |
| 14 | +) |
11 | 15 | from test_framework.test_framework import BitcoinTestFramework |
12 | 16 | from test_framework.util import ( |
13 | 17 | assert_equal, |
14 | 18 | assert_raises_rpc_error, |
15 | 19 | ) |
16 | 20 | from test_framework.wallet_util import bytes_to_wif |
17 | 21 |
|
| 22 | + |
18 | 23 | class ImportPrunedFundsTest(BitcoinTestFramework): |
19 | 24 | def set_test_params(self): |
20 | 25 | self.setup_clean_chain = True |
@@ -124,5 +129,18 @@ def run_test(self): |
124 | 129 | w1.removeprunedfunds(txnid3) |
125 | 130 | assert not [tx for tx in w1.listtransactions(include_watchonly=True) if tx['txid'] == txnid3] |
126 | 131 |
|
| 132 | + # Check various RPC parameter validation errors |
| 133 | + assert_raises_rpc_error(-22, "TX decode failed", w1.importprunedfunds, b'invalid tx'.hex(), proof1) |
| 134 | + assert_raises_rpc_error(-5, "Transaction given doesn't exist in proof", w1.importprunedfunds, rawtxn2, proof1) |
| 135 | + |
| 136 | + mb = from_hex(CMerkleBlock(), proof1) |
| 137 | + mb.header.hashMerkleRoot = 0xdeadbeef # cause mismatch between merkle root and merkle block |
| 138 | + assert_raises_rpc_error(-5, "Something wrong with merkleblock", w1.importprunedfunds, rawtxn1, mb.serialize().hex()) |
| 139 | + |
| 140 | + mb = from_hex(CMerkleBlock(), proof1) |
| 141 | + mb.header.nTime += 1 # modify arbitrary block header field to change block hash |
| 142 | + assert_raises_rpc_error(-5, "Block not found in chain", w1.importprunedfunds, rawtxn1, mb.serialize().hex()) |
| 143 | + |
| 144 | + |
127 | 145 | if __name__ == '__main__': |
128 | 146 | ImportPrunedFundsTest().main() |
0 commit comments