mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#23501: various feature_nulldummy.py improvements
This commit is contained in:
parent
851dae7b29
commit
f6fa0c06b8
@ -20,7 +20,10 @@ from test_framework.blocktools import (
|
|||||||
create_transaction,
|
create_transaction,
|
||||||
)
|
)
|
||||||
from test_framework.messages import CTransaction
|
from test_framework.messages import CTransaction
|
||||||
from test_framework.script import CScript
|
from test_framework.script import (
|
||||||
|
OP_0,
|
||||||
|
OP_TRUE,
|
||||||
|
)
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
@ -29,16 +32,12 @@ from test_framework.util import (
|
|||||||
|
|
||||||
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
|
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
|
||||||
|
|
||||||
def trueDummy(tx):
|
|
||||||
scriptSig = CScript(tx.vin[0].scriptSig)
|
def invalidate_nulldummy_tx(tx):
|
||||||
newscript = []
|
"""Transform a NULLDUMMY compliant tx (i.e. scriptSig starts with OP_0)
|
||||||
for i in scriptSig:
|
to be non-NULLDUMMY compliant by replacing the dummy with OP_TRUE"""
|
||||||
if len(newscript) == 0:
|
assert_equal(tx.vin[0].scriptSig[0], OP_0)
|
||||||
assert len(i) == 0
|
tx.vin[0].scriptSig = bytes([OP_TRUE]) + tx.vin[0].scriptSig[1:]
|
||||||
newscript.append(b'\x51')
|
|
||||||
else:
|
|
||||||
newscript.append(i)
|
|
||||||
tx.vin[0].scriptSig = CScript(newscript)
|
|
||||||
tx.rehash()
|
tx.rehash()
|
||||||
|
|
||||||
class NULLDUMMYTest(BitcoinTestFramework):
|
class NULLDUMMYTest(BitcoinTestFramework):
|
||||||
@ -86,7 +85,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
|
self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
|
||||||
test2tx = create_transaction(self.nodes[0], txid2, self.ms_address, amount=47)
|
test2tx = create_transaction(self.nodes[0], txid2, self.ms_address, amount=47)
|
||||||
trueDummy(test2tx)
|
invalidate_nulldummy_tx(test2tx)
|
||||||
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test2tx.serialize().hex(), 0)
|
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test2tx.serialize().hex(), 0)
|
||||||
|
|
||||||
self.log.info(f"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{COINBASE_MATURITY + 4}]")
|
self.log.info(f"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{COINBASE_MATURITY + 4}]")
|
||||||
@ -95,7 +94,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
|||||||
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
|
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
|
||||||
test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, amount=46)
|
test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, amount=46)
|
||||||
test6txs=[CTransaction(test4tx)]
|
test6txs=[CTransaction(test4tx)]
|
||||||
trueDummy(test4tx)
|
invalidate_nulldummy_tx(test4tx)
|
||||||
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test4tx.serialize().hex(), 0)
|
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test4tx.serialize().hex(), 0)
|
||||||
self.block_submit(self.nodes[0], [test4tx], accept=False)
|
self.block_submit(self.nodes[0], [test4tx], accept=False)
|
||||||
|
|
||||||
@ -110,12 +109,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
|||||||
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||||
assert_equal(tmpl['previousblockhash'], self.lastblockhash)
|
assert_equal(tmpl['previousblockhash'], self.lastblockhash)
|
||||||
assert_equal(tmpl['height'], self.lastblockheight + 1)
|
assert_equal(tmpl['height'], self.lastblockheight + 1)
|
||||||
block = create_block(tmpl=tmpl, ntime=self.lastblocktime + 1, dip4_activated=dip4_activated)
|
block = create_block(tmpl=tmpl, ntime=self.lastblocktime + 1, txlist=txs, dip4_activated=dip4_activated)
|
||||||
for tx in txs:
|
|
||||||
tx.rehash()
|
|
||||||
block.vtx.append(tx)
|
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
|
||||||
block.rehash()
|
|
||||||
block.solve()
|
block.solve()
|
||||||
assert_equal(None if accept else NULLDUMMY_ERROR, node.submitblock(block.serialize().hex()))
|
assert_equal(None if accept else NULLDUMMY_ERROR, node.submitblock(block.serialize().hex()))
|
||||||
if accept:
|
if accept:
|
||||||
|
Loading…
Reference in New Issue
Block a user