|
11 | 11 |
|
12 | 12 | ## Possible test improvements
|
13 | 13 |
|
14 |
| -- TODO: test submitting a transaction and verifying it appears in mempool |
15 | 14 | - TODO: test what happens with -reindex and -reindex-chainstate before the
|
16 | 15 | snapshot is validated, and make sure it's deleted successfully.
|
17 | 16 |
|
|
35 | 34 | """
|
36 | 35 | from shutil import rmtree
|
37 | 36 |
|
| 37 | +from test_framework.messages import tx_from_hex |
38 | 38 | from test_framework.test_framework import BitcoinTestFramework
|
39 | 39 | from test_framework.util import (
|
40 | 40 | assert_equal,
|
41 | 41 | assert_raises_rpc_error,
|
42 | 42 | )
|
| 43 | +from test_framework.wallet import getnewdestination |
| 44 | + |
43 | 45 |
|
44 | 46 | START_HEIGHT = 199
|
45 | 47 | SNAPSHOT_BASE_HEIGHT = 299
|
@@ -207,6 +209,22 @@ def run_test(self):
|
207 | 209 |
|
208 | 210 | assert_equal(n1.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
|
209 | 211 |
|
| 212 | + self.log.info("Submit a spending transaction for a snapshot chainstate coin to the mempool") |
| 213 | + # spend the coinbase output of the first block that is not available on node1 |
| 214 | + spend_coin_blockhash = n1.getblockhash(START_HEIGHT + 1) |
| 215 | + assert_raises_rpc_error(-1, "Block not found on disk", n1.getblock, spend_coin_blockhash) |
| 216 | + prev_tx = n0.getblock(spend_coin_blockhash, 3)['tx'][0] |
| 217 | + prevout = {"txid": prev_tx['txid'], "vout": 0, "scriptPubKey": prev_tx['vout'][0]['scriptPubKey']['hex']} |
| 218 | + privkey = n0.get_deterministic_priv_key().key |
| 219 | + raw_tx = n1.createrawtransaction([prevout], {getnewdestination()[2]: 24.99}) |
| 220 | + signed_tx = n1.signrawtransactionwithkey(raw_tx, [privkey], [prevout])['hex'] |
| 221 | + signed_txid = tx_from_hex(signed_tx).rehash() |
| 222 | + |
| 223 | + assert n1.gettxout(prev_tx['txid'], 0) is not None |
| 224 | + n1.sendrawtransaction(signed_tx) |
| 225 | + assert signed_txid in n1.getrawmempool() |
| 226 | + assert not n1.gettxout(prev_tx['txid'], 0) |
| 227 | + |
210 | 228 | PAUSE_HEIGHT = FINAL_HEIGHT - 40
|
211 | 229 |
|
212 | 230 | self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)
|
|
0 commit comments