Skip to content

Commit

Permalink
Fix nulldummy tests by creating correct DIP4 coinbase transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Sep 3, 2018
1 parent d3ac862 commit c7f75af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion qa/rpc-tests/nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def tx_submit(self, node, tx, msg = ""):


def block_submit(self, node, txs, accept = False):
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1)
dip4_activated = self.lastblockheight + 1 >= 432
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1, dip4_activated=dip4_activated), self.lastblocktime + 1)
block.nVersion = 4
for tx in txs:
tx.rehash()
Expand Down
7 changes: 6 additions & 1 deletion qa/rpc-tests/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def serialize_script_num(value):
# Create a coinbase transaction, assuming no miner fees.
# If pubkey is passed in, the coinbase output will be a P2PK output;
# otherwise an anyone-can-spend output.
def create_coinbase(height, pubkey = None):
def create_coinbase(height, pubkey = None, dip4_activated=False):
coinbase = CTransaction()
coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff),
ser_string(serialize_script_num(height)), 0xffffffff))
Expand All @@ -53,6 +53,11 @@ def create_coinbase(height, pubkey = None):
else:
coinbaseoutput.scriptPubKey = CScript([OP_TRUE])
coinbase.vout = [ coinbaseoutput ]
if dip4_activated:
coinbase.nVersion = 3
coinbase.nType = 5
cbtx_payload = CCbTx(1, height, 0)
coinbase.vExtraPayload = cbtx_payload.serialize()
coinbase.calc_sha256()
return coinbase

Expand Down

0 comments on commit c7f75af

Please sign in to comment.