aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkouloumos <kouloumosa@gmail.com>2023-01-13 12:21:33 +0200
committerkouloumos <kouloumosa@gmail.com>2023-01-16 19:14:21 +0200
commit6bd098a838881ba615c01354560a70d47256f90f (patch)
tree25abebd41e54566bb4b682f42b055cb7535c078f /test
parent42029a7fd42e93426bdfb40d1918d739d20962af (diff)
test: simplify tests by using the pre-mined chain
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/mempool_expiry.py9
-rwxr-xr-xtest/functional/mempool_resurrect.py6
-rwxr-xr-xtest/functional/rpc_net.py5
-rwxr-xr-xtest/functional/rpc_rawtransaction.py5
-rwxr-xr-xtest/functional/rpc_txoutproof.py7
5 files changed, 3 insertions, 29 deletions
diff --git a/test/functional/mempool_expiry.py b/test/functional/mempool_expiry.py
index 0c91da901f..15a5f765df 100755
--- a/test/functional/mempool_expiry.py
+++ b/test/functional/mempool_expiry.py
@@ -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)
diff --git a/test/functional/mempool_resurrect.py b/test/functional/mempool_resurrect.py
index 3e610d02ac..c10052372d 100755
--- a/test/functional/mempool_resurrect.py
+++ b/test/functional/mempool_resurrect.py
@@ -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
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index af8b2ad72b..5fdd5daddf 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -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
diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index 1c91ab6f5f..cdec4b2a85 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -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()
diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py
index d04d05962f..60b7ce8d20 100755
--- a/test/functional/rpc_txoutproof.py
+++ b/test/functional/rpc_txoutproof.py
@@ -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']