aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_nulldummy.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-11-12 23:32:01 +0100
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-11-13 00:21:37 +0100
commite1d4a128e8c71a741c2435f949c1427929e151b7 (patch)
treeacc90939be25d06f806cf007c32184b8aab22b4c /test/functional/feature_nulldummy.py
parentc9dd5c8d6e59e27af98e99d2844d6ead8eec3162 (diff)
test: simplify and document NULLDUMMY-invalidation helper
The function `trueDummy` in feature_nulldummy.py is currently more complicated than it needs to be. Rather than converting the scriptSig to a CScript and looping through it to build a new scriptSig with the modified push, simply directly replace the push of null (OP_0) with a push of one (OP_TRUE/OP_1). Note that on master, actually an element with the value of 0x51 is pushed (0x0151...) -- this was very likely not intended, as 0x51 is the script op-code for OP_TRUE, and also the function's name suggests that the "true" value shall be pushed.
Diffstat (limited to 'test/functional/feature_nulldummy.py')
-rwxr-xr-xtest/functional/feature_nulldummy.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py
index 217a38050d..34491ffc1a 100755
--- a/test/functional/feature_nulldummy.py
+++ b/test/functional/feature_nulldummy.py
@@ -22,7 +22,10 @@ from test_framework.blocktools import (
create_transaction,
)
from test_framework.messages import CTransaction
-from test_framework.script import CScript
+from test_framework.script import (
+ OP_0,
+ OP_TRUE,
+)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@@ -33,15 +36,10 @@ NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argumen
def trueDummy(tx):
- scriptSig = CScript(tx.vin[0].scriptSig)
- newscript = []
- for i in scriptSig:
- if len(newscript) == 0:
- assert len(i) == 0
- newscript.append(b'\x51')
- else:
- newscript.append(i)
- tx.vin[0].scriptSig = CScript(newscript)
+ """Transform a NULLDUMMY compliant tx (i.e. scriptSig starts with OP_0)
+ to be non-NULLDUMMY compliant by replacing the dummy with OP_TRUE"""
+ assert_equal(tx.vin[0].scriptSig[0], OP_0)
+ tx.vin[0].scriptSig = bytes([OP_TRUE]) + tx.vin[0].scriptSig[1:]
tx.rehash()