Skip to content

Commit 5b192e0

Browse files
committed
[Tests][Bug] Fix staking status in generate_pos()
"validtime" is not returned from getstakingstatus anymore (nor it was needed).
1 parent d870d5c commit 5b192e0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,20 +1013,25 @@ def generate_pos(self, node_id, btime=None):
10131013
""" stakes a block using generate on nodes[node_id]"""
10141014
assert_greater_than(len(self.nodes), node_id)
10151015
rpc_conn = self.nodes[node_id]
1016+
ss = rpc_conn.getstakingstatus()
1017+
assert ss["walletunlocked"]
1018+
assert ss["mintablecoins"]
10161019
if btime is not None:
10171020
next_btime = btime + 60
10181021
fStaked = False
1022+
failures = 0
10191023
while not fStaked:
10201024
try:
10211025
rpc_conn.generate(1)
10221026
fStaked = True
10231027
except JSONRPCException as e:
10241028
if ("Couldn't create new block" in str(e)):
1025-
# couldn't generate block. check that this node can stake
1026-
ss = rpc_conn.getstakingstatus()
1027-
if not (ss["validtime"] and ss["haveconnections"] and ss["walletunlocked"] and
1028-
ss["mintablecoins"] and ss["enoughcoins"]):
1029-
raise AssertionError("Node %d unable to stake!" % node_id)
1029+
failures += 1
1030+
# couldn't generate block. check that this node can still stake (after 60 failures)
1031+
if failures > 60:
1032+
ss = rpc_conn.getstakingstatus()
1033+
if not (ss["walletunlocked"] and ss["mintablecoins"]):
1034+
raise AssertionError("Node %d unable to stake!" % node_id)
10301035
# try to stake one sec in the future
10311036
if btime is not None:
10321037
btime += 1

0 commit comments

Comments
 (0)