Skip to content

Commit

Permalink
Merge pull request #418 from marcus290/fix-while-loops
Browse files Browse the repository at this point in the history
RPC tests: Fix while loops of cfund tests causing random test fails
  • Loading branch information
marcus290 authored Feb 24, 2019
2 parents d4c8c5e + 9d61718 commit 66a4852
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ def run_test(self):
assert(self.nodes[0].getpaymentrequest(paymentrequestid0)["status"] == "pending")
assert(self.nodes[0].cfundstats()["funds"]["locked"] == locked_accepted)

blocks=slow_gen(self.nodes[0], 1)

# Wait for the proposal to expire
while int(time.time()) <= int(self.nodes[0].getproposal(proposalid0)["expiresOn"]):
while int(self.nodes[0].getblock(blocks[0])["time"]) <= int(self.nodes[0].getproposal(proposalid0)["expiresOn"]):
blocks=slow_gen(self.nodes[0], 1)
time.sleep(1)

blocks=slow_gen(self.nodes[0], 1)

assert(self.nodes[0].getproposal(proposalid0)["status"] == "expired waiting for end of voting period")

self.nodes[0].invalidateblock(blocks[-1])
Expand Down
7 changes: 4 additions & 3 deletions qa/rpc-tests/cfund-proposal-state-accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ def run_test(self):
self.nodes[0].invalidateblock(blocks[-1])
assert(self.nodes[0].getproposal(proposalid0)["votingCycle"] == votingCycle_after_state_change)

blocks=slow_gen(self.nodes[0], 1)

# Wait for the proposal to expire
while int(time.time()) <= int(self.nodes[0].getproposal(proposalid0)["expiresOn"]):
while int(self.nodes[0].getblock(blocks[0])["time"]) <= int(self.nodes[0].getproposal(proposalid0)["expiresOn"]):
blocks=slow_gen(self.nodes[0], 1)
time.sleep(1)

blocks=slow_gen(self.nodes[0], 1)

assert(self.nodes[0].getproposal(proposalid0)["status"] == "expired waiting for end of voting period")

self.nodes[0].invalidateblock(blocks[-1])
Expand Down

0 comments on commit 66a4852

Please sign in to comment.