From 86e9af6fd7be940717341b5960140246f419c563 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 14 Aug 2023 21:57:38 +0200 Subject: [PATCH] Sync test: submit more fake shares --- tests/src/stratum_dummy.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/src/stratum_dummy.py b/tests/src/stratum_dummy.py index 84c694b..c5474f1 100644 --- a/tests/src/stratum_dummy.py +++ b/tests/src/stratum_dummy.py @@ -56,7 +56,7 @@ while True: if ('method' in obj) and ('params' in obj) and (obj['method'] == 'job'): job_id = obj['params']['job_id'] target = obj['params']['target'] - elif ('result' in obj): + elif ('result' in obj) and ('job' in obj['result']): if ('id' in obj['result']): rpc_id = obj['result']['id'] job_id = obj['result']['job']['job_id'] @@ -66,8 +66,19 @@ while True: if (msg_id < 4): result = ('f' if (msg_id == 2) else '0') * 64 request = '{"id":' + str(msg_id) + ',"method":"submit","params":{"id":"' + rpc_id + '","job_id":"' + job_id + '","nonce":"ffffffff","result":"' + result + '"}}\n' - else: + elif (msg_id == 4): request = '{"id":' + str(msg_id) + ',"method":"keepalived"}\n' + else: + t = bytearray.fromhex(target) + for i in range(len(t)): + if (t[i] > 0): + t[i] -= 1 + break + else: + t[i] = 255 + + result = ('0' * (64 - len(target))) + t.hex() + request = '{"id":' + str(msg_id) + ',"method":"submit","params":{"id":"' + rpc_id + '","job_id":"' + job_id + '","nonce":"ffffffff","result":"' + result + '"}}\n' msg_id += 1 s = '-> ' + request