mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
8ca90f3f99
fa89badf887dcc01e5bdece248b5e7d234fee227 test: Require standard txs in regtest (MarcoFalke) fa9b4191609c3ef75e69d391eb91e4d5c1e0bcf5 test: Add test that mainnet requires standard txs (MarcoFalke) fa613ca0a8f99c4771859de9e571878530d3ecb5 chainparams: Remove unused fMineBlocksOnDemand (MarcoFalke) Pull request description: I don't see a reason why regtest should allow non-standard txs, as it makes testing mainnet behaviour such as #15846 unnecessarily hard and unintuitive. Of course, testnet policy remains unchanged to allow propagation of non-standard txs. ACKs for top commit: ajtowns: ACK fa89badf887dcc01e5bdece248b5e7d234fee227 Tree-SHA512: c4c675affb054868850bd2683aa07f4c741a448cbacb2ea8334191e105f426b0790fe6a468be61e9c5880d24154f7bf1c7075051697172dce92180c1bc3a1c90
76 lines
3.0 KiB
Python
Executable File
76 lines
3.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015-2021 The Dash Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, ToHex
|
|
from test_framework.script import CScript, OP_CAT, OP_DROP, OP_TRUE
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import assert_equal, assert_raises_rpc_error, get_bip9_status, satoshi_round
|
|
|
|
'''
|
|
feature_dip0020_activation.py
|
|
|
|
This test checks activation of DIP0020 opcodes
|
|
'''
|
|
|
|
DISABLED_OPCODE_ERROR = "non-mandatory-script-verify-flag (Attempted to use a disabled opcode)"
|
|
|
|
|
|
class DIP0020ActivationTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 1
|
|
self.extra_args = [["-acceptnonstdtxn=1"]]
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
|
|
def run_test(self):
|
|
self.node = self.nodes[0]
|
|
self.relayfee = satoshi_round(self.nodes[0].getnetworkinfo()["relayfee"])
|
|
|
|
# We should have some coins already
|
|
utxos = self.node.listunspent()
|
|
assert len(utxos) > 0
|
|
|
|
# Lock some coins using disabled opcodes
|
|
utxo = utxos[len(utxos) - 1]
|
|
value = int(satoshi_round(utxo["amount"] - self.relayfee) * COIN)
|
|
tx = CTransaction()
|
|
tx.vin.append(CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"])))
|
|
tx.vout.append(CTxOut(value, CScript([b'1', b'2', OP_CAT])))
|
|
tx_signed_hex = self.node.signrawtransactionwithwallet(ToHex(tx))["hex"]
|
|
txid = self.node.sendrawtransaction(tx_signed_hex)
|
|
|
|
# This tx should be completely valid, should be included in mempool and mined in the next block
|
|
assert txid in set(self.node.getrawmempool())
|
|
self.node.generate(1)
|
|
assert txid not in set(self.node.getrawmempool())
|
|
|
|
# Create spending tx
|
|
value = int(value - self.relayfee * COIN)
|
|
tx0 = CTransaction()
|
|
tx0.vin.append(CTxIn(COutPoint(int(txid, 16), 0)))
|
|
tx0.vout.append(CTxOut(value, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE])))
|
|
tx0.rehash()
|
|
tx0_hex = ToHex(tx0)
|
|
|
|
# This tx isn't valid yet
|
|
assert_equal(get_bip9_status(self.nodes[0], 'dip0020')['status'], 'locked_in')
|
|
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, self.node.sendrawtransaction, tx0_hex)
|
|
|
|
# Generate enough blocks to activate DIP0020 opcodes
|
|
self.node.generate(98)
|
|
assert_equal(get_bip9_status(self.nodes[0], 'dip0020')['status'], 'active')
|
|
|
|
# Still need 1 more block for mempool to accept new opcodes
|
|
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, self.node.sendrawtransaction, tx0_hex)
|
|
self.node.generate(1)
|
|
|
|
# Should be spendable now
|
|
tx0id = self.node.sendrawtransaction(tx0_hex)
|
|
assert tx0id in set(self.node.getrawmempool())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
DIP0020ActivationTest().main()
|