aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_assumeutxo.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2024-01-10 01:07:17 +0100
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2024-01-10 01:18:27 +0100
commit931575418e082af37b88b1819125b0d0f0fabbd5 (patch)
tree2c29f1958ee7eb9387d40c9ecbb669853029dcd5 /test/functional/feature_assumeutxo.py
parent063a8b83875997068b3eb506b5f30f2691d18052 (diff)
test: assumeutxo: spend coin from snapshot chainstate after loading
Check that an UTXO that is only available in the snapshot chainstate is also visible to the mempool by submitting a spending transaction.
Diffstat (limited to 'test/functional/feature_assumeutxo.py')
-rwxr-xr-xtest/functional/feature_assumeutxo.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index 2e3589b020..f26a300f70 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -11,7 +11,6 @@ The assumeutxo value generated and used here is committed to in
## 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.
@@ -35,11 +34,14 @@ Interesting starting states could be loading a snapshot when the current chain t
"""
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
@@ -207,6 +209,22 @@ class AssumeutxoTest(BitcoinTestFramework):
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()
+
+ assert n1.gettxout(prev_tx['txid'], 0) is not None
+ n1.sendrawtransaction(signed_tx)
+ assert signed_txid in n1.getrawmempool()
+ assert not n1.gettxout(prev_tx['txid'], 0)
+
PAUSE_HEIGHT = FINAL_HEIGHT - 40
self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)