Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_nulldummy.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2016 The Bitcoin Core developers | # Copyright (c) 2016 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. | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import * | from test_framework.util import * | ||||
from test_framework.messages import FromHex | |||||
from test_framework.mininode import CTransaction, network_thread_start | from test_framework.mininode import CTransaction, network_thread_start | ||||
from test_framework.blocktools import create_coinbase, create_block | from test_framework.blocktools import create_coinbase, create_block | ||||
from test_framework.script import CScript | from test_framework.script import CScript | ||||
from io import BytesIO | |||||
import time | import time | ||||
NULLDUMMY_ERROR = "64: non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)" | NULLDUMMY_ERROR = "64: non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)" | ||||
def trueDummy(tx): | def trueDummy(tx): | ||||
scriptSig = CScript(tx.vin[0].scriptSig) | scriptSig = CScript(tx.vin[0].scriptSig) | ||||
newscript = [] | newscript = [] | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]") | "Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]") | ||||
self.block_submit(self.nodes[0], [test2tx], True) | self.block_submit(self.nodes[0], [test2tx], True) | ||||
def create_transaction(self, node, txid, to_address, amount): | def create_transaction(self, node, txid, to_address, amount): | ||||
inputs = [{"txid": txid, "vout": 0}] | inputs = [{"txid": txid, "vout": 0}] | ||||
outputs = {to_address: amount} | outputs = {to_address: amount} | ||||
rawtx = node.createrawtransaction(inputs, outputs) | rawtx = node.createrawtransaction(inputs, outputs) | ||||
signresult = node.signrawtransaction(rawtx) | signresult = node.signrawtransaction(rawtx) | ||||
tx = CTransaction() | return FromHex(CTransaction(), signresult['hex']) | ||||
f = BytesIO(hex_str_to_bytes(signresult['hex'])) | |||||
tx.deserialize(f) | |||||
return tx | |||||
def block_submit(self, node, txs, accept=False): | def block_submit(self, node, txs, accept=False): | ||||
block = create_block(self.tip, create_coinbase( | block = create_block(self.tip, create_coinbase( | ||||
self.lastblockheight + 1), self.lastblocktime + 1) | self.lastblockheight + 1), self.lastblocktime + 1) | ||||
block.nVersion = 4 | block.nVersion = 4 | ||||
for tx in txs: | for tx in txs: | ||||
tx.rehash() | tx.rehash() | ||||
block.vtx.append(tx) | block.vtx.append(tx) | ||||
Show All 18 Lines |