diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/feature_fee_estimation.py | 1 | ||||
-rwxr-xr-x | test/functional/feature_rbf.py | 1 | ||||
-rwxr-xr-x | test/functional/feature_signet.py | 8 | ||||
-rwxr-xr-x | test/functional/mempool_unbroadcast.py | 2 | ||||
-rwxr-xr-x | test/functional/mining_prioritisetransaction.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_permissions.py | 1 | ||||
-rwxr-xr-x | test/functional/p2p_segwit.py | 2 | ||||
-rwxr-xr-x | test/functional/rpc_rawtransaction.py | 2 | ||||
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 12 | ||||
-rw-r--r-- | test/functional/test_framework/util.py | 5 | ||||
-rw-r--r-- | test/functional/test_framework/wallet.py | 27 | ||||
-rwxr-xr-x | test/functional/wallet_importdescriptors.py | 2 |
12 files changed, 37 insertions, 28 deletions
diff --git a/test/functional/feature_fee_estimation.py b/test/functional/feature_fee_estimation.py index 422612a78e..ca21dd8a73 100755 --- a/test/functional/feature_fee_estimation.py +++ b/test/functional/feature_fee_estimation.py @@ -51,7 +51,6 @@ def small_txpuzzle_randfee( if total_in <= amount + fee: raise RuntimeError(f"Insufficient funds: need {amount + fee}, have {total_in}") tx = wallet.create_self_transfer_multi( - from_node=from_node, utxos_to_spend=utxos_to_spend, fee_per_output=0) tx.vout[0].nValue = int((total_in - amount - fee) * COIN) diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index b3b6328dbb..712897e5e7 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -473,7 +473,6 @@ class ReplaceByFeeTest(BitcoinTestFramework): # Now attempt to submit a tx that double-spends all the root tx inputs, which # would invalidate `num_txs_invalidated` transactions. double_tx = wallet.create_self_transfer_multi( - from_node=normal_node, utxos_to_spend=root_utxos, fee_per_output=10_000_000, # absurdly high feerate ) diff --git a/test/functional/feature_signet.py b/test/functional/feature_signet.py index 6578caee3f..4c1e48af6d 100755 --- a/test/functional/feature_signet.py +++ b/test/functional/feature_signet.py @@ -39,6 +39,14 @@ class SignetBasicTest(BitcoinTestFramework): shared_args3, shared_args3, ] + def setup_network(self): + self.setup_nodes() + + # Setup the three signets, which are incompatible with each other + self.connect_nodes(0, 1) + self.connect_nodes(2, 3) + self.connect_nodes(4, 5) + def run_test(self): self.log.info("basic tests using OP_TRUE challenge") diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py index 37ef4a9157..7587adc257 100755 --- a/test/functional/mempool_unbroadcast.py +++ b/test/functional/mempool_unbroadcast.py @@ -40,7 +40,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework): wallet_tx_hsh = node.sendtoaddress(addr, 0.0001) # generate a txn using sendrawtransaction - txFS = self.wallet.create_self_transfer(from_node=node) + txFS = self.wallet.create_self_transfer() rpc_tx_hsh = node.sendrawtransaction(txFS["hex"]) # check transactions are in unbroadcast using rpc diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py index e0f2446b2d..fb3974c1d5 100755 --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -212,7 +212,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): assert x not in mempool # Create a free transaction. Should be rejected. - tx_res = self.wallet.create_self_transfer(from_node=self.nodes[0], fee_rate=0) + tx_res = self.wallet.create_self_transfer(fee_rate=0) tx_hex = tx_res['hex'] tx_id = tx_res['txid'] diff --git a/test/functional/p2p_permissions.py b/test/functional/p2p_permissions.py index 1dc3a5b9a0..185011c2df 100755 --- a/test/functional/p2p_permissions.py +++ b/test/functional/p2p_permissions.py @@ -91,6 +91,7 @@ class P2PPermissionsTests(BitcoinTestFramework): self.nodes[1].assert_start_raises_init_error(["-whitelist=oopsie@127.0.0.1"], "Invalid P2P permission", match=ErrorMatch.PARTIAL_REGEX) self.nodes[1].assert_start_raises_init_error(["-whitelist=noban@127.0.0.1:230"], "Invalid netmask specified in", match=ErrorMatch.PARTIAL_REGEX) self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1/10"], "Cannot resolve -whitebind address", match=ErrorMatch.PARTIAL_REGEX) + self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1", "-bind=127.0.0.1", "-listen=0"], "Cannot set -bind or -whitebind together with -listen=0", match=ErrorMatch.PARTIAL_REGEX) def check_tx_relay(self): block_op_true = self.nodes[0].getblock(self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_P2WSH_OP_TRUE)[0]) diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 89ddfd3bcf..952f1e5cc5 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -1998,7 +1998,7 @@ class SegWitTest(BitcoinTestFramework): def serialize(self): return serialize_with_bogus_witness(self.tx) - tx = self.wallet.create_self_transfer(from_node=self.nodes[0])['tx'] + tx = self.wallet.create_self_transfer()['tx'] assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, hexstring=serialize_with_bogus_witness(tx).hex(), iswitness=True) with self.nodes[0].assert_debug_log(['Unknown transaction optional data']): self.test_node.send_and_ping(msg_bogus_tx(tx)) diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index dee6d777af..26a5da85b7 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -285,7 +285,7 @@ class RawTransactionsTest(BitcoinTestFramework): # Test a transaction with a large fee. # Fee rate is 0.20000000 BTC/kvB - tx = self.wallet.create_self_transfer(from_node=self.nodes[0], fee_rate=Decimal("0.20000000")) + tx = self.wallet.create_self_transfer(fee_rate=Decimal("0.20000000")) # Thus, testmempoolaccept should reject testres = self.nodes[2].testmempoolaccept([tx['hex']])[0] assert_equal(testres['allowed'], False) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 3f02d21d42..c880aabd21 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -581,6 +581,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): def connect_nodes(self, a, b): from_connection = self.nodes[a] to_connection = self.nodes[b] + from_num_peers = 1 + len(from_connection.getpeerinfo()) + to_num_peers = 1 + len(to_connection.getpeerinfo()) ip_port = "127.0.0.1:" + str(p2p_port(b)) from_connection.addnode(ip_port, "onetry") # poll until version handshake complete to avoid race conditions @@ -588,10 +590,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): # See comments in net_processing: # * Must have a version message before anything else # * Must have a verack message before anything else - wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) - wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo())) - wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) - wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo())) + self.wait_until(lambda: sum(peer['version'] != 0 for peer in from_connection.getpeerinfo()) == from_num_peers) + self.wait_until(lambda: sum(peer['version'] != 0 for peer in to_connection.getpeerinfo()) == to_num_peers) + self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()) == from_num_peers) + self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers) def disconnect_nodes(self, a, b): def disconnect_nodes_helper(from_connection, node_num): @@ -620,7 +622,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): raise # wait to disconnect - wait_until_helper(lambda: not get_peer_ids(), timeout=5) + self.wait_until(lambda: not get_peer_ids(), timeout=5) disconnect_nodes_helper(self.nodes[a], b) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 1c64fa4028..6a588275ea 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -527,9 +527,8 @@ def create_lots_of_big_transactions(mini_wallet, node, fee, tx_batch_size, txout use_internal_utxos = utxos is None for _ in range(tx_batch_size): tx = mini_wallet.create_self_transfer( - from_node=node, - utxo_to_spend=None if use_internal_utxos else utxos.pop(), - fee_rate=0, + utxo_to_spend=None if use_internal_utxos else utxos.pop(), + fee_rate=0, )["tx"] tx.vout[0].nValue -= fee_sats tx.vout.extend(txouts) diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 7249e53676..1e154fbd44 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -180,10 +180,10 @@ class MiniWallet: self._utxos = [] return utxos - def send_self_transfer(self, **kwargs): + def send_self_transfer(self, *, from_node, **kwargs): """Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" tx = self.create_self_transfer(**kwargs) - self.sendrawtransaction(from_node=kwargs['from_node'], tx_hex=tx['hex']) + self.sendrawtransaction(from_node=from_node, tx_hex=tx['hex']) return tx def send_to(self, *, from_node, scriptPubKey, amount, fee=1000): @@ -198,14 +198,14 @@ class MiniWallet: Returns a tuple (txid, n) referring to the created external utxo outpoint. """ - tx = self.create_self_transfer(from_node=from_node, fee_rate=0)["tx"] + tx = self.create_self_transfer(fee_rate=0)["tx"] assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee) tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex()) return txid, 1 - def send_self_transfer_multi(self, **kwargs): + def send_self_transfer_multi(self, *, from_node, **kwargs): """ Create and send a transaction that spends the given UTXOs and creates a certain number of outputs with equal amounts. @@ -217,16 +217,18 @@ class MiniWallet: - list of newly created UTXOs, ordered by vout index """ tx = self.create_self_transfer_multi(**kwargs) - txid = self.sendrawtransaction(from_node=kwargs['from_node'], tx_hex=tx.serialize().hex()) + txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex()) return {'new_utxos': [self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))], 'txid': txid, 'hex': tx.serialize().hex(), 'tx': tx} def create_self_transfer_multi( - self, *, from_node, - utxos_to_spend: Optional[List[dict]] = None, - num_outputs=1, - sequence=0, - fee_per_output=1000): + self, + *, + utxos_to_spend: Optional[List[dict]] = None, + num_outputs=1, + sequence=0, + fee_per_output=1000, + ): """ Create and return a transaction that spends the given UTXOs and creates a certain number of outputs with equal amounts. @@ -234,7 +236,7 @@ class MiniWallet: utxos_to_spend = utxos_to_spend or [self.get_utxo()] # create simple tx template (1 input, 1 output) tx = self.create_self_transfer( - fee_rate=0, from_node=from_node, + fee_rate=0, utxo_to_spend=utxos_to_spend[0], sequence=sequence)["tx"] # duplicate inputs, witnesses and outputs @@ -253,9 +255,8 @@ class MiniWallet: o.nValue = outputs_value_total // num_outputs return tx - def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, locktime=0, sequence=0): + def create_self_transfer(self, *, fee_rate=Decimal("0.003"), utxo_to_spend=None, locktime=0, sequence=0): """Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" - from_node = from_node or self._test_node utxo_to_spend = utxo_to_spend or self.get_utxo() if self._mode in (MiniWalletMode.RAW_OP_TRUE, MiniWalletMode.ADDRESS_OP_TRUE): vsize = Decimal(104) # anyone-can-spend diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index ac74ff2484..ff11f421a1 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -454,7 +454,7 @@ class ImportDescriptorsTest(BitcoinTestFramework): send_txid = wmulti_priv.sendtoaddress(w0.getnewaddress(), 8) decoded = wmulti_priv.gettransaction(txid=send_txid, verbose=True)['decoded'] assert_equal(len(decoded['vin'][0]['txinwitness']), 4) - self.generate(self.nodes[0], 6) + self.sync_all() self.nodes[1].createwallet(wallet_name="wmulti_pub", disable_private_keys=True, blank=True, descriptors=True) wmulti_pub = self.nodes[1].get_wallet_rpc("wmulti_pub") |