aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_cltv.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-04-22 18:04:57 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-04-29 07:18:28 +0200
commitfa066f1b66ab75e6c88e11922bbd085c9d3211de (patch)
treea2dfab8d65239fe927c7a74d7913e6eb7ab51119 /test/functional/feature_cltv.py
parentfa5591d38cfc917235a3dffd61c36dbf1f781a4d (diff)
downloadbitcoin-fa066f1b66ab75e6c88e11922bbd085c9d3211de.tar.xz
test: Run feature_cltv with MiniWallet
Diffstat (limited to 'test/functional/feature_cltv.py')
-rwxr-xr-xtest/functional/feature_cltv.py30
1 files changed, 8 insertions, 22 deletions
diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py
index 49dea28c4e..6c51944d81 100755
--- a/test/functional/feature_cltv.py
+++ b/test/functional/feature_cltv.py
@@ -11,11 +11,9 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates at (regtest) block height
from test_framework.blocktools import (
create_block,
create_coinbase,
- create_transaction,
)
from test_framework.messages import (
CTransaction,
- ToHex,
msg_block,
)
from test_framework.p2p import P2PInterface
@@ -27,12 +25,8 @@ from test_framework.script import (
OP_DROP,
)
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import (
- assert_equal,
- hex_str_to_bytes,
-)
-
-from io import BytesIO
+from test_framework.util import assert_equal
+from test_framework.wallet import MiniWallet
CLTV_HEIGHT = 1351
@@ -41,15 +35,11 @@ CLTV_HEIGHT = 1351
# 1) prepending a given script to the scriptSig of vin 0 and
# 2) (optionally) modify the nSequence of vin 0 and the tx's nLockTime
def cltv_modify_tx(node, tx, prepend_scriptsig, nsequence=None, nlocktime=None):
+ assert_equal(len(tx.vin), 1)
if nsequence is not None:
tx.vin[0].nSequence = nsequence
tx.nLockTime = nlocktime
- # Need to re-sign, since nSequence and nLockTime changed
- signed_result = node.signrawtransactionwithwallet(ToHex(tx))
- tx = CTransaction()
- tx.deserialize(BytesIO(hex_str_to_bytes(signed_result['hex'])))
-
tx.vin[0].scriptSig = CScript(prepend_scriptsig + list(CScript(tx.vin[0].scriptSig)))
tx.rehash()
return tx
@@ -97,9 +87,6 @@ class BIP65Test(BitcoinTestFramework):
self.setup_clean_chain = True
self.rpc_timeout = 480
- def skip_test_if_missing_module(self):
- self.skip_if_no_wallet()
-
def test_cltv_info(self, *, is_active):
assert_equal(self.nodes[0].getblockchaininfo()['softforks']['bip65'], {
"active": is_active,
@@ -110,20 +97,20 @@ class BIP65Test(BitcoinTestFramework):
def run_test(self):
peer = self.nodes[0].add_p2p_connection(P2PInterface())
+ wallet = MiniWallet(self.nodes[0], raw_script=True)
self.test_cltv_info(is_active=False)
self.log.info("Mining %d blocks", CLTV_HEIGHT - 2)
- self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.nodes[0].generate(CLTV_HEIGHT - 2)]
- self.nodeaddress = self.nodes[0].getnewaddress()
+ wallet.generate(10)
+ self.nodes[0].generate(CLTV_HEIGHT - 2 - 10)
self.log.info("Test that invalid-according-to-CLTV transactions can still appear in a block")
# create one invalid tx per CLTV failure reason (5 in total) and collect them
invalid_ctlv_txs = []
for i in range(5):
- spendtx = create_transaction(self.nodes[0], self.coinbase_txids[i],
- self.nodeaddress, amount=1.0)
+ spendtx = wallet.create_self_transfer(from_node=self.nodes[0])['tx']
spendtx = cltv_invalidate(self.nodes[0], spendtx, i)
invalid_ctlv_txs.append(spendtx)
@@ -158,8 +145,7 @@ class BIP65Test(BitcoinTestFramework):
# create and test one invalid tx per CLTV failure reason (5 in total)
for i in range(5):
- spendtx = create_transaction(self.nodes[0], self.coinbase_txids[10+i],
- self.nodeaddress, amount=1.0)
+ spendtx = wallet.create_self_transfer(from_node=self.nodes[0])['tx']
spendtx = cltv_invalidate(self.nodes[0], spendtx, i)
expected_cltv_reject_reason = [