mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-01 08:24:21 +01:00
[test] CScriptNum Decode Check as Unit Tests
Migrates the CScriptNum decode tests into a unit test, and moved some changes made in #14816. Made possible by the integration of test_framework unit testing in #18576. Further extends the original test with larger ints, similar to the scriptnum_tests.cpp file. Adds test to blocktools.py testing fn create_coinbase() with CScriptNum decode.
This commit is contained in:
@@ -29,8 +29,6 @@ from test_framework.util import (
|
||||
assert_raises_rpc_error,
|
||||
connect_nodes,
|
||||
)
|
||||
from test_framework.script import CScriptNum
|
||||
|
||||
|
||||
def assert_template(node, block, expect, rehash=True):
|
||||
if rehash:
|
||||
@@ -91,12 +89,6 @@ class MiningTest(BitcoinTestFramework):
|
||||
coinbase_tx.rehash()
|
||||
|
||||
# round-trip the encoded bip34 block height commitment
|
||||
assert_equal(CScriptNum.decode(coinbase_tx.vin[0].scriptSig), next_height)
|
||||
# round-trip negative and multi-byte CScriptNums to catch python regression
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(1500))), 1500)
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1500))), -1500)
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1))), -1)
|
||||
|
||||
block = CBlock()
|
||||
block.nVersion = tmpl["version"]
|
||||
block.hashPrevBlock = int(tmpl["previousblockhash"], 16)
|
||||
|
||||
Reference in New Issue
Block a user