From 2f65a75f7e2618ae1cb49a4106d584a2064d0691 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 10 Mar 2025 14:28:50 +0000 Subject: [PATCH] swap: Midgard -> Thornode --- mmgen/swap/proto/thorchain/__init__.py | 4 ++-- .../swap/proto/thorchain/{midgard.py => thornode.py} | 8 ++++---- test/cmdtest_d/ct_swap.py | 8 ++++---- test/cmdtest_d/{midgard.py => thornode.py} | 8 ++++---- .../fakemods/mmgen/swap/proto/thorchain/midgard.py | 11 ----------- .../fakemods/mmgen/swap/proto/thorchain/thornode.py | 11 +++++++++++ 6 files changed, 25 insertions(+), 25 deletions(-) rename mmgen/swap/proto/thorchain/{midgard.py => thornode.py} (96%) rename test/cmdtest_d/{midgard.py => thornode.py} (92%) delete mode 100755 test/overlay/fakemods/mmgen/swap/proto/thorchain/midgard.py create mode 100755 test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py diff --git a/mmgen/swap/proto/thorchain/__init__.py b/mmgen/swap/proto/thorchain/__init__.py index e2131e84..9c98712b 100755 --- a/mmgen/swap/proto/thorchain/__init__.py +++ b/mmgen/swap/proto/thorchain/__init__.py @@ -37,7 +37,7 @@ class ExpInt4(ExpInt): return ExpInt.__new__(cls, spec, prec=params.exp_prec) def rpc_client(tx, amt): - from .midgard import Midgard - return Midgard(tx, amt) + from .thornode import Thornode + return Thornode(tx, amt) from .memo import Memo as data diff --git a/mmgen/swap/proto/thorchain/midgard.py b/mmgen/swap/proto/thorchain/thornode.py similarity index 96% rename from mmgen/swap/proto/thorchain/midgard.py rename to mmgen/swap/proto/thorchain/thornode.py index c091fd96..9f51bcd2 100755 --- a/mmgen/swap/proto/thorchain/midgard.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -9,12 +9,12 @@ # https://gitlab.com/mmgen/mmgen-wallet """ -swap.proto.thorchain.midgard: THORChain swap protocol network query ops +swap.proto.thorchain.thornode: THORChain swap protocol network query ops """ import json -class MidgardRPCClient: +class ThornodeRPCClient: http_hdrs = {'Content-Type': 'application/json'} proto = 'https' @@ -44,12 +44,12 @@ class MidgardRPCClient: timeout = timeout or self.timeout, verify = self.verify) -class Midgard: +class Thornode: def __init__(self, tx, amt): self.tx = tx self.in_amt = amt - self.rpc = MidgardRPCClient(tx) + self.rpc = ThornodeRPCClient(tx) def get_quote(self): self.get_str = '/thorchain/quote/swap?from_asset={a}.{a}&to_asset={b}.{b}&amount={c}'.format( diff --git a/test/cmdtest_d/ct_swap.py b/test/cmdtest_d/ct_swap.py index 09d6dbbd..a37abee5 100755 --- a/test/cmdtest_d/ct_swap.py +++ b/test/cmdtest_d/ct_swap.py @@ -17,7 +17,7 @@ from pathlib import Path from mmgen.protocol import init_proto from ..include.common import make_burn_addr, gr_uc from .common import dfl_bip39_file -from .midgard import run_midgard_server +from .thornode import run_thornode_server from .ct_autosign import CmdTestAutosign, CmdTestAutosignThreaded from .ct_regtest import CmdTestRegtest, rt_data, dfl_wcls, rt_pw, cfg, strip_ansi_escapes @@ -25,9 +25,9 @@ from .ct_regtest import CmdTestRegtest, rt_data, dfl_wcls, rt_pw, cfg, strip_ans sample1 = gr_uc[:24] sample2 = '00010203040506' -def midgard_server_start(): +def thornode_server_start(): import threading - t = threading.Thread(target=run_midgard_server, name='Midgard server thread') + t = threading.Thread(target=run_thornode_server, name='Thornode server thread') t.daemon = True t.start() @@ -175,7 +175,7 @@ class CmdTestSwap(CmdTestRegtest, CmdTestAutosignThreaded): self.protos = [init_proto(cfg, k, network='regtest', need_amt=True) for k in ('btc', 'ltc', 'bch')] - midgard_server_start() # TODO: stop server when test group finishes executing + thornode_server_start() # TODO: stop server when test group finishes executing self.opts.append('--bob') diff --git a/test/cmdtest_d/midgard.py b/test/cmdtest_d/thornode.py similarity index 92% rename from test/cmdtest_d/midgard.py rename to test/cmdtest_d/thornode.py index 39701c27..49c70aba 100755 --- a/test/cmdtest_d/midgard.py +++ b/test/cmdtest_d/thornode.py @@ -78,12 +78,12 @@ class handler(BaseHTTPRequestHandler): header = b'HTTP/1.1 200 OK\nContent-type: application/json\n\n' def do_GET(self): - # print(f'Midgard server received:\n {self.requestline}') + # print(f'Thornode server received:\n {self.requestline}') self.wfile.write(self.header + json.dumps(create_data(self.requestline)).encode()) -def run_midgard_server(server_class=HTTPServer, handler_class=handler): - print('Midgard server listening on port 18800') +def run_thornode_server(server_class=HTTPServer, handler_class=handler): + print('Thornode server listening on port 18800') server_address = ('localhost', 18800) httpd = server_class(server_address, handler_class) httpd.serve_forever() - print('Midgard server exiting') + print('Thornode server exiting') diff --git a/test/overlay/fakemods/mmgen/swap/proto/thorchain/midgard.py b/test/overlay/fakemods/mmgen/swap/proto/thorchain/midgard.py deleted file mode 100755 index 995c608e..00000000 --- a/test/overlay/fakemods/mmgen/swap/proto/thorchain/midgard.py +++ /dev/null @@ -1,11 +0,0 @@ -from .midgard_orig import * - -class overlay_fake_MidgardRPCClient: - - proto = 'http' - host = 'localhost:18800' - verify = False - -MidgardRPCClient.proto = overlay_fake_MidgardRPCClient.proto -MidgardRPCClient.host = overlay_fake_MidgardRPCClient.host -MidgardRPCClient.verify = overlay_fake_MidgardRPCClient.verify diff --git a/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py b/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py new file mode 100755 index 00000000..c569a534 --- /dev/null +++ b/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py @@ -0,0 +1,11 @@ +from .thornode_orig import * + +class overlay_fake_ThornodeRPCClient: + + proto = 'http' + host = 'localhost:18800' + verify = False + +ThornodeRPCClient.proto = overlay_fake_ThornodeRPCClient.proto +ThornodeRPCClient.host = overlay_fake_ThornodeRPCClient.host +ThornodeRPCClient.verify = overlay_fake_ThornodeRPCClient.verify