diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-01-27 16:31:03 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-03-26 11:33:55 +0000 |
commit | e69acffdc88e0297d649658551f4a331dd3395f1 (patch) | |
tree | bedc4cea64c992b74e15009ca4fa70ab776a176d | |
parent | Merge pull request #6388 (diff) | |
download | monero-e69acffdc88e0297d649658551f4a331dd3395f1.tar.xz |
functional_tests: update cookie at 10 seconds interval
Otherwise the daemon will start rejecting
Diffstat (limited to '')
-rwxr-xr-x | tests/functional_tests/rpc_payment.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/functional_tests/rpc_payment.py b/tests/functional_tests/rpc_payment.py index 4c777ccd7..90c5e1211 100755 --- a/tests/functional_tests/rpc_payment.py +++ b/tests/functional_tests/rpc_payment.py @@ -31,6 +31,7 @@ from __future__ import print_function import subprocess import os +import time """Test daemon RPC payment calls """ @@ -143,6 +144,7 @@ class RPCPaymentTest(): found_valid = 0 found_invalid = 0 last_credits = 0 + loop_time = time.time() while found_valid == 0 or found_invalid == 0: nonce += 1 try: @@ -152,10 +154,17 @@ class RPCPaymentTest(): except Exception as e: found_invalid += 1 res = daemon.rpc_access_info(client = self.get_signature()) + cookie = res.cookie + loop_time = time.time() assert res.credits < last_credits or res.credits == 0 assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails last_credits = res.credits + if time.time() >= loop_time + 10: + res = daemon.rpc_access_info(client = self.get_signature()) + cookie = res.cookie + loop_time = time.time() + # we should now have 1 valid nonce, and a number of bad ones res = daemon.rpc_access_info(client = self.get_signature()) assert len(res.hashing_blob) > 39 @@ -176,6 +185,7 @@ class RPCPaymentTest(): assert e.nonces_dupe == 0 # Try random nonces till we find one that's valid so we get a load of credits + loop_time = time.time() while last_credits == 0: nonce += 1 try: @@ -186,6 +196,10 @@ class RPCPaymentTest(): except: found_invalid += 1 assert nonce < 1000 # can't find a valid none -> the RPC probably fails + if time.time() >= loop_time + 10: + res = daemon.rpc_access_info(client = self.get_signature()) + cookie = res.cookie + loop_time = time.time() # we should now have at least 5000 res = daemon.rpc_access_info(client = self.get_signature()) @@ -208,6 +222,7 @@ class RPCPaymentTest(): res = daemon.rpc_access_info(client = self.get_signature()) cookie = res.cookie old_cookie = cookie # we keep that so can submit a stale later + loop_time = time.time() while True: nonce += 1 try: @@ -218,6 +233,11 @@ class RPCPaymentTest(): found_invalid += 1 assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails + if time.time() >= loop_time + 10: + res = daemon.rpc_access_info(client = self.get_signature()) + cookie = res.cookie + loop_time = time.time() + res = daemon.rpc_access_data() assert len(res.entries) > 0 e = [x for x in res.entries if x['client'] == self.public_key] @@ -247,14 +267,17 @@ class RPCPaymentTest(): # find stales without updating cookie, one within 5 seconds (accepted), one later (rejected) res = daemon.rpc_access_info(client = self.get_signature()) + cookie = res.cookie # let the daemon update its timestamp, but use old cookie found_close_stale = 0 found_late_stale = 0 + loop_time = time.time() while found_close_stale == 0 or found_late_stale == 0: nonce += 1 try: res = daemon.rpc_access_submit_nonce(nonce = nonce, cookie = cookie, client = self.get_signature()) found_close_stale += 1 found_valid += 1 + time.sleep(15) # now we've got an early stale, wait till they become late stales except Exception as e: #if e[0]['error']['code'] == -18: # stale if "'code': -18" in str(e): # stale (ugly version, but also works with python 3) @@ -263,6 +286,11 @@ class RPCPaymentTest(): found_invalid += 1 assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails + if time.time() >= loop_time + 10: + res = daemon.rpc_access_info(client = self.get_signature()) + # cookie = res.cookie # let the daemon update its timestamp, but use old cookie + loop_time = time.time() + res = daemon.rpc_access_data() assert len(res.entries) > 0 e = [x for x in res.entries if x['client'] == self.public_key] |