Skip to content

Commit 7e32fde

Browse files
committed
test: feature_cltv.py: don't return tx copies in modification functions
The functions cltv_modify_tx(), cltv_invalidate() and cltv_validate() all modify the passed transaction in-place, i.e. there is no need to return a copy.
1 parent 9ab2ce0 commit 7e32fde

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/functional/feature_cltv.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def cltv_modify_tx(tx, prepend_scriptsig, nsequence=None, nlocktime=None):
4545

4646
tx.vin[0].scriptSig = CScript(prepend_scriptsig + list(CScript(tx.vin[0].scriptSig)))
4747
tx.rehash()
48-
return tx
4948

5049

5150
def cltv_invalidate(tx, failure_reason):
@@ -69,14 +68,14 @@ def cltv_invalidate(tx, failure_reason):
6968
[[CScriptNum(500), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0xffffffff, 500],
7069
][failure_reason]
7170

72-
return cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
71+
cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
7372

7473

7574
def cltv_validate(tx, height):
7675
# Modify the signature in vin 0 and nSequence/nLockTime of the tx to pass CLTV
7776
scheme = [[CScriptNum(height), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, height]
7877

79-
return cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
78+
cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
8079

8180

8281
class BIP65Test(BitcoinTestFramework):
@@ -114,7 +113,7 @@ def run_test(self):
114113
invalid_cltv_txs = []
115114
for i in range(5):
116115
spendtx = wallet.create_self_transfer(from_node=self.nodes[0])['tx']
117-
spendtx = cltv_invalidate(spendtx, i)
116+
cltv_invalidate(spendtx, i)
118117
invalid_cltv_txs.append(spendtx)
119118

120119
tip = self.nodes[0].getbestblockhash()
@@ -149,7 +148,7 @@ def run_test(self):
149148
# create and test one invalid tx per CLTV failure reason (5 in total)
150149
for i in range(5):
151150
spendtx = wallet.create_self_transfer(from_node=self.nodes[0])['tx']
152-
spendtx = cltv_invalidate(spendtx, i)
151+
cltv_invalidate(spendtx, i)
153152

154153
expected_cltv_reject_reason = [
155154
"non-mandatory-script-verify-flag (Operation not valid with the current stack size)",
@@ -182,7 +181,7 @@ def run_test(self):
182181
peer.sync_with_ping()
183182

184183
self.log.info("Test that a version 4 block with a valid-according-to-CLTV transaction is accepted")
185-
spendtx = cltv_validate(spendtx, CLTV_HEIGHT - 1)
184+
cltv_validate(spendtx, CLTV_HEIGHT - 1)
186185

187186
block.vtx.pop(1)
188187
block.vtx.append(spendtx)

0 commit comments

Comments
 (0)