mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
test: simplify tests by using the pre-mined chain
This commit is contained in:
parent
42029a7fd4
commit
6bd098a838
5 changed files with 3 additions and 29 deletions
|
@ -12,7 +12,6 @@ definable expiry timeout via the '-mempoolexpiry=<n>' command line argument
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import DEFAULT_MEMPOOL_EXPIRY_HOURS
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
|
@ -27,17 +26,11 @@ CUSTOM_MEMPOOL_EXPIRY = 10 # hours
|
|||
class MempoolExpiryTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def test_transaction_expiry(self, timeout):
|
||||
"""Tests that a transaction expires after the expiry timeout and its
|
||||
children are removed as well."""
|
||||
node = self.nodes[0]
|
||||
self.wallet = MiniWallet(node)
|
||||
|
||||
# Add enough mature utxos to the wallet so that all txs spend confirmed coins.
|
||||
self.generate(self.wallet, 4)
|
||||
self.generate(node, COINBASE_MATURITY)
|
||||
|
||||
# Send a parent transaction that will expire.
|
||||
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']
|
||||
|
@ -97,6 +90,8 @@ class MempoolExpiryTest(BitcoinTestFramework):
|
|||
assert_equal(half_expiry_time, node.getmempoolentry(independent_txid)['time'])
|
||||
|
||||
def run_test(self):
|
||||
self.wallet = MiniWallet(self.nodes[0])
|
||||
|
||||
self.log.info('Test default mempool expiry timeout of %d hours.' %
|
||||
DEFAULT_MEMPOOL_EXPIRY_HOURS)
|
||||
self.test_transaction_expiry(DEFAULT_MEMPOOL_EXPIRY_HOURS)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# 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 BitcoinTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
from test_framework.wallet import MiniWallet
|
||||
|
@ -13,16 +12,11 @@ from test_framework.wallet import MiniWallet
|
|||
class MempoolCoinbaseTest(BitcoinTestFramework):
|
||||
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
|
||||
|
|
|
@ -11,7 +11,6 @@ from decimal import Decimal
|
|||
from itertools import product
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
import test_framework.messages
|
||||
from test_framework.p2p import (
|
||||
P2PInterface,
|
||||
|
@ -43,7 +42,6 @@ def assert_net_servicesnames(servicesflag, servicenames):
|
|||
|
||||
class NetTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [["-minrelaytxfee=0.00001000"], ["-minrelaytxfee=0.00000500"]]
|
||||
self.supports_cli = False
|
||||
|
@ -51,9 +49,6 @@ class NetTest(BitcoinTestFramework):
|
|||
def run_test(self):
|
||||
# We need miniwallet to make a transaction
|
||||
self.wallet = MiniWallet(self.nodes[0])
|
||||
self.generate(self.wallet, 1)
|
||||
# Get out of IBD for the minfeefilter and getpeerinfo tests.
|
||||
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
|
||||
|
||||
# By default, the test framework sets up an addnode connection from
|
||||
# node 1 --> node0. By connecting node0 --> node 1, we're left with
|
||||
|
|
|
@ -16,7 +16,6 @@ from collections import OrderedDict
|
|||
from decimal import Decimal
|
||||
from itertools import product
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import (
|
||||
MAX_BIP125_RBF_SEQUENCE,
|
||||
CTransaction,
|
||||
|
@ -59,7 +58,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.add_wallet_options(parser, descriptors=False)
|
||||
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 3
|
||||
self.extra_args = [
|
||||
["-txindex"],
|
||||
|
@ -77,9 +75,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
self.wallet = MiniWallet(self.nodes[0])
|
||||
self.log.info("Prepare some coins for multiple *rawtransaction commands")
|
||||
self.generate(self.wallet, 10)
|
||||
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
|
||||
|
||||
self.getrawtransaction_tests()
|
||||
self.getrawtransaction_verbosity_tests()
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test gettxoutproof and verifytxoutproof RPCs."""
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import (
|
||||
CMerkleBlock,
|
||||
from_hex,
|
||||
|
@ -20,7 +19,6 @@ from test_framework.wallet import MiniWallet
|
|||
class MerkleBlockTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [
|
||||
[],
|
||||
["-txindex"],
|
||||
|
@ -28,12 +26,9 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
miniwallet = MiniWallet(self.nodes[0])
|
||||
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins
|
||||
self.generate(miniwallet, 5)
|
||||
self.generate(self.nodes[0], COINBASE_MATURITY)
|
||||
|
||||
chain_height = self.nodes[1].getblockcount()
|
||||
assert_equal(chain_height, 105)
|
||||
assert_equal(chain_height, 200)
|
||||
|
||||
txid1 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid']
|
||||
txid2 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid']
|
||||
|
|
Loading…
Add table
Reference in a new issue