diff options
author | Gregory Sanders <gsanders87@gmail.com> | 2018-11-27 10:06:19 -0500 |
---|---|---|
committer | Gregory Sanders <gsanders87@gmail.com> | 2018-11-29 08:31:48 -0500 |
commit | 2012d4df23b7b065ccc1dbe596073d98e428fd3d (patch) | |
tree | 7f565e7c1bc56bff9e44f8fa6d3bc991a2fdc5f4 /test/functional/mining_basic.py | |
parent | a4eaaa6ac53606a1533b56050af77961d8c27dc7 (diff) |
Add CScriptNum decode python implementation in functional suite
Diffstat (limited to 'test/functional/mining_basic.py')
-rwxr-xr-x | test/functional/mining_basic.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index 9f01be0646..6e74731349 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -25,7 +25,7 @@ from test_framework.util import ( assert_raises_rpc_error, bytes_to_hex_str as b2x, ) - +from test_framework.script import CScriptNum def assert_template(node, block, expect, rehash=True): if rehash: @@ -65,11 +65,19 @@ class MiningTest(BitcoinTestFramework): assert 'proposal' in tmpl['capabilities'] assert 'coinbasetxn' not in tmpl - coinbase_tx = create_coinbase(height=int(tmpl["height"]) + 1) + next_height = int(tmpl["height"]) + coinbase_tx = create_coinbase(height=next_height) # sequence numbers must not be max for nLockTime to have effect coinbase_tx.vin[0].nSequence = 2 ** 32 - 2 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) |