Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2019 The Bitcoin Core developers | # Copyright (c) 2015-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Utilities for manipulating blocks and transactions.""" | """Utilities for manipulating blocks and transactions.""" | ||||
import unittest | |||||
from .script import ( | from .script import ( | ||||
CScript, | CScript, | ||||
CScriptNum, | CScriptNum, | ||||
CScriptOp, | CScriptOp, | ||||
OP_1, | OP_1, | ||||
OP_CHECKSIG, | OP_CHECKSIG, | ||||
OP_DUP, | OP_DUP, | ||||
OP_EQUALVERIFY, | OP_EQUALVERIFY, | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | for _ in range(num): | ||||
[OP_RETURN, bytes(padding, 'utf-8')]))) | [OP_RETURN, bytes(padding, 'utf-8')]))) | ||||
# Create a proper fee for the transaction to be mined | # Create a proper fee for the transaction to be mined | ||||
ctx.vout[0].nValue -= int(fee_multiplier * node.calculate_fee(ctx)) | ctx.vout[0].nValue -= int(fee_multiplier * node.calculate_fee(ctx)) | ||||
signresult = node.signrawtransactionwithwallet( | signresult = node.signrawtransactionwithwallet( | ||||
ToHex(ctx), None, "NONE|FORKID") | ToHex(ctx), None, "NONE|FORKID") | ||||
txid = node.sendrawtransaction(signresult["hex"], 0) | txid = node.sendrawtransaction(signresult["hex"], 0) | ||||
txids.append(txid) | txids.append(txid) | ||||
return txids | return txids | ||||
class TestFrameworkBlockTools(unittest.TestCase): | |||||
def test_create_coinbase(self): | |||||
height = 20 | |||||
coinbase_tx = create_coinbase(height=height) | |||||
assert_equal(CScriptNum.decode(coinbase_tx.vin[0].scriptSig), height) |