From d70367bcf8ec0489618e21f9a98efe7524bbc0d2 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 26 Mar 2019 11:35:47 -0400 Subject: [PATCH] Add broken python serialization to always give issuance input, test for decode failure --- test/functional/feature_txwitness.py | 31 ++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/functional/feature_txwitness.py b/test/functional/feature_txwitness.py index d40e5a80dc..450bdd6850 100755 --- a/test/functional/feature_txwitness.py +++ b/test/functional/feature_txwitness.py @@ -14,14 +14,15 @@ """ -from test_framework.messages import CTransaction, CBlock, ser_uint256, FromHex, CBlockHeader, uint256_from_str, CTxOut, ToHex +from test_framework.messages import CTransaction, CBlock, ser_uint256, FromHex, uint256_from_str, CTxOut, ToHex, CTxIn, COutPoint, OUTPOINT_ISSUANCE_FLAG, ser_string from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes, assert_raises_rpc_error, assert_greater_than from test_framework import util -from test_framework.blocktools import create_coinbase, create_block, get_witness_script +from test_framework.blocktools import get_witness_script from io import BytesIO import copy +import struct class TxWitnessTest(BitcoinTestFramework): def set_test_params(self): @@ -182,13 +183,35 @@ class TxWitnessTest(BitcoinTestFramework): assert_raises_rpc_error(-25, "bad-cb-amount", self.nodes[0].testproposedblock, WitToHex(block_witness_stuffed)) assert_greater_than(len(WitToHex(block_witness_stuffed)), 100000*4) # Make sure the witness data is actually serialized + # A CTxIn that always serializes the asset issuance, even for coinbases. + class AlwaysIssuanceCTxIn(CTxIn): + def serialize(self): + r = b'' + outpoint = COutPoint() + outpoint.hash = self.prevout.hash + outpoint.n = self.prevout.n + outpoint.n |= OUTPOINT_ISSUANCE_FLAG + r += outpoint.serialize() + r += ser_string(self.scriptSig) + r += struct.pack("