diff --git a/README.md b/README.md index a8ceee6..7849473 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The package is published in PyPI at the following link: |Package |Description | |----------------------------------------------|---------------------------------------------------------------------| -|[snet-sdk](https://pypi.org/project/snet.sdk/)|Integrate SingularityNET services seamlessly into Python applications| +|[snet.sdk](https://pypi.org/project/snet.sdk/)|Integrate SingularityNET services seamlessly into Python applications| ## Getting Started @@ -23,53 +23,72 @@ The SingularityNET SDK abstracts and manages state channels with service provide ### Usage -To call a SingularityNET service, the user must be able to deposit funds (AGI tokens) to the [Multi-Party Escrow](https://dev.singularitynet.io/docs/concepts/multi-party-escrow/) Smart Contract. +To call a SingularityNET service, the user must be able to deposit funds (AGIX tokens) to the [Multi-Party Escrow](https://dev.singularitynet.io/docs/concepts/multi-party-escrow/) Smart Contract. To deposit these tokens or do any other transaction on the Ethereum blockchain, the user must possess an Ethereum identity with available Ether. -Once you have installed the snet-sdk in your current environment and it's in your PYTHONPATH, you should import it and create an instance of the base sdk class: - +Once you have installed snet-sdk in your current environment, you can import it into your Python script and create an instance of the base sdk class: ```python from snet import sdk -from config import config +config = { + "private_key": 'YOUR_PRIVATE_WALLET_KEY', + "eth_rpc_endpoint": f"https://sepolia.infura.io/v3/YOUR_INFURA_KEY", + "email": "your@email.com", + "free_call_auth_token-bin":"f5533eb0f01f0d45239c11b411bdfd4221fd3b125e4250db1f7bc044466108bc10ce95ab62ae224b6578b68d0ce337b4ec36e4b9dfbe6653e04973107813cbc01c", + "free-call-token-expiry-block":19690819, + "concurrency": False, + "org_id": "organization_id", + "service_id": "id_of_the_service", + "group_name": "default_group", + "identity_name": "local_name_for_that_identity", + "identity_type": "key", + "network": "sepolia", + "force_update": False + } + snet_sdk = sdk.SnetSDK(config) ``` -The `config` parameter must be a Python dictionary. -See [test_sdk_client.py.sample](https://github.com/singnet/snet-cli/blob/master/packages/sdk/testcases/functional_tests/test_sdk_client.py) for a sample configuration file. +The `config` parameter is a Python dictionary. +See [test_sdk_client.py](https://github.com/singnet/snet-sdk-python/blob/master/testcases/functional_tests/test_sdk_client.py) for a reference. +#### Config options description + +private_key: Your wallet's private key that will be used to pay for calls. Is **required** to make a call; +eth_rpc_endpoint: RPC endpoint that is used to access the Ethereum network. Is **required** to make a call; +email: Your email; +"free_call_auth_token-bin" and "free-call-token-expiry-block": Are used to make free calls. See more on that below; +org_id: ID of the organization that owns the service you want to call. Is **required** to make a call; +service_id: ID of the service you want to call. Is **required** to make a call; +identity_name: Name that will be used locally to save your wallet settings. You can check your identities in the `~/.snet/config` file; +identity_type: Type of your wallet authentication. Note that snet-sdk currently supports only "key" identity_type; +network: You can set the Ethereum network that will be used to make a call; +force_update: If set to False, will reuse the existing gRPC stubs (if any) instead of downloading proto and regenerating them every time. -After executing this code, you should have client libraries created for this service. They are located in the following path: ~/.snet/org_id/service_id/python/ -Note: Currently you can only save files to ~/.snet/ +After executing this code, you should have client libraries created for this service. They are located at the following path: `~/.snet/org_id/service_id/python/` + +Note: Currently you can only save files to `~/.snet/`. We will fix this in the future. ##### Free call configuration -If you want to use free call you need to add below mwntioned attributes in config file. +If you want to use a free call you need to add these attributes to the config dictionary: ``` "free_call_auth_token-bin":"f2548d27ffd319b9c05918eeac15ebab934e5cfcd68e1ec3db2b92765", "free-call-token-expiry-block":172800, "email":"test@test.com" ``` -You can download this config for a given service from [Dapp]([https://beta.singularitynet.io/) - -Now, the instance of the sdk can be used to create service client instances. -Continuing from the previous code this is an example using `Exampleservicee` from the `26072b8b6a0e448180f8c0e702ab6d2f` organization: +You can receive these for a given service from the [Dapp](https://beta.singularitynet.io/) +#### Calling the service +Now, the instance of the sdk can be used to create the service client instances. +Continuing from the previous code this is an example using `Exampleservice` from the `26072b8b6a0e448180f8c0e702ab6d2f` organization: ```python -import example_service_pb2_grpc - -org_id = "26072b8b6a0e448180f8c0e702ab6d2f" -service_id = "Exampleservice" -group_name="default_group" - -service_client = snet_sdk.create_service_client(org_id, service_id, group_name) +service_client = snet_sdk.create_service_client() +service_client.deposit_and_open_channel(123456, 33333) ``` - -Note that `org_id` and `service_id` must be passed to `config`. - -The generated service_client instance can be used to call methods provided by the service. -To call these methods, you need to use the call_rpc method, passing into it the names of the method and data object, as well as the data itself (What specific data needs to be passed can be seen in the .proto file). -Continuing from the previous code, this is an example using example-service from the snet organization: - +`deposit_and_open_channel()` function deposits the specified amount of AGIX tokens in cogs into an MPE smart contract and opens a payment channel. +The instance of service_client that has been generated can be utilized to invoke the methods that the service offers. +To do this, use the the call_rpc method. This method needs the names of the method and data object, along with the data itself, to be passed into it. +The specific data that needs to be passed can be found in the .proto file. Building upon the previously written code, here’s an example that uses the *Exampleservice* from the *26072b8b6a0e448180f8c0e702ab6d2f* organization: ```python result = service_client.call_rpc("mul", "Numbers", a=20, b=3) print(f"Performing 20 * 3: {result}") # Performing 20 * 3: value: 60.0 @@ -112,4 +131,4 @@ $ pip install -e . ## License This project is licensed under the MIT License - see the -[LICENSE](https://github.com/singnet/snet-sdk-python/blob/master/LICENSE) file for details. +[LICENSE](https://github.com/singnet/snet-sdk-python/blob/master/LICENSE) file for details. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 98984b5..bd6e3b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,5 +17,5 @@ argcomplete==3.1.2 grpcio-health-checking==1.59.0 jsonschema==4.0.0 eth-account==0.9.0 -snet-cli==2.1.2 +snet-cli==2.1.3 snet.contracts==0.1.1 \ No newline at end of file diff --git a/snet/sdk/__init__.py b/snet/sdk/__init__.py index aaeb555..543bce5 100644 --- a/snet/sdk/__init__.py +++ b/snet/sdk/__init__.py @@ -81,12 +81,48 @@ def __init__(self, config, metadata_provider=None): self.registry_contract = get_contract_object(self.web3, "Registry", _registry_contract_address) self.account = Account(self.web3, config, self.mpe_contract) - - sdk = SDKCommand(Config(), args=Arguments(config['org_id'], config['service_id'])) - sdk.generate_client_library() - def create_service_client(self, org_id, service_id, group_name=None, - payment_channel_management_strategy=None, options=None, concurrent_calls=1): + global_config = Config(sdk_config=config) + self.setup_config(global_config) + sdk = SDKCommand(global_config, args=Arguments(config['org_id'], config['service_id'])) + force_update = config.get('force_update', False) + + if force_update: + sdk.generate_client_library() + else: + path_to_pb_files = self.get_path_to_pb_files(config['org_id'], config['service_id']) + pb_2_file_name = find_file_by_keyword(path_to_pb_files, keyword="pb2.py") + pb_2_grpc_file_name = find_file_by_keyword(path_to_pb_files, keyword="pb2_grpc.py") + if not pb_2_file_name or not pb_2_grpc_file_name: + sdk.generate_client_library() + + def setup_config(self, config: Config) -> None: + out_f = sys.stdout + network = self._config.get("network", None) + identity_name = self._config.get("identity_name", None) + # Checking for an empty network + if network and config["session"]["network"] != network: + config.set_session_network(network, out_f) + if identity_name: + self.set_session_identity(identity_name, config, out_f) + elif len(config.get_all_identities_names()) > 0: + if "identity" not in config["session"] or config["session"]["identity"] == "": + raise Exception("identity_name is not passed or selected") + + def set_session_identity(self, identity_name: str, config: Config, out_f): + if identity_name not in config.get_all_identities_names(): + identity = config.setup_identity() + config.add_identity(identity_name, identity, out_f) + config.set_session_identity(identity_name, out_f) + elif config["session"]["identity"] != identity_name: + config.set_session_identity(identity_name, out_f) + + def create_service_client(self, payment_channel_management_strategy=None, + options=None, concurrent_calls=1): + org_id = self._config.get("org_id") + service_id = self._config.get("service_id") + group_name = self._config.get("group_name", "default_group") + if payment_channel_management_strategy is None: payment_channel_management_strategy = DefaultPaymentStrategy(concurrent_calls) if options is None: diff --git a/testcases/functional_tests/examples_service_pb2.py b/testcases/functional_tests/examples_service_pb2.py deleted file mode 100644 index 0c79462..0000000 --- a/testcases/functional_tests/examples_service_pb2.py +++ /dev/null @@ -1,166 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: examples_service.proto - -import sys -_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='examples_service.proto', - package='example_service', - syntax='proto3', - serialized_options=None, - serialized_pb=_b('\n\x16\x65xamples_service.proto\x12\x0f\x65xample_service\"\x1f\n\x07Numbers\x12\t\n\x01\x61\x18\x01 \x01(\x02\x12\t\n\x01\x62\x18\x02 \x01(\x02\"\x17\n\x06Result\x12\r\n\x05value\x18\x01 \x01(\x02\x32\xfc\x01\n\nCalculator\x12:\n\x03\x61\x64\x64\x12\x18.example_service.Numbers\x1a\x17.example_service.Result\"\x00\x12:\n\x03sub\x12\x18.example_service.Numbers\x1a\x17.example_service.Result\"\x00\x12:\n\x03mul\x12\x18.example_service.Numbers\x1a\x17.example_service.Result\"\x00\x12:\n\x03\x64iv\x12\x18.example_service.Numbers\x1a\x17.example_service.Result\"\x00\x62\x06proto3') -) - - - - -_NUMBERS = _descriptor.Descriptor( - name='Numbers', - full_name='example_service.Numbers', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='a', full_name='example_service.Numbers.a', index=0, - number=1, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR), - _descriptor.FieldDescriptor( - name='b', full_name='example_service.Numbers.b', index=1, - number=2, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=43, - serialized_end=74, -) - - -_RESULT = _descriptor.Descriptor( - name='Result', - full_name='example_service.Result', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='value', full_name='example_service.Result.value', index=0, - number=1, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=76, - serialized_end=99, -) - -DESCRIPTOR.message_types_by_name['Numbers'] = _NUMBERS -DESCRIPTOR.message_types_by_name['Result'] = _RESULT -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -Numbers = _reflection.GeneratedProtocolMessageType('Numbers', (_message.Message,), dict( - DESCRIPTOR = _NUMBERS, - __module__ = 'examples_service_pb2' - # @@protoc_insertion_point(class_scope:example_service.Numbers) - )) -_sym_db.RegisterMessage(Numbers) - -Result = _reflection.GeneratedProtocolMessageType('Result', (_message.Message,), dict( - DESCRIPTOR = _RESULT, - __module__ = 'examples_service_pb2' - # @@protoc_insertion_point(class_scope:example_service.Result) - )) -_sym_db.RegisterMessage(Result) - - - -_CALCULATOR = _descriptor.ServiceDescriptor( - name='Calculator', - full_name='example_service.Calculator', - file=DESCRIPTOR, - index=0, - serialized_options=None, - serialized_start=102, - serialized_end=354, - methods=[ - _descriptor.MethodDescriptor( - name='add', - full_name='example_service.Calculator.add', - index=0, - containing_service=None, - input_type=_NUMBERS, - output_type=_RESULT, - serialized_options=None, - ), - _descriptor.MethodDescriptor( - name='sub', - full_name='example_service.Calculator.sub', - index=1, - containing_service=None, - input_type=_NUMBERS, - output_type=_RESULT, - serialized_options=None, - ), - _descriptor.MethodDescriptor( - name='mul', - full_name='example_service.Calculator.mul', - index=2, - containing_service=None, - input_type=_NUMBERS, - output_type=_RESULT, - serialized_options=None, - ), - _descriptor.MethodDescriptor( - name='div', - full_name='example_service.Calculator.div', - index=3, - containing_service=None, - input_type=_NUMBERS, - output_type=_RESULT, - serialized_options=None, - ), -]) -_sym_db.RegisterServiceDescriptor(_CALCULATOR) - -DESCRIPTOR.services_by_name['Calculator'] = _CALCULATOR - -# @@protoc_insertion_point(module_scope) diff --git a/testcases/functional_tests/examples_service_pb2_grpc.py b/testcases/functional_tests/examples_service_pb2_grpc.py deleted file mode 100644 index 4f8e8e5..0000000 --- a/testcases/functional_tests/examples_service_pb2_grpc.py +++ /dev/null @@ -1,97 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc - -import examples_service_pb2 as examples__service__pb2 - - -class CalculatorStub(object): - # missing associated documentation comment in .proto file - pass - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.add = channel.unary_unary( - '/example_service.Calculator/add', - request_serializer=examples__service__pb2.Numbers.SerializeToString, - response_deserializer=examples__service__pb2.Result.FromString, - ) - self.sub = channel.unary_unary( - '/example_service.Calculator/sub', - request_serializer=examples__service__pb2.Numbers.SerializeToString, - response_deserializer=examples__service__pb2.Result.FromString, - ) - self.mul = channel.unary_unary( - '/example_service.Calculator/mul', - request_serializer=examples__service__pb2.Numbers.SerializeToString, - response_deserializer=examples__service__pb2.Result.FromString, - ) - self.div = channel.unary_unary( - '/example_service.Calculator/div', - request_serializer=examples__service__pb2.Numbers.SerializeToString, - response_deserializer=examples__service__pb2.Result.FromString, - ) - - -class CalculatorServicer(object): - # missing associated documentation comment in .proto file - pass - - def add(self, request, context): - # missing associated documentation comment in .proto file - pass - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def sub(self, request, context): - # missing associated documentation comment in .proto file - pass - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def mul(self, request, context): - # missing associated documentation comment in .proto file - pass - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def div(self, request, context): - # missing associated documentation comment in .proto file - pass - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_CalculatorServicer_to_server(servicer, server): - rpc_method_handlers = { - 'add': grpc.unary_unary_rpc_method_handler( - servicer.add, - request_deserializer=examples__service__pb2.Numbers.FromString, - response_serializer=examples__service__pb2.Result.SerializeToString, - ), - 'sub': grpc.unary_unary_rpc_method_handler( - servicer.sub, - request_deserializer=examples__service__pb2.Numbers.FromString, - response_serializer=examples__service__pb2.Result.SerializeToString, - ), - 'mul': grpc.unary_unary_rpc_method_handler( - servicer.mul, - request_deserializer=examples__service__pb2.Numbers.FromString, - response_serializer=examples__service__pb2.Result.SerializeToString, - ), - 'div': grpc.unary_unary_rpc_method_handler( - servicer.div, - request_deserializer=examples__service__pb2.Numbers.FromString, - response_serializer=examples__service__pb2.Result.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'example_service.Calculator', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) diff --git a/testcases/functional_tests/service_spec1/__init__.py b/testcases/functional_tests/service_spec1/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/testcases/functional_tests/service_spec1/examples_service.proto b/testcases/functional_tests/service_spec1/examples_service.proto deleted file mode 100644 index 2ecac58..0000000 --- a/testcases/functional_tests/service_spec1/examples_service.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; - -package example_service; - -message Numbers { - float a = 1; - float b = 2; -} - -message Result { - float value = 1; -} - -service Calculator { - rpc add(Numbers) returns (Result) {} - rpc sub(Numbers) returns (Result) {} - rpc mul(Numbers) returns (Result) {} - rpc div(Numbers) returns (Result) {} -} diff --git a/testcases/functional_tests/test_prepaid_payment_multithread.py b/testcases/functional_tests/test_prepaid_payment_multithread.py deleted file mode 100644 index 8111bbb..0000000 --- a/testcases/functional_tests/test_prepaid_payment_multithread.py +++ /dev/null @@ -1,47 +0,0 @@ -from snet import sdk -import examples_service_pb2 -import examples_service_pb2_grpc -import threading - - - -def service_call(service_client, token, channel, a, b): - service_client.set_concurrency_token_and_channel(token, channel) - request = examples_service_pb2.Numbers(a=a, b=b) - result = service_client.service.mul(request) - assert result.value == a * b - - -def test_sdk(): - org_id = "6ce80f485dae487688c3a083688819bb" - service_id = "test_freecall" - group_name = "default_group" - - config = { - "private_key": "0x484573a7949da33d9aceeba372fc697532fdb69278318c03d04418a1af8a6208", - "eth_rpc_endpoint": "https://goerli.infura.io/v3/09027f4a13e841d48dbfefc67e7685d5", - "mpe_contract_address": "0x8fb1dc8df86b388c7e00689d1ecb533a160b4d0c", - "registry_contract_address": "0x663422c6999ff94933dbcb388623952cf2407f6f", - "token_contract_address": "0xb97E9bBB6fd49865709d3F1576e8506ad640a13B", - "ipfs_rpc_endpoint": "http://ipfs.singularitynet.io:80", - "free_call_auth_token-bin": "", - "free-call-token-expiry-block": 9808238, - "email": "ichbinvivek@gmail.com" - } - snet_sdk = sdk.SnetSDK(config) - service_client = snet_sdk.create_service_client(org_id, service_id, examples_service_pb2_grpc.CalculatorStub, - group_name=group_name, concurrent_calls=2) - token, channel = service_client.get_concurrency_token_and_channel() - try: - thread_1 = threading.Thread(target=service_call, args=(service_client, token, channel, 2, 3), name="thread_1") - thread_2 = threading.Thread(target=service_call, args=(service_client, token, channel, 4, 5), name="thread_2") - thread_1.start() - thread_2.start() - thread_1.join() - thread_2.join() - except Exception as e: - print("threading failed", e) - - -if __name__ == '__main__': - test_sdk() diff --git a/testcases/functional_tests/test_sdk_client.py b/testcases/functional_tests/test_sdk_client.py index e0f73f6..7ab32ce 100644 --- a/testcases/functional_tests/test_sdk_client.py +++ b/testcases/functional_tests/test_sdk_client.py @@ -8,79 +8,12 @@ class TestSDKClient(unittest.TestCase): def setUp(self): self.service_client, self.path_to_pb_files = get_test_service_data() + channel = self.service_client.deposit_and_open_channel(123456, 33333) - # TODO update/replace/remove tests that are commented out - - # def test_verify_when_no_open_channel(self): - # channels = self.service_client.load_open_channels() - # self.assertEqual(0, len(channels)) - - # def test_make_first_free_call(self): - # result = self.service_client.call_rpc("mul", "Numbers", a=20, b=4) - # self.assertEqual(80.0, result.value) - - # def test_make_second_free_call(self): - # result = self.service_client.call_rpc("mul", "Numbers", a=20, b=5) - # self.assertEqual(100.0, result.value) - - def test_open_first_channel(self): - channel = self.service_client.open_channel(123456, 33333) - # self.assertEqual(0, channel.channel_id) - # self.assertEqual(0, channel.state['nonce']) - # self.assertEqual(0, channel.state['last_signed_amount']) - - def test_first_call_to_service_after_opening_first_channel(self): + def test__call_to_service(self): result = self.service_client.call_rpc("mul", "Numbers", a=20, b=3) self.assertEqual(60.0, result.value) - # def test_verify_channel_state_after_opening_first_channel_and_first_call_to_service(self): - # self.service_client.update_channel_states() - # channels = self.service_client.load_open_channels() - # self.assertEqual(0, channels[0].channel_id) - # self.assertEqual(0, channels[0].state['nonce']) - # self.assertEqual(1000, channels[0].state['last_signed_amount']) - - # def test_second_call_to_service_after_opening_first_channel(self): - # result = self.service_client.call_rpc("mul", "Numbers", a=20, b=3) - # self.assertEqual(60.0, result.value) - - # def test_verify_channel_state_after_opening_first_channel_and_second_call_to_service(self): - # self.service_client.update_channel_states() - # channels = self.service_client.load_open_channels() - # self.assertEqual(0, channels[0].channel_id) - # self.assertEqual(0, channels[0].state['nonce']) - # self.assertEqual(2000, channels[0].state['last_signed_amount']) - - # def test_open_second_channel(self): - # channel = self.service_client.open_channel(1234321, 123456) - # self.assertEqual(1, channel.channel_id) - # self.assertEqual(0, channel.state['nonce']) - # self.assertEqual(0, channel.state['last_signed_amount']) - - # def test_verify_number_of_channel_after_opening_second_channel(self): - # self.service_client.update_channel_states() - # channels = self.service_client.load_open_channels() - # self.assertEqual(0, channels[0].channel_id) - # self.assertEqual(0, channels[0].state['nonce']) - # self.assertEqual(2000, channels[0].state['last_signed_amount']) - # self.assertEqual(1, channels[1].channel_id) - # self.assertEqual(0, channels[1].state['nonce']) - # self.assertEqual(0, channels[1].state['last_signed_amount']) - - # def test_first_call_to_service_after_opening_second_channel(self): - # result = self.service_client.call_rpc("mul", "Numbers", a=20, b=3) - # self.assertEqual(60.0, result.value) - - # def test_verify_channel_state_after_opening_second_channel_and_first_call_to_service(self): - # self.service_client.update_channel_states() - # channels = self.service_client.load_open_channels() - # self.assertEqual(0, channels[0].channel_id) - # self.assertEqual(0, channels[0].state['nonce']) - # self.assertEqual(3000, channels[0].state['last_signed_amount']) - # self.assertEqual(1, channels[1].channel_id) - # self.assertEqual(0, channels[1].state['nonce']) - # self.assertEqual(0, channels[1].state['last_signed_amount']) - def tearDown(self): try: shutil.rmtree(self.path_to_pb_files) @@ -90,26 +23,22 @@ def tearDown(self): def get_test_service_data(): - org_id = "26072b8b6a0e448180f8c0e702ab6d2f" - service_id = "Exampleservice" - group_name = "default_group" - config = { "private_key": os.environ['SNET_TEST_WALLET_PRIVATE_KEY'], "eth_rpc_endpoint": f"https://sepolia.infura.io/v3/{os.environ['SNET_TEST_INFURA_KEY']}", - "email": "test@test.com", - # "free_call_auth_token-bin":"f5533eb0f01f0d45239c11b411bdfd4221fd3b125e4250db1f7bc044466108bc10ce95ab62ae224b6578b68d0ce337b4ec36e4b9dfbe6653e04973107813cbc01c", - # "free-call-token-expiry-block":19690819, "concurrency": False, - "org_id": org_id, - "service_id": service_id, + "org_id": "26072b8b6a0e448180f8c0e702ab6d2f", + "service_id": "Exampleservice", + "group_name": "default_group", "identity_name": "test", "identity_type": "key", + "network": "sepolia", + "force_update": False } snet_sdk = sdk.SnetSDK(config) - service_client = snet_sdk.create_service_client(org_id, service_id, group_name) - path_to_pb_files = snet_sdk.get_path_to_pb_files(org_id, service_id) + service_client = snet_sdk.create_service_client() + path_to_pb_files = snet_sdk.get_path_to_pb_files(config['org_id'], config['service_id']) return service_client, path_to_pb_files diff --git a/testcases/utils/reset_environment.sh b/testcases/utils/reset_environment.sh index 83034d3..94035a6 100755 --- a/testcases/utils/reset_environment.sh +++ b/testcases/utils/reset_environment.sh @@ -94,5 +94,3 @@ sleep 20 #cd ~/singnet/snet-cli - - diff --git a/version.py b/version.py index 30a0d3a..88c513e 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "3.2.0" \ No newline at end of file +__version__ = "3.3.0"