aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_invalid_block.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-11-15 18:43:15 +0100
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-11-17 15:45:34 +0100
commite57c0eb865b4ce155b5a4a2e56e46791a47e85af (patch)
treef4e7019956866b66133fdcfe918c2e78dac82ce5 /test/functional/p2p_invalid_block.py
parentdf5d783aef3e5af2d1294fc8ff9470a5dc878325 (diff)
downloadbitcoin-e57c0eb865b4ce155b5a4a2e56e46791a47e85af.tar.xz
test: refactor: replace OP_1/OP_TRUE magic numbers by constants
Diffstat (limited to 'test/functional/p2p_invalid_block.py')
-rwxr-xr-xtest/functional/p2p_invalid_block.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py
index 9598012484..0dfa25174b 100755
--- a/test/functional/p2p_invalid_block.py
+++ b/test/functional/p2p_invalid_block.py
@@ -15,9 +15,14 @@ becomes valid.
import copy
import time
-from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script
+from test_framework.blocktools import (
+ create_block,
+ create_coinbase,
+ create_tx_with_script,
+)
from test_framework.messages import COIN
from test_framework.p2p import P2PDataStore
+from test_framework.script import OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
@@ -66,9 +71,8 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
# For more information on merkle-root malleability see src/consensus/merkle.cpp.
self.log.info("Test merkle root malleability.")
- # b'0x51' is OP_TRUE
- tx1 = create_tx_with_script(block1.vtx[0], 0, script_sig=b'\x51', amount=50 * COIN)
- tx2 = create_tx_with_script(tx1, 0, script_sig=b'\x51', amount=50 * COIN)
+ tx1 = create_tx_with_script(block1.vtx[0], 0, script_sig=bytes([OP_TRUE]), amount=50 * COIN)
+ tx2 = create_tx_with_script(tx1, 0, script_sig=bytes([OP_TRUE]), amount=50 * COIN)
block2 = create_block(tip, create_coinbase(height), block_time, txlist=[tx1, tx2])
block_time += 1
block2.solve()
@@ -115,7 +119,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
# Complete testing of CVE-2018-17144, by checking for the inflation bug.
# Create a block that spends the output of a tx in a previous block.
- tx3 = create_tx_with_script(tx2, 0, script_sig=b'\x51', amount=50 * COIN)
+ tx3 = create_tx_with_script(tx2, 0, script_sig=bytes([OP_TRUE]), amount=50 * COIN)
tx3.vin.append(tx3.vin[0]) # Duplicates input
tx3.rehash()
block4 = create_block(tip, create_coinbase(height), block_time, txlist=[tx3])