mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
7c43fa5426
9c34aff39309b8adc99d347e07b6ddb5366498e9 Remove previous_release.sh (Brian Liotti) e1e5960e10a9329d9f55a3967d546ffbdd896030 script: Add previous_release.py (Brian Liotti) Pull request description: Closes #18132 Added functionality: 1) checks file hash before untarring when using the binary download option ACKs for top commit: fjahr: re-ACK 9c34aff39309b8adc99d347e07b6ddb5366498e9 Sjors: tACK 9c34aff39309b8adc99d347e07b6ddb5366498e9 Tree-SHA512: 323f11828736a372a47f048592de8b027ddcd75b38f312dfc73f7b495d1e078bfeb384d9cdf434b3e70f2c6c0ce2da2df48e9a6460ac0e1967c6829a411c52d5
83 lines
3.1 KiB
Python
Executable File
83 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017-2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test that mempool.dat is both backward and forward compatible between versions
|
|
|
|
NOTE: The test is designed to prevent cases when compatibility is broken accidentally.
|
|
In case we need to break mempool compatibility we can continue to use the test by just bumping the version number.
|
|
|
|
Download node binaries:
|
|
contrib/devtools/previous_release.py -b v0.19.1 v0.18.1 v0.17.1 v0.16.3 v0.15.2
|
|
|
|
Only v0.15.0.0 is required by this test. The rest is used in other backwards compatibility tests.
|
|
"""
|
|
|
|
import os
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import (
|
|
adjust_bitcoin_conf_for_pre_16
|
|
)
|
|
|
|
class MempoolCompatibilityTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 2
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
self.skip_if_no_previous_releases()
|
|
|
|
def setup_network(self):
|
|
self.add_nodes(self.num_nodes, versions=[
|
|
150000, # oldest version supported by the test framework
|
|
None,
|
|
])
|
|
self.extra_args = [
|
|
[],
|
|
[],
|
|
]
|
|
adjust_bitcoin_conf_for_pre_16(self.nodes[0].bitcoinconf)
|
|
self.start_nodes()
|
|
self.import_deterministic_coinbase_privkeys()
|
|
|
|
def run_test(self):
|
|
self.log.info("Test that mempool.dat is compatible between versions")
|
|
|
|
old_node = self.nodes[0]
|
|
new_node = self.nodes[1]
|
|
recipient = old_node.getnewaddress()
|
|
self.stop_node(1)
|
|
|
|
self.log.info("Add a transaction to mempool on old node and shutdown")
|
|
old_tx_hash = old_node.sendtoaddress(recipient, 0.0001)
|
|
assert old_tx_hash in old_node.getrawmempool()
|
|
self.stop_node(0)
|
|
|
|
self.log.info("Move mempool.dat from old to new node")
|
|
old_node_mempool = os.path.join(old_node.datadir, self.chain, 'mempool.dat')
|
|
new_node_mempool = os.path.join(new_node.datadir, self.chain, 'mempool.dat')
|
|
os.rename(old_node_mempool, new_node_mempool)
|
|
|
|
self.log.info("Start new node and verify mempool contains the tx")
|
|
self.start_node(1)
|
|
assert old_tx_hash in new_node.getrawmempool()
|
|
|
|
self.log.info("Add unbroadcasted tx to mempool on new node and shutdown")
|
|
unbroadcasted_tx_hash = new_node.sendtoaddress(recipient, 0.0001)
|
|
assert unbroadcasted_tx_hash in new_node.getrawmempool()
|
|
mempool = new_node.getrawmempool(True)
|
|
assert mempool[unbroadcasted_tx_hash]['unbroadcast']
|
|
self.stop_node(1)
|
|
|
|
self.log.info("Move mempool.dat from new to old node")
|
|
os.rename(new_node_mempool, old_node_mempool)
|
|
|
|
self.log.info("Start old node again and verify mempool contains both txs")
|
|
self.start_node(0, ['-nowallet'])
|
|
assert old_tx_hash in old_node.getrawmempool()
|
|
assert unbroadcasted_tx_hash in old_node.getrawmempool()
|
|
|
|
if __name__ == "__main__":
|
|
MempoolCompatibilityTest().main()
|