Skip to content

Commit d783229

Browse files
committed
[Tests] get correct nStakeModifier
1 parent 78e838e commit d783229

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

test/functional/fake_stake/base_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def create_spam_block(self, hashPrevBlock, stakingPrevOuts, height, fStakeDouble
107107

108108
# create a new private key used for block signing.
109109
# solve for the block here
110-
parent_block_stake_modifier = int(self.node.getblock(hashPrevBlock)['modifier'], 16)
111-
if not block.solve_stake(parent_block_stake_modifier, stakingPrevOuts):
110+
if not block.solve_stake(stakingPrevOuts):
112111
raise Exception("Not able to solve for any prev_outpoint")
113112

114113
self.log.info("Stake found. Signing block...")
@@ -267,8 +266,11 @@ def get_prevouts(self, utxo_list):
267266
'''
268267
stakingPrevOuts = {}
269268
for utxo in utxo_list:
270-
txBlocktime = self.node.getrawtransaction(utxo['txid'], 1)['blocktime']
271-
utxo_to_stakingPrevOuts(utxo, stakingPrevOuts, txBlocktime)
269+
utxo_tx = self.node.getrawtransaction(utxo['txid'], 1)
270+
txBlocktime = utxo_tx['blocktime']
271+
txBlockhash = utxo_tx['blockhash']
272+
stakeModifier = int(self.node.getblock(txBlockhash)['modifier'], 16)
273+
utxo_to_stakingPrevOuts(utxo, stakingPrevOuts, txBlocktime, stakeModifier)
272274

273275
return stakingPrevOuts
274276

test/functional/fake_stake/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def create_transaction(outPoint, sig, value, nTime, scriptPubKey=CScript()):
114114
return tx
115115

116116

117-
def utxo_to_stakingPrevOuts(utxo, stakingPrevOuts, txBlocktime):
117+
def utxo_to_stakingPrevOuts(utxo, stakingPrevOuts, txBlocktime, stakeModifier):
118118
'''
119119
Updates a map of unspent outputs to (amount, blocktime) to be used as stake inputs
120120
:param utxo: (map) utxo JSON object returned from listunspent
@@ -126,7 +126,7 @@ def utxo_to_stakingPrevOuts(utxo, stakingPrevOuts, txBlocktime):
126126
COINBASE_MATURITY = 100
127127
if utxo['confirmations'] > COINBASE_MATURITY:
128128
outPoint = COutPoint(int(utxo['txid'], 16), utxo['vout'])
129-
stakingPrevOuts[outPoint] = (int(utxo['amount'])*COIN, txBlocktime)
129+
stakingPrevOuts[outPoint] = (int(utxo['amount'])*COIN, txBlocktime, stakeModifier)
130130

131131
return
132132

test/functional/test_framework/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,12 @@ def get_uniqueness(self, prevout):
468468
r += ser_uint256(prevout.hash)
469469
return r
470470

471-
def solve_stake(self, stakeModifier, prevouts):
471+
def solve_stake(self, prevouts):
472472
target0 = uint256_from_compact(self.nBits)
473473
loop = True
474474
while loop:
475475
for prevout in prevouts:
476-
nvalue, txBlockTime = prevouts[prevout]
476+
nvalue, txBlockTime, stakeModifier = prevouts[prevout]
477477
target = int(target0 * nvalue / 100) % 2**256
478478
data = b""
479479
data += ser_uint64(stakeModifier)

0 commit comments

Comments
 (0)