Initial Vexta Core v0.1.0 release
This commit is contained in:
commit
25c454329d
2481 changed files with 689289 additions and 0 deletions
57
test/functional/mempool_resurrect.py
Executable file
57
test/functional/mempool_resurrect.py
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014-2021 The DigiByte Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test resurrection of mined transactions when the blockchain is re-organized."""
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.test_framework import DigiByteTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
from test_framework.wallet import MiniWallet
|
||||
|
||||
|
||||
class MempoolCoinbaseTest(DigiByteTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0]
|
||||
wallet = MiniWallet(node)
|
||||
|
||||
# Add enough mature utxos to the wallet so that all txs spend confirmed coins
|
||||
self.generate(wallet, 3)
|
||||
self.generate(node, COINBASE_MATURITY)
|
||||
|
||||
# Spend block 1/2/3's coinbase transactions
|
||||
# Mine a block
|
||||
# Create three more transactions, spending the spends
|
||||
# Mine another block
|
||||
# ... make sure all the transactions are confirmed
|
||||
# Invalidate both blocks
|
||||
# ... make sure all the transactions are put back in the mempool
|
||||
# Mine a new block
|
||||
# ... make sure all the transactions are confirmed again
|
||||
blocks = []
|
||||
spends1_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)]
|
||||
blocks.extend(self.generate(node, 1))
|
||||
spends2_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)]
|
||||
blocks.extend(self.generate(node, 1))
|
||||
|
||||
spends_ids = set(spends1_ids + spends2_ids)
|
||||
|
||||
# mempool should be empty, all txns confirmed
|
||||
assert_equal(set(node.getrawmempool()), set())
|
||||
confirmed_txns = set(node.getblock(blocks[0])['tx'] + node.getblock(blocks[1])['tx'])
|
||||
# Checks that all spend txns are contained in the mined blocks
|
||||
assert spends_ids < confirmed_txns
|
||||
|
||||
# Use invalidateblock to re-org back
|
||||
node.invalidateblock(blocks[0])
|
||||
|
||||
# Vexta does not resurrect disconnected block transactions into mempool.
|
||||
assert_equal(set(node.getrawmempool()), set())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
MempoolCoinbaseTest().main()
|
||||
Loading…
Reference in a new issue