From fa0404dbb76abd7ebf7c14bd80ce7c6297e20466 Mon Sep 17 00:00:00 2001 From: MacroFake Date: Tue, 12 Jul 2022 17:28:20 +0200 Subject: scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCE -BEGIN VERIFY SCRIPT- sed -i 's:BIP125_SEQUENCE_NUMBER:MAX_BIP125_RBF_SEQUENCE:g' $(git grep -l BIP125_SEQUENCE_NUMBER ./test) -END VERIFY SCRIPT- --- test/functional/feature_rbf.py | 10 +++++----- test/functional/mempool_accept.py | 6 +++--- test/functional/p2p_segwit.py | 4 ++-- test/functional/rpc_packages.py | 4 ++-- test/functional/rpc_rawtransaction.py | 4 ++-- test/functional/test_framework/messages.py | 2 +- test/functional/wallet_bumpfee.py | 8 ++++---- test/functional/wallet_listsinceblock.py | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index 1a8362d94d..2237a4171e 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -7,7 +7,7 @@ from decimal import Decimal from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, COIN, SEQUENCE_FINAL, ) @@ -428,7 +428,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): optin_parent_tx = wallet.send_self_transfer_multi( from_node=normal_node, - sequence=BIP125_SEQUENCE_NUMBER, + sequence=MAX_BIP125_RBF_SEQUENCE, utxos_to_spend=[root_utxos[graph_num]], num_outputs=txs_per_graph, ) @@ -636,14 +636,14 @@ class ReplaceByFeeTest(BitcoinTestFramework): optin_parent_tx = self.wallet.send_self_transfer( from_node=self.nodes[0], utxo_to_spend=confirmed_utxo, - sequence=BIP125_SEQUENCE_NUMBER, + sequence=MAX_BIP125_RBF_SEQUENCE, fee_rate=Decimal('0.01'), ) assert_equal(True, self.nodes[0].getmempoolentry(optin_parent_tx['txid'])['bip125-replaceable']) replacement_parent_tx = self.wallet.create_self_transfer( utxo_to_spend=confirmed_utxo, - sequence=BIP125_SEQUENCE_NUMBER, + sequence=MAX_BIP125_RBF_SEQUENCE, fee_rate=Decimal('0.02'), ) @@ -711,7 +711,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): optout_tx = self.wallet.send_self_transfer( from_node=self.nodes[0], utxo_to_spend=confirmed_utxo, - sequence=BIP125_SEQUENCE_NUMBER + 1, + sequence=MAX_BIP125_RBF_SEQUENCE + 1, fee_rate=Decimal('0.01'), ) assert_equal(False, self.nodes[0].getmempoolentry(optout_tx['txid'])['bip125-replaceable']) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 85464b8d0d..65b37a4975 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -11,7 +11,7 @@ import math from test_framework.test_framework import BitcoinTestFramework from test_framework.key import ECKey from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, COIN, COutPoint, CTxIn, @@ -87,7 +87,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.log.info('A transaction not in the mempool') fee = Decimal('0.000007') utxo_to_spend = self.wallet.get_utxo(txid=txid_in_block) # use 0.3 BTC UTXO - tx = self.wallet.create_self_transfer(utxo_to_spend=utxo_to_spend, sequence=BIP125_SEQUENCE_NUMBER)['tx'] + tx = self.wallet.create_self_transfer(utxo_to_spend=utxo_to_spend, sequence=MAX_BIP125_RBF_SEQUENCE)['tx'] tx.vout[0].nValue = int((Decimal('0.3') - fee) * COIN) raw_tx_0 = tx.serialize().hex() txid_0 = tx.rehash() @@ -125,7 +125,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.log.info('A transaction that replaces a mempool transaction') tx = tx_from_hex(raw_tx_0) tx.vout[0].nValue -= int(fee * COIN) # Double the fee - tx.vin[0].nSequence = BIP125_SEQUENCE_NUMBER + 1 # Now, opt out of RBF + tx.vin[0].nSequence = MAX_BIP125_RBF_SEQUENCE + 1 # Now, opt out of RBF raw_tx_0 = tx.serialize().hex() txid_0 = tx.rehash() self.check_mempool_result( diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index eedb7e6fa1..db6954ccf6 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -16,7 +16,7 @@ from test_framework.blocktools import ( ) from test_framework.key import ECKey from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, CBlockHeader, CInv, COutPoint, @@ -589,7 +589,7 @@ class SegWitTest(BitcoinTestFramework): tx.vin = [CTxIn(COutPoint(p2sh_tx.sha256, 0), CScript([witness_script]))] tx.vout = [CTxOut(p2sh_tx.vout[0].nValue - 10000, script_pubkey)] tx.vout.append(CTxOut(8000, script_pubkey)) # Might burn this later - tx.vin[0].nSequence = BIP125_SEQUENCE_NUMBER # Just to have the option to bump this tx from the mempool + tx.vin[0].nSequence = MAX_BIP125_RBF_SEQUENCE # Just to have the option to bump this tx from the mempool tx.rehash() # This is always accepted, since the mempool policy is to consider segwit as always active diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index f687849287..9a563cbf5f 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -10,7 +10,7 @@ import random from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE from test_framework.test_framework import BitcoinTestFramework from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, COIN, CTxInWitness, tx_from_hex, @@ -273,7 +273,7 @@ class RPCPackagesTest(BitcoinTestFramework): def test_rbf(self): node = self.nodes[0] coin = self.coins.pop() - inputs = [{"txid": coin["txid"], "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}] + inputs = [{"txid": coin["txid"], "vout": 0, "sequence": MAX_BIP125_RBF_SEQUENCE}] fee = Decimal('0.00125000') output = {node.get_deterministic_priv_key().address: 50 - fee} raw_replaceable_tx = node.createrawtransaction(inputs, output) diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index 26a5da85b7..bbf1f022d7 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -17,7 +17,7 @@ from decimal import Decimal from test_framework.blocktools import COINBASE_MATURITY from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, CTransaction, tx_from_hex, ) @@ -223,7 +223,7 @@ class RawTransactionsTest(BitcoinTestFramework): # Test `createrawtransaction` mismatch between sequence number(s) and `replaceable` option assert_raises_rpc_error(-8, "Invalid parameter combination: Sequence number(s) contradict replaceable option", - self.nodes[0].createrawtransaction, [{'txid': TXID, 'vout': 0, 'sequence': BIP125_SEQUENCE_NUMBER+1}], {}, 0, True) + self.nodes[0].createrawtransaction, [{'txid': TXID, 'vout': 0, 'sequence': MAX_BIP125_RBF_SEQUENCE+1}], {}, 0, True) # Test `createrawtransaction` invalid `locktime` assert_raises_rpc_error(-3, "Expected type number", self.nodes[0].createrawtransaction, [], {}, 'foo') diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index aae44c0ac0..e6d9f9ae3a 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -39,7 +39,7 @@ MAX_BLOOM_HASH_FUNCS = 50 COIN = 100000000 # 1 btc in satoshis MAX_MONEY = 21000000 * COIN -BIP125_SEQUENCE_NUMBER = 0xfffffffd # Sequence number that is rbf-opt-in (BIP 125) and csv-opt-out (BIP 68) +MAX_BIP125_RBF_SEQUENCE = 0xfffffffd # Sequence number that is rbf-opt-in (BIP 125) and csv-opt-out (BIP 68) SEQUENCE_FINAL = 0xffffffff # Sequence number that disables nLockTime if set for every input of a tx MAX_PROTOCOL_MESSAGE_LENGTH = 4000000 # Maximum length of incoming protocol messages diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index 3b23ee8e94..9a481b290b 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -23,7 +23,7 @@ from test_framework.blocktools import ( send_to_witness, ) from test_framework.messages import ( - BIP125_SEQUENCE_NUMBER, + MAX_BIP125_RBF_SEQUENCE, ) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( @@ -212,7 +212,7 @@ def test_segwit_bumpfee_succeeds(self, rbf_node, dest_address): rbfraw = rbf_node.createrawtransaction([{ 'txid': segwitid, 'vout': 0, - "sequence": BIP125_SEQUENCE_NUMBER + "sequence": MAX_BIP125_RBF_SEQUENCE }], {dest_address: Decimal("0.0005"), rbf_node.getrawchangeaddress(): Decimal("0.0003")}) rbfsigned = rbf_node.signrawtransactionwithwallet(rbfraw) @@ -243,7 +243,7 @@ def test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address): "txid": utxo["txid"], "vout": utxo["vout"], "address": utxo["address"], - "sequence": BIP125_SEQUENCE_NUMBER + "sequence": MAX_BIP125_RBF_SEQUENCE } for utxo in utxos] output_val = sum(utxo["amount"] for utxo in utxos) - fee rawtx = rbf_node.createrawtransaction(inputs, {dest_address: output_val}) @@ -578,7 +578,7 @@ def test_change_script_match(self, rbf_node, dest_address): def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")): tx_input = dict( - sequence=BIP125_SEQUENCE_NUMBER, **next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000"))) + sequence=MAX_BIP125_RBF_SEQUENCE, **next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000"))) destinations = {dest_address: Decimal("0.00050000")} if change_size > 0: destinations[node.getrawchangeaddress()] = change_size diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py index fc06565983..1f3a276d9c 100755 --- a/test/functional/wallet_listsinceblock.py +++ b/test/functional/wallet_listsinceblock.py @@ -8,7 +8,7 @@ from test_framework.address import key_to_p2wpkh from test_framework.blocktools import COINBASE_MATURITY from test_framework.key import ECKey from test_framework.test_framework import BitcoinTestFramework -from test_framework.messages import BIP125_SEQUENCE_NUMBER +from test_framework.messages import MAX_BIP125_RBF_SEQUENCE from test_framework.util import ( assert_array_result, assert_equal, @@ -346,7 +346,7 @@ class ListSinceBlockTest(BitcoinTestFramework): dest_address = spending_node.getnewaddress() tx_input = dict( - sequence=BIP125_SEQUENCE_NUMBER, **next(u for u in spending_node.listunspent())) + sequence=MAX_BIP125_RBF_SEQUENCE, **next(u for u in spending_node.listunspent())) rawtx = spending_node.createrawtransaction( [tx_input], {dest_address: tx_input["amount"] - Decimal("0.00051000"), spending_node.getrawchangeaddress(): Decimal("0.00050000")}) -- cgit v1.2.3 From faace13b712a349863eaf7c469069db17b6e9dd5 Mon Sep 17 00:00:00 2001 From: MacroFake Date: Tue, 12 Jul 2022 18:55:43 +0200 Subject: test: Remove duplicate MAX_BIP125_RBF_SEQUENCE constant --- test/functional/rpc_psbt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index d2a888fd31..264b2ac32d 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -11,8 +11,9 @@ from itertools import product from test_framework.descriptors import descsum_create from test_framework.key import ECKey, H_POINT from test_framework.messages import ( - ser_compact_size, + MAX_BIP125_RBF_SEQUENCE, WITNESS_SCALE_FACTOR, + ser_compact_size, ) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( @@ -27,7 +28,6 @@ from test_framework.wallet_util import bytes_to_wif import json import os -MAX_BIP125_RBF_SEQUENCE = 0xfffffffd # Create one-input, one-output, no-fee transaction: class PSBTTest(BitcoinTestFramework): -- cgit v1.2.3