Skip to content

Commit

Permalink
test: assumeutxo: spend coin from spanshot chainstate after loading
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Jan 10, 2024
1 parent 063a8b8 commit bdff45e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
## Possible test improvements
- TODO: test submitting a transaction and verifying it appears in mempool
- TODO: test what happens with -reindex and -reindex-chainstate before the
snapshot is validated, and make sure it's deleted successfully.
Expand All @@ -35,11 +34,14 @@
"""
from shutil import rmtree

from test_framework.messages import tx_from_hex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)
from test_framework.wallet import getnewdestination


START_HEIGHT = 199
SNAPSHOT_BASE_HEIGHT = 299
Expand Down Expand Up @@ -207,6 +209,19 @@ def run_test(self):

assert_equal(n1.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)

self.log.info("Submit a spending transaction for a snapshot chainstate coin to the mempool")
# spend the coinbase output of the first block that is not available on node1
spend_coin_blockhash = n1.getblockhash(START_HEIGHT + 1)
assert_raises_rpc_error(-1, "Block not found on disk", n1.getblock, spend_coin_blockhash)
prev_tx = n0.getblock(spend_coin_blockhash, 3)['tx'][0]
prevout = {"txid": prev_tx['txid'], "vout": 0, "scriptPubKey": prev_tx['vout'][0]['scriptPubKey']['hex']}
privkey = n0.get_deterministic_priv_key().key
raw_tx = n1.createrawtransaction([prevout], {getnewdestination()[2]: 24.99})
signed_tx = n1.signrawtransactionwithkey(raw_tx, [privkey], [prevout])['hex']
signed_txid = tx_from_hex(signed_tx).rehash()
n1.sendrawtransaction(signed_tx)
assert signed_txid in n1.getrawmempool()

PAUSE_HEIGHT = FINAL_HEIGHT - 40

self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)
Expand Down

0 comments on commit bdff45e

Please sign in to comment.