commit 272bf43ba5692a3b9cb7b761d2f5b7ce489a1d4d
parent 2ad84fc5aadfd4ce2290343d03f39b5d5f0af4e3
Author: lash <dev@holbrook.no>
Date: Thu, 12 May 2022 06:26:34 +0000
Add rpc timeout proxy args
Diffstat:
5 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py
@@ -11,6 +11,7 @@ import sys
from aiee.arg import (
ArgFlag as BaseArgFlag,
Arg as BaseArg,
+ process_args,
)
logg = logging.getLogger(__name__)
@@ -98,6 +99,8 @@ class Arg(BaseArg):
self.add('p', 'provider', help='RPC HTTP(S) provider url')
self.set_long('p', 'provider')
self.add_long('rpc-dialect', 'provider', help='RPC HTTP(S) backend dialect')
+ self.add_long('rpc-timeout', 'provider', help='RPC autentication credential values')
+ self.add_long('rpc-proxy', 'provider', help='RPC autentication credential values')
self.add_long('height', 'no_target', default='latest', help='Block height to execute against')
diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py
@@ -115,8 +115,8 @@ def process_config(config, arg, args, flags):
config.add(True, '_WAIT')
elif args.w:
config.add(True, '_WAIT')
-
- if arg.match('seq', flags):
+
+ if arg.match('seq', flags):
config.add(getattr(args, 'seq'), '_SEQ')
if arg.match('wallet', flags):
diff --git a/chainlib/cli/rpc.py b/chainlib/cli/rpc.py
@@ -61,7 +61,7 @@ class Rpc:
self.id_generator = IntSequenceGenerator()
self.chain_spec = config.get('CHAIN_SPEC')
- self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth, verify_identity=config.true('RPC_VERIFY'))
+ self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth, verify_identity=config.true('RPC_VERIFY'), timeout=float(config.get('RPC_TIMEOUT')))
return self.conn
diff --git a/chainlib/data/config/config.ini b/chainlib/data/config/config.ini
@@ -5,6 +5,8 @@ credentials =
dialect = default
scheme = http
verify = 1
+timeout = 10.0
+proxy =
[chain]
spec =
diff --git a/tests/test_cli.py b/tests/test_cli.py
@@ -122,34 +122,6 @@ class TestCli(unittest.TestCase):
config = Config()
config = process_config(config, self.arg, args, flags)
- print(config)
-
-
-# def test_args_process_extra(self):
-# ap = ArgumentParser()
-# flags = self.flags.VERBOSE | self.flags.CONFIG
-# process_args(ap, self.arg, flags)
-# ap.add_argument('--foo', type=str)
-# argv = [
-# '--foo',
-# 'bar',
-# ]
-# args = ap.parse_args(argv)
-# extra_args = {
-# 'foo': None,
-# }
-#
-# config = Config()
-# config = process_config(config, self.arg, args, flags)
-# self.assertEqual(config.get('_FOO'), 'bar')
-#
-# extra_args = {
-# 'foo': 'FOOFOO',
-# }
-#
-# config = Config()
-# config = process_config(config, self.arg, args, flags)
-# self.assertEqual(config.get('FOOFOO'), 'bar')
if __name__ == '__main__':