diff --git a/mmgen/proto/rune/params.py b/mmgen/proto/rune/params.py index 0532bc55..dadb21b3 100755 --- a/mmgen/proto/rune/params.py +++ b/mmgen/proto/rune/params.py @@ -49,6 +49,7 @@ class mainnet(CoinProtocol.Secp256k1): rpc_remote_params = {'server_domain': Hostname('ninerealms.com')} rpc_remote_rest_params = {'host': Hostname('thornode.ninerealms.com')} rpc_remote_rpc_params = {'host': Hostname('rpc.ninerealms.com')} + rpc_swap_params = {'host': Hostname('thornode.ninerealms.com')} def decode_addr(self, addr): hrp, data = bech32.bech32_decode(addr) @@ -69,6 +70,7 @@ class testnet(mainnet): # testnet is stagenet bech32_hrp = 'sthor' rpc_remote_rest_params = {'host': Hostname('stagenet-thornode.ninerealms.com')} rpc_remote_rpc_params = {'host': Hostname('stagenet-rpc.ninerealms.com')} + rpc_swap_params = {'host': Hostname('stagenet-thornode.ninerealms.com')} class regtest(testnet): # regtest is deprecated testnet bech32_hrp = 'tthor' @@ -79,3 +81,4 @@ class regtest(testnet): # regtest is deprecated testnet 'host': Hostname('localhost:18800'), 'verify': False} rpc_remote_rpc_params = rpc_remote_rest_params + rpc_swap_params = rpc_remote_rest_params | {'host': Hostname('localhost:18900')} diff --git a/mmgen/swap/proto/thorchain/thornode.py b/mmgen/swap/proto/thorchain/thornode.py index bd2ede9b..6c9a3b53 100755 --- a/mmgen/swap/proto/thorchain/thornode.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -15,6 +15,7 @@ swap.proto.thorchain.thornode: THORChain swap protocol network query ops import time, json from collections import namedtuple +from ....protocol import init_proto from ....amt import UniAmt from ....http import HTTPClient @@ -24,13 +25,15 @@ gas_unit_data = { 'gwei': _gd('G', 'Gwei'), } -class ThornodeRPCClient(HTTPClient): +class ThornodeSwapClient(HTTPClient): http_hdrs = {'Content-Type': 'application/json'} - host = 'thornode.ninerealms.com' timeout = 5 def __init__(self, tx, *, network_proto=None, host=None): + rune_proto = init_proto(tx.cfg, 'rune', network=tx.cfg._proto.network) + for k, v in rune_proto.rpc_swap_params.items(): + setattr(self, k, v) super().__init__(tx.cfg, network_proto=network_proto, host=host) class Thornode: @@ -38,7 +41,7 @@ class Thornode: def __init__(self, tx, amt): self.tx = tx self.in_amt = UniAmt(f'{amt:.8f}') - self.rpc = ThornodeRPCClient(tx) + self.rpc = ThornodeSwapClient(tx) def get_quote(self, swap_cfg): diff --git a/test/cmdtest_d/httpd/__init__.py b/test/cmdtest_d/httpd/__init__.py index 32743ee4..9240d8fd 100755 --- a/test/cmdtest_d/httpd/__init__.py +++ b/test/cmdtest_d/httpd/__init__.py @@ -37,7 +37,7 @@ class HTTPD: handler_class = SilentRequestHandler) import threading - t = threading.Thread(target=self.httpd.serve_forever, name=f'{self.name} thread') + t = threading.Thread(target=self.httpd.serve_forever, name=f'{type(self).__name__} thread') t.daemon = True t.start() diff --git a/test/cmdtest_d/httpd/thornode/__init__.py b/test/cmdtest_d/httpd/thornode/__init__.py index 47bc6df5..9c107c89 100755 --- a/test/cmdtest_d/httpd/thornode/__init__.py +++ b/test/cmdtest_d/httpd/thornode/__init__.py @@ -16,5 +16,4 @@ from .. import HTTPD class ThornodeServer(HTTPD): name = 'thornode server' - port = 18800 content_type = 'application/json' diff --git a/test/cmdtest_d/httpd/thornode/rpc.py b/test/cmdtest_d/httpd/thornode/rpc.py index 7e1515bc..6bdebee3 100755 --- a/test/cmdtest_d/httpd/thornode/rpc.py +++ b/test/cmdtest_d/httpd/thornode/rpc.py @@ -18,6 +18,7 @@ from wsgiref.util import request_uri from . import ThornodeServer class ThornodeRPCServer(ThornodeServer): + port = 18800 name = 'thornode RPC server' def make_response_body(self, method, environ): diff --git a/test/cmdtest_d/httpd/thornode/swap.py b/test/cmdtest_d/httpd/thornode/swap.py index 97904655..10ae19b6 100755 --- a/test/cmdtest_d/httpd/thornode/swap.py +++ b/test/cmdtest_d/httpd/thornode/swap.py @@ -130,6 +130,7 @@ def make_inbound_addr(proto, mmtype): mmtype = mmtype).pubhash2addr(f'{n:040x}') class ThornodeSwapServer(ThornodeServer): + port = 18900 name = 'thornode swap server' request_pat = r'/thorchain/quote/swap\?from_asset=(\S+)\.(\S+)&to_asset=(\S+)\.(\S+)&amount=(\d+)' diff --git a/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py b/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py deleted file mode 100755 index d069d0cb..00000000 --- a/test/overlay/fakemods/mmgen/swap/proto/thorchain/thornode.py +++ /dev/null @@ -1,11 +0,0 @@ -from .thornode_orig import * - -class overlay_fake_ThornodeRPCClient: - - network_proto = 'http' - host = 'localhost:18800' - verify = False - -ThornodeRPCClient.network_proto = overlay_fake_ThornodeRPCClient.network_proto -ThornodeRPCClient.host = overlay_fake_ThornodeRPCClient.host -ThornodeRPCClient.verify = overlay_fake_ThornodeRPCClient.verify