Skip to content

Commit 6bd098a

Browse files
committed
test: simplify tests by using the pre-mined chain
1 parent 42029a7 commit 6bd098a

File tree

5 files changed

+3
-29
lines changed

5 files changed

+3
-29
lines changed

Diff for: test/functional/mempool_expiry.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from datetime import timedelta
1414

15-
from test_framework.blocktools import COINBASE_MATURITY
1615
from test_framework.messages import DEFAULT_MEMPOOL_EXPIRY_HOURS
1716
from test_framework.test_framework import BitcoinTestFramework
1817
from test_framework.util import (
@@ -27,17 +26,11 @@
2726
class MempoolExpiryTest(BitcoinTestFramework):
2827
def set_test_params(self):
2928
self.num_nodes = 1
30-
self.setup_clean_chain = True
3129

3230
def test_transaction_expiry(self, timeout):
3331
"""Tests that a transaction expires after the expiry timeout and its
3432
children are removed as well."""
3533
node = self.nodes[0]
36-
self.wallet = MiniWallet(node)
37-
38-
# Add enough mature utxos to the wallet so that all txs spend confirmed coins.
39-
self.generate(self.wallet, 4)
40-
self.generate(node, COINBASE_MATURITY)
4134

4235
# Send a parent transaction that will expire.
4336
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']
@@ -97,6 +90,8 @@ def test_transaction_expiry(self, timeout):
9790
assert_equal(half_expiry_time, node.getmempoolentry(independent_txid)['time'])
9891

9992
def run_test(self):
93+
self.wallet = MiniWallet(self.nodes[0])
94+
10095
self.log.info('Test default mempool expiry timeout of %d hours.' %
10196
DEFAULT_MEMPOOL_EXPIRY_HOURS)
10297
self.test_transaction_expiry(DEFAULT_MEMPOOL_EXPIRY_HOURS)

Diff for: test/functional/mempool_resurrect.py

-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test resurrection of mined transactions when the blockchain is re-organized."""
66

7-
from test_framework.blocktools import COINBASE_MATURITY
87
from test_framework.test_framework import BitcoinTestFramework
98
from test_framework.util import assert_equal
109
from test_framework.wallet import MiniWallet
@@ -13,16 +12,11 @@
1312
class MempoolCoinbaseTest(BitcoinTestFramework):
1413
def set_test_params(self):
1514
self.num_nodes = 1
16-
self.setup_clean_chain = True
1715

1816
def run_test(self):
1917
node = self.nodes[0]
2018
wallet = MiniWallet(node)
2119

22-
# Add enough mature utxos to the wallet so that all txs spend confirmed coins
23-
self.generate(wallet, 3)
24-
self.generate(node, COINBASE_MATURITY)
25-
2620
# Spend block 1/2/3's coinbase transactions
2721
# Mine a block
2822
# Create three more transactions, spending the spends

Diff for: test/functional/rpc_net.py

-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from itertools import product
1212
import time
1313

14-
from test_framework.blocktools import COINBASE_MATURITY
1514
import test_framework.messages
1615
from test_framework.p2p import (
1716
P2PInterface,
@@ -43,17 +42,13 @@ def assert_net_servicesnames(servicesflag, servicenames):
4342

4443
class NetTest(BitcoinTestFramework):
4544
def set_test_params(self):
46-
self.setup_clean_chain = True
4745
self.num_nodes = 2
4846
self.extra_args = [["-minrelaytxfee=0.00001000"], ["-minrelaytxfee=0.00000500"]]
4947
self.supports_cli = False
5048

5149
def run_test(self):
5250
# We need miniwallet to make a transaction
5351
self.wallet = MiniWallet(self.nodes[0])
54-
self.generate(self.wallet, 1)
55-
# Get out of IBD for the minfeefilter and getpeerinfo tests.
56-
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
5752

5853
# By default, the test framework sets up an addnode connection from
5954
# node 1 --> node0. By connecting node0 --> node 1, we're left with

Diff for: test/functional/rpc_rawtransaction.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from decimal import Decimal
1717
from itertools import product
1818

19-
from test_framework.blocktools import COINBASE_MATURITY
2019
from test_framework.messages import (
2120
MAX_BIP125_RBF_SEQUENCE,
2221
CTransaction,
@@ -59,7 +58,6 @@ def add_options(self, parser):
5958
self.add_wallet_options(parser, descriptors=False)
6059

6160
def set_test_params(self):
62-
self.setup_clean_chain = True
6361
self.num_nodes = 3
6462
self.extra_args = [
6563
["-txindex"],
@@ -77,9 +75,6 @@ def setup_network(self):
7775

7876
def run_test(self):
7977
self.wallet = MiniWallet(self.nodes[0])
80-
self.log.info("Prepare some coins for multiple *rawtransaction commands")
81-
self.generate(self.wallet, 10)
82-
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
8378

8479
self.getrawtransaction_tests()
8580
self.getrawtransaction_verbosity_tests()

Diff for: test/functional/rpc_txoutproof.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test gettxoutproof and verifytxoutproof RPCs."""
66

7-
from test_framework.blocktools import COINBASE_MATURITY
87
from test_framework.messages import (
98
CMerkleBlock,
109
from_hex,
@@ -20,20 +19,16 @@
2019
class MerkleBlockTest(BitcoinTestFramework):
2120
def set_test_params(self):
2221
self.num_nodes = 2
23-
self.setup_clean_chain = True
2422
self.extra_args = [
2523
[],
2624
["-txindex"],
2725
]
2826

2927
def run_test(self):
3028
miniwallet = MiniWallet(self.nodes[0])
31-
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins
32-
self.generate(miniwallet, 5)
33-
self.generate(self.nodes[0], COINBASE_MATURITY)
3429

3530
chain_height = self.nodes[1].getblockcount()
36-
assert_equal(chain_height, 105)
31+
assert_equal(chain_height, 200)
3732

3833
txid1 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid']
3934
txid2 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid']

0 commit comments

Comments
 (0)