aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_rbf.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-23 17:38:14 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-07-28 18:15:53 +0200
commitaa02c64540cd77199c2834549786b9bc91fd4bc9 (patch)
treecccf9131625f385dd15c74b259cd8480984ce730 /test/functional/feature_rbf.py
parenta3f6397c7390ca033311f2219094ac90f6e582f9 (diff)
test: use MiniWallet for simple doublespend test in feature_rbf.py
Diffstat (limited to 'test/functional/feature_rbf.py')
-rwxr-xr-xtest/functional/feature_rbf.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py
index 2db11b26f0..65929704eb 100755
--- a/test/functional/feature_rbf.py
+++ b/test/functional/feature_rbf.py
@@ -4,6 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the RBF code."""
+from copy import deepcopy
from decimal import Decimal
from test_framework.blocktools import COINBASE_MATURITY
@@ -88,7 +89,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# the pre-mined test framework chain contains coinbase outputs to the
# MiniWallet's default address ADDRESS_BCRT1_P2WSH_OP_TRUE in blocks
# 76-100 (see method BitcoinTestFramework._initialize_chain())
- self.wallet.scan_blocks(start=76, num=1)
+ self.wallet.scan_blocks(start=76, num=2)
self.log.info("Running test simple doublespend...")
self.test_simple_doublespend()
@@ -130,24 +131,17 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_simple_doublespend(self):
"""Simple doublespend"""
- tx0_outpoint = make_utxo(self.nodes[0], int(1.1 * COIN))
-
- # make_utxo may have generated a bunch of blocks, so we need to sync
- # before we can spend the coins generated, or else the resulting
- # transactions might not be accepted by our peers.
- self.sync_all()
+ # we use MiniWallet to create a transaction template with inputs correctly set,
+ # and modify the output (amount, scriptPubKey) according to our needs
+ tx_template = self.wallet.create_self_transfer(from_node=self.nodes[0])['tx']
- tx1a = CTransaction()
- tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
+ tx1a = deepcopy(tx_template)
tx1a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
tx1a_hex = tx1a.serialize().hex()
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0)
- self.sync_all()
-
# Should fail because we haven't changed the fee
- tx1b = CTransaction()
- tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
+ tx1b = deepcopy(tx_template)
tx1b.vout = [CTxOut(1 * COIN, DUMMY_2_P2WPKH_SCRIPT)]
tx1b_hex = tx1b.serialize().hex()
@@ -155,9 +149,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
# Extra 0.1 BTC fee
- tx1b = CTransaction()
- tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
- tx1b.vout = [CTxOut(int(0.9 * COIN), DUMMY_P2WPKH_SCRIPT)]
+ tx1b.vout[0].nValue -= int(0.1 * COIN)
tx1b_hex = tx1b.serialize().hex()
# Works when enabled
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, 0)