Skip to content

Commit 8c4b490

Browse files
mxaddictalex v
authored andcommitted
Make some tests more reliable (#537)
* Make coldstaking test more reliable * Updated qa/rpc-tests/cfund-proposal-state-accept.py test to be more reliable
1 parent 42769b2 commit 8c4b490

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

qa/rpc-tests/cfund-proposal-state-accept.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ def run_test(self):
156156

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

159+
# Load the expires_on value before the loop
160+
expires_on = int(self.nodes[0].getproposal(proposalid0)["expiresOn"])
161+
159162
# Wait for the proposal to expire
160-
while int(self.nodes[0].getblock(blocks[0])["time"]) <= int(self.nodes[0].getproposal(proposalid0)["expiresOn"]):
161-
blocks=slow_gen(self.nodes[0], 1)
162-
time.sleep(1)
163+
while int(self.nodes[0].getblock(blocks[0])["time"]) <= expires_on:
164+
blocks=slow_gen(self.nodes[0], 1, 0.5)
163165

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

qa/rpc-tests/coldstaking_spending.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ColdStakingSpending(NavCoinTestFramework):
1313
def __init__(self):
1414
super().__init__()
1515
self.setup_clean_chain = True
16-
self.num_nodes = 2
16+
self.num_nodes = 1
1717
# set up nodes
1818
def setup_network(self, split=False):
1919
self.nodes = self.setup_nodes()
@@ -52,7 +52,8 @@ def run_test(self):
5252

5353
# send funds to the cold staking address (leave some nav for fees) -- we specifically require
5454
# a transaction fee of minimum 0.002884 navcoin due to the complexity of this transaction
55-
self.nodes[0].sendtoaddress(coldstaking_address_spending, float(self.nodes[0].getbalance()) - MIN_COLDSTAKING_SENDING_FEE)
55+
tx = self.nodes[0].sendtoaddress(coldstaking_address_spending, float(self.nodes[0].getbalance()) - MIN_COLDSTAKING_SENDING_FEE)
56+
fee = self.nodes[0].gettransaction(tx)['fee']
5657
# put transaction in new block & update blockchain
5758
slow_gen(self.nodes[0], 1)
5859
# create list for all coldstaking utxo recieved
@@ -72,7 +73,7 @@ def run_test(self):
7273
# difference between balance after sending and previous balance is the same when block reward is removed
7374
# values are converted to string and "00" is added to right of == operand because values must have equal num of
7475
# decimals
75-
assert(str(balance_post_send_one - BLOCK_REWARD) <= (str(float(balance_before_send) - MIN_COLDSTAKING_SENDING_FEE) + "00"))
76+
assert_equal(balance_post_send_one - BLOCK_REWARD, balance_before_send + fee) # FEE IS negative already so we ADD it
7677

7778
"""check staking weight now == 0 (we don't hold the staking key)"""
7879

0 commit comments

Comments
 (0)