From cf8ccc13caae5c61fa7ba8226cafdfae9a11268d Mon Sep 17 00:00:00 2001 From: MorozovMisha Date: Tue, 4 Feb 2025 15:16:01 +0300 Subject: [PATCH] [SPT-777] New functional tests: service metadata daemon, endpoints --- snet/cli/test/functional_tests/func_tests.py | 93 ++++--- snet/cli/test/functional_tests/mint/mint.py | 62 ----- .../script10_claim_timeout_all.sh | 39 --- .../script11_update_metadata.sh | 69 ----- .../script12_extend_add_for_service.sh | 80 ------ .../script13_call_reinitialize.sh | 64 ----- .../script14_full_stateless_logic.sh | 53 ---- .../script15_sdk_generate_client_library.sh | 21 -- .../functional_tests/script1_twogroups.sh | 259 ------------------ .../script2_deposit_transfer.sh | 24 -- .../script3_without_addresses.sh | 77 ------ .../script4_only_with_networks.sh | 96 ------- .../script5_identity1_rpc_mnemonic.sh | 73 ----- .../functional_tests/script6_organization.sh | 104 ------- .../functional_tests/script7_contracts.sh | 31 --- .../test/functional_tests/script8_networks.sh | 16 -- .../functional_tests/script9_treasurer.sh | 90 ------ .../service_spec1/ExampleService.proto | 17 -- .../test/functional_tests/service_spec1/test | 1 - snet/cli/test/utils/reset_environment.sh | 61 ----- snet/cli/test/utils/run_all_functional.sh | 11 - 21 files changed, 57 insertions(+), 1284 deletions(-) delete mode 100644 snet/cli/test/functional_tests/mint/mint.py delete mode 100755 snet/cli/test/functional_tests/script10_claim_timeout_all.sh delete mode 100755 snet/cli/test/functional_tests/script11_update_metadata.sh delete mode 100755 snet/cli/test/functional_tests/script12_extend_add_for_service.sh delete mode 100644 snet/cli/test/functional_tests/script13_call_reinitialize.sh delete mode 100644 snet/cli/test/functional_tests/script14_full_stateless_logic.sh delete mode 100755 snet/cli/test/functional_tests/script15_sdk_generate_client_library.sh delete mode 100755 snet/cli/test/functional_tests/script1_twogroups.sh delete mode 100755 snet/cli/test/functional_tests/script2_deposit_transfer.sh delete mode 100755 snet/cli/test/functional_tests/script3_without_addresses.sh delete mode 100755 snet/cli/test/functional_tests/script4_only_with_networks.sh delete mode 100755 snet/cli/test/functional_tests/script5_identity1_rpc_mnemonic.sh delete mode 100755 snet/cli/test/functional_tests/script6_organization.sh delete mode 100644 snet/cli/test/functional_tests/script7_contracts.sh delete mode 100644 snet/cli/test/functional_tests/script8_networks.sh delete mode 100644 snet/cli/test/functional_tests/script9_treasurer.sh delete mode 100644 snet/cli/test/functional_tests/service_spec1/ExampleService.proto delete mode 100644 snet/cli/test/functional_tests/service_spec1/test delete mode 100755 snet/cli/test/utils/reset_environment.sh delete mode 100755 snet/cli/test/utils/run_all_functional.sh diff --git a/snet/cli/test/functional_tests/func_tests.py b/snet/cli/test/functional_tests/func_tests.py index 9461f8e6..e04914c8 100644 --- a/snet/cli/test/functional_tests/func_tests.py +++ b/snet/cli/test/functional_tests/func_tests.py @@ -117,7 +117,7 @@ def test_deposit(self): execute(["account", "deposit", f"{self.amount}", "-y", "-q"], self.parser, self.conf) result = execute(["account", "balance"], self.parser, self.conf) self.balance_2 = float(result.split("\n")[3].split()[1]) - assert round(self.balance_2, 3) == round(self.balance_1, 3) + self.amount + assert round(self.balance_2, 2) == round(self.balance_1, 2) + self.amount def test_withdraw(self): result = execute(["account", "balance"], self.parser, self.conf) @@ -125,7 +125,7 @@ def test_withdraw(self): execute(["account", "withdraw", f"{self.amount}", "-y", "-q"], self.parser, self.conf) result = execute(["account", "balance"], self.parser, self.conf) self.balance_2 = float(result.split("\n")[3].split()[1]) - assert round(self.balance_2, 3) == round(self.balance_1, 3) - self.amount + assert round(self.balance_2, 2) == round(self.balance_1, 2) - self.amount def test_transfer(self): result = execute(["account", "transfer", ADDR, f"{self.amount}", "-y"], self.parser, self.conf) @@ -240,26 +240,20 @@ def setUp(self): self.password = "12345" self.group = "default_group" data = execute(["channel", "print-filter-group", self.org_id, "default_group"], self.parser, self.conf) - max_id = None - for line in data.splitlines()[2:]: - parts = line.split() - if len(parts) < 7: - continue - - channel_id = int(parts[0].lstrip("#")) - value = int(parts[6]) + lines = data.split("\n") - if value > 0: - if max_id is None or channel_id > max_id: - max_id = channel_id - self.max_id = str(max_id) if max_id is not None else None + for line in lines: + parts = line.split() + if len(parts) >= 6 and parts[0].isdigit() and parts[-1].isdigit(): + channel_id, expiration = parts[0], int(parts[-1]) + self.max_id=channel_id def test_channel_1_extend(self): execute(["account", "deposit", self.amount, "-y", "-q"], self.parser, self.conf) result1 = execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf) - result2 = execute(["channel", "extend-add-for-org", self.org_id, "default_group", "--channel-id", f"{self.max_id}", "-y"], self.parser, self.conf) - print(result2) - assert f"channelId: ", self.max_id in result1 + # result2 = execute(["channel", "extend-add-for-org", self.org_id, "default_group", "--channel-id", f"{self.max_id}", "-y"], self.parser, self.conf) + # print(result2) + assert "channelId: ", self.max_id in result1 def test_channel_2_print_filter_sender(self): result = execute(["channel", "print-filter-sender"], self.parser, self.conf) @@ -270,11 +264,11 @@ def test_channel_3_print_filter_group_sender(self): result = execute(["channel", "print-filter-group-sender", self.org_id, self.group], self.parser, self.conf) assert "Channels for sender: ", ADDR in result - def test_channel_3_print_filter_group(self): + def test_channel_4_print_filter_group(self): result = execute(["channel", "print-filter-group", self.org_id, self.group], self.parser, self.conf) assert self.max_id in result - def test_channel_4_claim(self): + def test_channel_5_claim(self): execute(["account", "deposit", self.amount, "-y", "-q"], self.parser, self.conf) execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf) result1 = execute(["channel", "claim-timeout", f"{self.max_id}", "-y"], self.parser, self.conf) @@ -302,13 +296,13 @@ def setUp(self): def test_0_preparations(self): identity_list=execute(["identity", "list"], self.parser, self.conf) if self.identity_name not in identity_list: - execute(["identity", "create", self.identity_name, "key", "--private-key", "faaf0c972a152459d97e7267280689583aae2d1caaa518cce7e412dd13f7b3e8", "-de"], self.parser, self.conf) + execute(["identity", "create", self.identity_name, "key", "--private-key", PRIVATE_KEY, "-de"], self.parser, self.conf) execute(["network", "sepolia"], self.parser, self.conf) result = execute(["session"], self.parser, self.conf) assert "network: sepolia" in result def test_1_channel_open(self): - execute(["set", "default_eth_rpc_endpoint", "https://sepolia.infura.io/v3/047c3c4404ef4cbc90938371a8e34604"], self.parser, self.conf) + execute(["set", "default_eth_rpc_endpoint", INFURA], self.parser, self.conf) execute(["account", "deposit", "0.0001", "-y"], self.parser, self.conf) self.block=int(execute(["channel", "block-number"], self.parser, self.conf)) print(self.block) @@ -332,7 +326,7 @@ def test_3_service_get_channel_state(self): assert "current_unspent_amount_in_cogs = " in result def test_4_call_low_level(self): - result = execute(["client", "call-lowlevel", self.org_id, self.service_id, self.group, self.max_id, self.nonce, self.amount_in_cogs], self.parser, self.conf) + result = execute(["client", "call-lowlevel", self.org_id, self.service_id, self.group, self.max_id, self.nonce, self.amount_in_cogs, self.method, self.params], self.parser, self.conf) assert "spam" in result def test_5_get_api_registry(self): @@ -374,7 +368,7 @@ def setUp(self): self.free_calls = "100" self.contributor = "Stasy" self.contributor_mail = "stasy@hotmail.com" - self.tags = "new", "text2text", "t2t", "punctuality" + self.tags = ["new", "text2text", "t2t", "punctuality"] self.hero_image = "./img.jpg" self.contact = "author" self.email = "author@hotmail.com" @@ -426,12 +420,22 @@ def test_3_create_service(self): result = execute(["service", "publish", self.org_id, self.service_id, "-y"], self.parser, self.conf) assert "event: ServiceCreated" in result - def test_4_lists(self): - result1 = execute(["organization", "list"], self.parser, self.conf) - result2 = execute(["organization", "list-org-names"], self.parser, self.conf) - result3 = execute(["organization", "list-my"], self.parser, self.conf) - result4 = execute(["organization", "list-services", self.org_id], self.parser, self.conf) - assert (self.org_id in result1) and (self.org_name in result2) and (self.org_id in result3) and (self.service_id in result4) + def test_41_list(self): + result = execute(["organization", "list"], self.parser, self.conf) + assert self.org_id in result + + def test_42_list_org_names(self): + result = execute(["organization", "list-org-names"], self.parser, self.conf) + assert self.org_name in result + + def test_43_list_my(self): + result = execute(["organization", "list-my"], self.parser, self.conf) + assert self.org_id in result + + def test_44_list_services(self): + result = execute(["organization", "list-services", self.org_id], self.parser, self.conf) + assert self.service_id in result + def test_5_change_members(self): result_add = execute(["organization", "add-members", self.org_id, ADDR, "-y"], self.parser, self.conf) @@ -439,7 +443,7 @@ def test_5_change_members(self): # result_change_owner = execute(["organization", "change-owner", self.org_id, ADDR], self.parser, self.conf) assert "event: OrganizationModified" in result_rem - def test_6_change_org_metadata(self): + def test_61_change_org_metadata(self): hero_image = open("img.jpg", "w+") hero_image.close() execute(["organization", "metadata-add-assets", self.hero_image, "hero_image"], self.parser, self.conf) @@ -453,10 +457,16 @@ def test_6_change_org_metadata(self): result = execute(["organization", "print-metadata", self.org_id], self.parser, self.conf) assert self.new_description in result - def test_7_change_service_metadata(self): + def test_62_change_service_metadata(self): execute(["service", "metadata-remove-group", self.group_name], self.parser, self.conf) execute(["service", "metadata-add-group", self.group_name], self.parser, self.conf) execute(["organization", "update-group", self.group_name], self.parser, self.conf) + execute(["service", "metadata-add-daemon-addresses", self.group_name, ADDR], self.parser, self.conf) + execute(["service", "metadata-remove-all-daemon-addresses", self.group_name], self.parser, self.conf) + execute(["service", "metadata-update-daemon-addresses", self.group_name, ADDR], self.parser, self.conf) + execute(["service", "metadata-add-endpoints", self.group_name, self.endpoint], self.parser, self.conf) + execute(["service", "metadata-remove-all-endpoints", self.group_name], self.parser, self.conf) + execute(["service", "metadata-add-endpoints", self.group_name, self.endpoint], self.parser, self.conf) execute(["service", "metadata-set-free-calls", self.group_name, self.free_calls], self.parser, self.conf) execute(["service", "metadata-set-freecall-signer-address", self.group_name, ADDR], self.parser, self.conf) execute(["service", "metadata-add-description", "--description", self.new_description, "--short-description", self.short_description, "--url", self.url], @@ -471,25 +481,36 @@ def test_7_change_service_metadata(self): execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf) execute(["service", "metadata-remove-media", "1"], self.parser, self.conf) execute(["service", "metadata-remove-all-media"], self.parser, self.conf) - execute(["service", "metadata-add-tags", self.tags], self.parser, self.conf) + execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf) + execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf) + execute(["service", "metadata-swap-media-order", "1", "2"], self.parser, self.conf) + execute(["service", "metadata-change-media-order"], self.parser, self.conf) execute(["service", "update-metadata", self.org_id, self.service_id, "-y"], self.parser, self.conf) result = execute(["service", "print-metadata", self.org_id, self.service_id], self.parser, self.conf) print(execute(["service", "print-metadata", self.org_id, self.service_id], self.parser, self.conf)) print(execute(["service", "print-service-status", self.org_id, self.service_id], self.parser, self.conf)) assert self.contributor in result - def test_8_get_api_metadata(self): + def test_63_tags(self): + execute(["service", "metadata-add-tags", self.tags], self.parser, self.conf) + execute(["service", "update-metadata", self.org_id, self.service_id, "-y"], self.parser, self.conf) + print(execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf)) + result=execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf) + print(result) + assert self.tags in result + + def test_64_get_api_metadata(self): os.remove(f"./ExampleService.proto") execute(["service", "get-api-metadata", "./"], self.parser, self.conf) assert os.path.exists(f"./ExampleService.proto") - def test_9_delete_service(self): + def test_7_delete_service(self): result = execute(["service", "delete", self.org_id, self.service_id, "-y"], self.parser, self.conf) os.remove(f"./service_metadata.json") assert "event: ServiceDeleted" in result - def test_91_delete_organization(self): - result=execute(["organization", "delete", self.org_id, "-y"], self.parser, self.conf) + def test_8_delete_organization(self): + result = execute(["organization", "delete", self.org_id, "-y"], self.parser, self.conf) os.remove(f"./organization_metadata.json") os.remove(f"img.jpg") assert "event: OrganizationDeleted" in result diff --git a/snet/cli/test/functional_tests/mint/mint.py b/snet/cli/test/functional_tests/mint/mint.py deleted file mode 100644 index bf37a47b..00000000 --- a/snet/cli/test/functional_tests/mint/mint.py +++ /dev/null @@ -1,62 +0,0 @@ -from snet.contracts import get_contract_object - -from packages.snet_cli.snet.snet_cli.utils.utils import get_web3 -from web3.gas_strategies.time_based import medium_gas_price_strategy - -TRANSACTION_TIMEOUT = 500 -DEFAULT_GAS = 300000 -HTTP_PROVIDER = "http://localhost:8545" - -wallet_address_1 = "0x592E3C0f3B038A0D673F19a18a773F993d4b2610" -contract_address = "0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14" -signer_private_key = ( - "0xc71478a6d0fe44e763649de0a0deb5a080b788eefbbcf9c6f7aef0dd5dbd67e0" -) - -initialNonce = 0 -mint_amount = 10000000000000000 - - -def _get_nonce(web3, address): - nonce = web3.eth.get_transaction_count(address) - if initialNonce >= nonce: - nonce = initialNonce + 1 - nonce = nonce - return nonce - - -def send_transaction(web3, contract_fn, *args): - txn_hash = _send_signed_transaction(web3, contract_fn, *args) - return web3.eth.wait_for_transaction_receipt(txn_hash, TRANSACTION_TIMEOUT) - - -def _send_signed_transaction(web3, wallet_address, contract_fn, *args): - transaction = contract_fn(*args).buildTransaction( - { - "chainId": int(web3.version.network), - "gas": DEFAULT_GAS, - "gasPrice": web3.eth.gas_price * 4 / 3, - "nonce": _get_nonce(web3, wallet_address), - } - ) - - signed_txn = web3.eth.account.sign_transaction( - transaction, private_key=signer_private_key - ) - return web3.to_hex(web3.eth.send_raw_transaction(signed_txn.rawTransaction)) - - -def mint_token(): - w3 = get_web3(HTTP_PROVIDER) - address_1 = w3.to_checksum_address(wallet_address_1) - contract = get_contract_object( - w3, contract_file="SingularityNetToken.json", address=contract_address - ) - - send_transaction( - w3, wallet_address_1, contract.functions.mint, address_1, int(mint_amount) - ) - - -if __name__ == "__main__": - mint_token() diff --git a/snet/cli/test/functional_tests/script10_claim_timeout_all.sh b/snet/cli/test/functional_tests/script10_claim_timeout_all.sh deleted file mode 100755 index dd713ed9..00000000 --- a/snet/cli/test/functional_tests/script10_claim_timeout_all.sh +++ /dev/null @@ -1,39 +0,0 @@ -snet service metadata-init ./service_spec1/ ExampleService --group-name group0 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 9.8.9.8:8080 -snet service metadata-init ./service_spec1/ ExampleService -snet service metadata-add-group group1 -snet service metadata-add-endpoints group1 8.8.8.8:22 1.2.3.4:8080 - -snet service metadata-add-group group2 -snet service metadata-add-endpoints group2 8.8.8.8:2 1.2.3.4:800 - -snet organization metadata-init org1 testo individual -snet organization add-group group0 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet organization add-group group1 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 1.2.1.1:8089 -snet organization add-group group2 0x32267d505B1901236508DcDa64C1D0d5B9DF639a 1.2.1.1:8089 -snet organization create testo -y -q -snet service metadata-remove-group group0 -snet service publish testo tests -y -q - -EXPIRATION0=$(($(snet channel block-number) - 1)) -EXPIRATION1=$(($(snet channel block-number) - 1)) -EXPIRATION2=$(($(snet channel block-number) + 100000)) - -snet account deposit 100 -y -q - -assert_balance() { - MPE_BALANCE=$(snet account balance | grep MPE) - test ${MPE_BALANCE##*:} = $1 -} - -# should file because group_name has not been specified -snet channel open-init testo tests 1 $EXPIRATION0 -yq && exit 1 || echo "fail as expected" - -snet channel open-init testo group0 0.1 $EXPIRATION0 -yq -snet channel open-init testo group1 1 $EXPIRATION1 -yq -snet channel open-init testo group2 10 $EXPIRATION2 -yq - -assert_balance 88.9 - -# should claim channels 0 and 1, but not 2 -snet channel claim-timeout-all -y -assert_balance 90 diff --git a/snet/cli/test/functional_tests/script11_update_metadata.sh b/snet/cli/test/functional_tests/script11_update_metadata.sh deleted file mode 100755 index 7fb5f82d..00000000 --- a/snet/cli/test/functional_tests/script11_update_metadata.sh +++ /dev/null @@ -1,69 +0,0 @@ -# simple case of one group -snet service metadata-init ./service_spec1/ ExampleService --fixed-price 0.0001 --endpoints 8.8.8.8:2020 --group-name group1 - -snet --print-traceback organization metadata-init org1 testo individual -snet --print-traceback organization add-group group1 0x52653A9091b5d5021bed06c5118D24b23620c529 5.5.6.7:8089 -snet --print-traceback organization add-group group2 0x52653A9091b5d5021bed06c5118D24b23620c529 1.2.1.1:8089 -snet --print-traceback organization create testo -y -q -snet --print-traceback service publish testo tests -y -q - -# change group_id - -# case with several groups -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --group-name group0 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 9.8.9.8:8080 - -snet --print-traceback service metadata-add-daemon-addresses group0 0x123 -test "$(< service_metadata.json jq '.groups[0].daemon_addresses | length')" = 1 && echo "succes" || exit 1 -snet --print-traceback service metadata-add-daemon-addresses group0 0x234 - -snet --print-traceback service metadata-update-daemon-addresses group0 0x123 -test "$(< service_metadata.json jq '.groups[0].daemon_addresses | length')" = 1 && echo "succes" || exit 1 - -snet --print-traceback service metadata-add-daemon-addresses group10 0x123 || echo "fail as expected" - -snet --print-traceback service metadata-add-group group1 -snet --print-traceback service metadata-add-endpoints group1 8.8.8.8:22 1.2.3.4:8080 - - -snet --print-traceback service metadata-add-group group2 -snet --print-traceback service metadata-add-endpoints group2 8.8.8.8:2 1.2.3.4:800 - -# this should fail as group0 is not in organization -snet --print-traceback service update-metadata testo tests -yq && exit 1 || echo "fail as expected" -snet --print-traceback service metadata-remove-group group0 -snet --print-traceback service update-metadata testo tests -yq - - - -#add assets with single value - -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --metadata-file=service_asset_metadata.json -#cp service_metadata.json service_asset_metadata.json -snet --print-traceback service metadata-add-assets ./service_spec1/test hero_image --metadata-file=service_asset_metadata.json -snet --print-traceback service metadata-add-assets ./service_spec1/test terms_of_use --metadata-file=service_asset_metadata.json -result=$(cat service_asset_metadata.json | jq '.assets.hero_image') -test $result = '"QmWQhwwnvK4YHvEarEguTDhz8o2kwvyfPhv5favs1VS4xm/test"' && echo "add asset with single value test case passed " || exit 1 - -#add assets with multiple values -snet --print-traceback service metadata-add-assets ./service_spec1/test images --metadata-file=service_asset_metadata.json -snet --print-traceback service metadata-add-assets ./service_spec1/test images --metadata-file=service_asset_metadata.json -result=$(cat service_asset_metadata.json | jq '.assets.images[1]') -test $result = '"QmWQhwwnvK4YHvEarEguTDhz8o2kwvyfPhv5favs1VS4xm/test"' && echo "add asset with multiple value test case passed " || exit 1 - -#remove assets -snet --print-traceback service metadata-remove-assets hero_image --metadata-file=service_asset_metadata.json -result=$(cat service_asset_metadata.json | jq '.assets.hero_image') -test $result = '""' && echo "metadata-remove-assets test case passed " || exit 1 - -#remove all assets -snet --print-traceback service metadata-remove-all-assets --metadata-file=service_asset_metadata.json -result=$(cat service_asset_metadata.json | jq '.assets') -test $result = '{}' && echo "metadata-remove-all-assets test case passed " || exit 1 -rm service_asset_metadata.json - -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --group-name group1 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 9.8.9.8:8080 -snet --print-traceback service metadata-set-free-calls group1 12 -snet --print-traceback service metadata-set-freecall-signer-address group1 0x123 -test "$(< service_metadata.json jq '.groups[0].free_calls')" = 12 \ -&& test "$(< service_metadata.json jq '.groups[0].free_call_signer_address')" = '"0x123"' \ -&& echo "free call test passed" || exit 1 diff --git a/snet/cli/test/functional_tests/script12_extend_add_for_service.sh b/snet/cli/test/functional_tests/script12_extend_add_for_service.sh deleted file mode 100755 index 56919344..00000000 --- a/snet/cli/test/functional_tests/script12_extend_add_for_service.sh +++ /dev/null @@ -1,80 +0,0 @@ -snet organization metadata-init org1 testo individual -snet organization add-group group1 0x52653A9091b5d5021bed06c5118D24b23620c529 5.5.6.7:8089 -snet organization add-group group2 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 1.2.1.1:8089 -snet organization create test0 -y -q - -snet service metadata-init ./service_spec1/ ExampleService --fixed-price 0.0001 --endpoints 8.8.8.8:2020 --group-name group1 - -snet organization create testo -y -q -snet service publish testo tests -y -q - -snet account deposit 100000000 -yq - -snet channel open-init testo group1 123.123 1 -yq - -snet channel print-initialized | grep 123.223 && exit 1 || echo "fail as expected" - -snet --print-traceback channel extend-add-for-org testo group1 --amount 0.1 --expiration 314 -yq -snet channel extend-add-for-org testo group1 --amount 0.2 -yq -snet --print-traceback channel extend-add-for-org testo group1 --expiration 315 -yq -snet channel print-initialized | grep 123.423 -snet channel print-initialized | grep 315 - -rm -rf ~/.snet/mpe_client -snet --print-traceback channel extend-add-for-org testo group1 --amount 0.1 --expiration 315 -yq -snet channel extend-add-for-org testo group1 --amount 0.1 -yq -snet channel extend-add-for-org testo group1 --expiration 31415 -yq -snet channel print-initialized | grep 123.623 -snet channel print-initialized | grep 31415 - -snet --print-traceback channel open-init testo group1 7777.8888 1 -yq --open-new-anyway -snet channel extend-add-for-org testo group1 --amount 0.01 --expiration 314 -yq && exit 1 || echo "fail as expected" -snet channel extend-add-for-org testo group1 --amount 0.01 -yq && exit 1 || echo "fail as expected" -snet channel extend-add-for-org testo group1 --expiration 31477 -yq && exit 1 || echo "fail as expected" - -snet channel extend-add-for-org testo group1 --amount 0.01 --expiration 314 -yq --channel-id 1 -snet channel extend-add-for-org testo group1 --amount 0.01 --channel-id 1 -yq -snet channel extend-add-for-org testo group1 --expiration 31477 -yq --channel-id 1 -snet channel print-initialized | grep 7777.9088 -snet channel print-initialized | grep 31477 - -# multiply payment groups case -#snet service metadata-init ./service_spec1/ ExampleService 0x52653A9091b5d5021bed06c5118D24b23620c529 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 --group-name group2 -snet service metadata-add-group group2 -snet service metadata-add-endpoints group2 8.8.8.8:20202 9.10.9.8:8080 - -snet service update-metadata testo tests -yq - -snet channel open-init testo group2 2222.33333 1 -yq - -snet --print-traceback channel extend-add-for-org testo group1 --amount 0.001 --expiration 314 -yq && exit 1 || echo "fail as expected" -snet channel extend-add-for-org testo group1 --amount 0.001 -yq && exit 1 || echo "fail as expected" -snet channel extend-add-for-org testo group1 --expiration 4321 -yq && exit 1 || echo "fail as expected" - -snet channel extend-add-for-org testo group2 --amount 0.001 --expiration 4321 -yq -snet channel extend-add-for-org testo group2 --amount 0.001 -yq -snet channel extend-add-for-org testo group2 --expiration 4321 -yq - -snet channel print-initialized -snet channel print-initialized | grep 2222.33533 -snet channel print-initialized | grep 4321 - -#reinitializing the channel use the existing chnanels. -snet channel open-init testo group2 2222.33333 1 -yq - -snet channel print-initialized -snet channel extend-add-for-org testo group2 --amount 0.0001 --expiration 4444 -yq -snet channel extend-add-for-org testo group2 --amount 0.0001 -yq -snet channel extend-add-for-org testo group2 --expiration 5643 -yq -snet channel print-initialized -snet channel print-initialized | grep 2222.33553 -snet channel print-initialized | grep 5643 - -rm -rf ~/.snet/mpe_client - -snet channel extend-add-for-org testo group2 --amount 0.00001 --expiration 7654 -yq -snet channel extend-add-for-org testo group2 --amount 0.00001 -yq -snet channel extend-add-for-org testo group2 --expiration 7655 -yq -snet channel print-initialized -snet channel print-initialized | grep 2222.33555 -snet channel print-initialized | grep 7655 diff --git a/snet/cli/test/functional_tests/script13_call_reinitialize.sh b/snet/cli/test/functional_tests/script13_call_reinitialize.sh deleted file mode 100644 index 3b7ea88b..00000000 --- a/snet/cli/test/functional_tests/script13_call_reinitialize.sh +++ /dev/null @@ -1,64 +0,0 @@ -# script13 - -# run daemon -cd simple_daemon -python test_simple_daemon.py & -DAEMON=$! -cd .. - -snet service metadata-init ./service_spec1/ ExampleService --fixed-price 0.0001 --endpoints 127.0.0.1:50051 --group-name group1 -snet account deposit 12345 -y -q -snet organization metadata-init org1 testo individual -snet organization add-group group1 0x52653A9091b5d5021bed06c5118D24b23620c529 127.0.0.1:50051 - -snet organization create testo -y -q - -snet service publish testo tests -y -q -snet --print-traceback service print-service-status testo tests -snet --print-traceback channel open-init testo group1 1 +10days -yq - -snet --print-traceback client call testo tests group1 classify {} -y - -rm -rf ~/.snet/mpe_client - -snet client call testo tests group1 classify {} -y -snet --print-traceback client call testo tests group1 classify {} -y --skip-update-check - -# we will corrupt initialized channel -rm -rf ~/.snet/mpe_client/*/testo/tests/service/*py -rm -rf ~/.snet/mpe_client/*/testo/channel* -# in the current version snet-cli cannot detect this problem, so it should fail -# and it is ok, because it shoudn't update service at each call -snet client call testo tests classify group1 {} -y && exit 1 || echo "fail as expected" - -snet service metadata-add-endpoints group1 localhost:50051 - -# this should still fail because we skip registry check -snet client call testo tests group1 classify {} -y --skip-update-check && exit 1 || echo "fail as expected" - -snet service update-metadata testo tests -yq - -# no snet-cli should automatically update service, because metadataURI has changed -snet --print-traceback client call testo tests group1 classify {} -y - -# multiply payment groups case -# multiply payment groups case -snet service metadata-init ./service_spec1/ ExampleService --fixed-price 0.0001 --endpoints 127.0.0.1:50051 --group-name group1 - -snet organization add-group group2 0x52653A9091b5d5021bed06c5118D24b23620c529 127.0.0.1:50051 -snet organization update-metadata testo -yq -snet --print-traceback service publish testo tests2 -y -q -snet service print-service-status testo tests2 -snet --print-traceback client call testo tests2 group2 classify {} -y && exit 1 || echo "fail as expected" - -snet service metadata-add-group group2 -snet service metadata-set-fixed-price group2 0.0001 -snet service metadata-add-endpoints group2 127.0.0.1:50051 -snet service update-metadata testo tests2 -y - -snet --print-traceback channel open-init testo group2 1 +10days -yq -snet --print-traceback client call testo tests2 group2 classify {} -y - -rm -rf ~/.snet/mpe_client - -kill $DAEMON diff --git a/snet/cli/test/functional_tests/script14_full_stateless_logic.sh b/snet/cli/test/functional_tests/script14_full_stateless_logic.sh deleted file mode 100644 index 00825283..00000000 --- a/snet/cli/test/functional_tests/script14_full_stateless_logic.sh +++ /dev/null @@ -1,53 +0,0 @@ -# Test get-channel-state -# run daemon -cd simple_daemon -python test_simple_daemon.py & -DAEMON=$! -cd .. - -snet service metadata-init ./service_spec1/ ExampleService --fixed-price 0.0001 --endpoints 127.0.0.1:50051 --group-name group1 -snet account deposit 12345 -y -q -snet organization metadata-init org1 testo individual -snet organization add-group group1 0x52653A9091b5d5021bed06c5118D24b23620c529 127.0.0.1:50051 - -snet organization create testo -y -q - -snet service publish testo tests -y -q -snet channel open-init testo group1 1 +10days -yq -snet channel print-initialized - -test_get_channel_state() { - MPE_BALANCE=$(snet client get-channel-state 0 localhost:50051 | grep current_unspent_amount_in_cogs) - test ${MPE_BALANCE##*=} = $1 -} - -test_get_channel_state 100000000 - -snet client call testo tests group1 classify {} -y - -test_get_channel_state 99990000 - -snet channel print-initialized -snet --print-traceback treasurer claim-all --endpoint localhost:50051 --wallet-index 9 -yq - -test_get_channel_state 99990000 - -snet client call testo tests group1 classify {} -y -snet client call testo tests group1 classify {} -y - -test_get_channel_state 99970000 - -# we will start claim of all channels but will not write them to blockchain -echo n | snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 && exit 1 || echo "fail as expected" - -test_get_channel_state 99970000 -snet client call testo tests group1 classify {} -y -test_get_channel_state 99960000 - -snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -test_get_channel_state 99960000 -snet client call testo tests group1 classify {} -y - -test_get_channel_state 99950000 - -kill $DAEMON diff --git a/snet/cli/test/functional_tests/script15_sdk_generate_client_library.sh b/snet/cli/test/functional_tests/script15_sdk_generate_client_library.sh deleted file mode 100755 index 4b0006c2..00000000 --- a/snet/cli/test/functional_tests/script15_sdk_generate_client_library.sh +++ /dev/null @@ -1,21 +0,0 @@ -# simple case of one group -snet service metadata-init ./service_spec1/ ExampleService --group-name group1 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 -snet organization metadata-init org1 testo individual -snet organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 127.0.0.1:50051 -snet organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 127.0.0.1:50051 -snet organization create testo -y -q -snet service publish testo tests -y -q - -snet sdk generate-client-library python testo tests -test -f client_libraries/testo/tests/python/ExampleService_pb2_grpc.py - -snet sdk generate-client-library nodejs testo tests -test -f client_libraries/testo/tests/nodejs/ExampleService_grpc_pb.js - -# test relative path (and using already installed compiler) -snet sdk generate-client-library nodejs testo tests snet_output -test -f snet_output/testo/tests/nodejs/ExampleService_grpc_pb.js - -# test absolute path -snet sdk generate-client-library nodejs testo tests /tmp/snet_output -test -f /tmp/snet_output/testo/tests/nodejs/ExampleService_grpc_pb.js diff --git a/snet/cli/test/functional_tests/script1_twogroups.sh b/snet/cli/test/functional_tests/script1_twogroups.sh deleted file mode 100755 index 3b95f983..00000000 --- a/snet/cli/test/functional_tests/script1_twogroups.sh +++ /dev/null @@ -1,259 +0,0 @@ -snet session - -# service side - -#should fail (not existed directory) -snet service metadata-init ./bad_dir/ ExampleService --encoding json --service-type jsonrpc --group-name group1 && exit 1 || echo "fail as expected" - -#should fail (directory doesn't contain any *.proto files) -snet service metadata-init ./ ExampleService --encoding json --service-type jsonrpc --group-name group1 && exit 1 || echo "fail as expected" - -# happy flow -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 -jq .model_ipfs_hash=1 service_metadata.json >tmp.txt -mv -f tmp.txt service_metadata.json -snet service metadata-set-model ./service_spec1/ -snet service metadata-add-description --json '{"description_string":"string1","description_int":1,"description_dict":{"a":1,"b":"s"}}' -snet service metadata-add-description --json '{"description_string":"string1","description_int":1,"description_dict":{"a":1,"b":"s"}}' --description "description" --url "http://127.0.0.1" -cat service_metadata.json | jq '.service_description.url' | grep "http://127.0.0.1" -snet service metadata-add-description --url "http://127.0.0.2" -cat service_metadata.json | jq '.service_description.url' | grep "http://127.0.0.2" -snet service metadata-add-description --json '{"description":"s"}' --description "description" && exit 1 || echo "fail as expected" -snet service metadata-add-description --json '{"url":"http://127.0.0.1"}' --url "http://127.0.0.2" && exit 1 || echo "fail as expected" - -#seconf argument is group_id should be removed -snet service metadata-add-group group2 -snet service metadata-add-endpoints group1 8.8.8.8:2020 9.8.9.8:8080 -snet service metadata-add-endpoints group2 8.8.8.8:22 1.2.3.4:8080 -grep "8.8.8.8:2020" service_metadata.json -snet service metadata-remove-all-endpoints group2 -grep "8.8.8.8:22" service_metadata.json && exit 1 || echo "fail as expected" -snet service metadata-remove-all-endpoints group1 -snet service metadata-add-endpoints group1 8.8.8.8:2020 9.8.9.8:8080 -snet service metadata-add-endpoints group2 8.8.8.8:22 1.2.3.4:8080 -snet --print-traceback service metadata-update-endpoints group2 8.8.8.8:23456 1.2.3.4:22 -grep "8.8.8.8:23456" service_metadata.json -grep "8.8.8.8:2020" service_metadata.json -grep "9.8.9.8:8080" service_metadata.json -grep "8.8.8.8:22" service_metadata.json && exit 1 || echo "fail as expected" -grep "1.2.3.4:8080" service_metadata.json && exit 1 || echo "fail as expected" - -snet service metadata-set-fixed-price group1 0.0001 - -# test --endpoints and --fixed-price options in 'snet service metadata-init' -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 --fixed-price 0 --endpoints 8.8.8.8:2020 9.8.9.8:8080 --metadata-file service_metadata2.json -grep fixed_price service_metadata2.json -snet service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 9.8.9.8:8080 --metadata-file service_metadata2.json -grep fixed_price service_metadata2.json -grep 9.8.9.8:8080 service_metadata2.json - -IPFS_HASH=$(snet service publish-in-ipfs) -echo $IPFS_HASH -ipfs cat $IPFS_HASH >service_metadata2.json - -# compare service_metadata.json and service_metadata2.json -cmp <(jq -S . service_metadata.json) <(jq -S . service_metadata2.json) -snet organization metadata-init org1 testo individual -grep org1 organization_metadata.json -snet organization create testo && exit 1 || echo "fail as expected" -# -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 -grep 5.5.6.7 organization_metadata.json -grep 0x42A605c07EdE0E1f648aB054775D6D4E38496144 organization_metadata.json -grep 5.5.6.7:8089 organization_metadata.json -snet --print-traceback organization create testo -y -snet organization print-metadata org1 testo >organization_metadata_print.json - -snet service metadata-add-tags tag1 tag2 tag3 -grep "tag1" service_metadata.json -grep "tag2" service_metadata.json -grep "tag3" service_metadata.json -grep "tag4" service_metadata.json && exit 1 || echo "fail as expected" - -snet service metadata-remove-tags tag2 tag1 -grep "tag2" service_metadata.json && exit 1 || echo "fail as expected" -grep "tag1" service_metadata.json && exit 1 || echo "fail as expected" -grep "tag3" service_metadata.json - -snet service publish testo tests -y -q -snet service update-add-tags testo tests tag1 tag2 tag3 -y -q -snet service update-remove-tags testo tests tag2 tag1 -y -q -snet service print-tags testo tests - -# it should have only tag3 now -cmp <(echo "tag3") <(snet service print-tags testo tests) - -snet service print-metadata testo tests >service_metadata3.json - -# compare service_metadata.json and service_metadata3.json -cmp <(jq -S . service_metadata.json) <(jq -S . service_metadata3.json) - -# test get_api_registry and -snet service get-api-registry testo tests _d1 -snet service get-api-metadata --metadata-file service_metadata3.json _d2 - -# as usual, by default it is metatada_file=service_metadata.json -snet service get-api-metadata _d3 - -cmp ./service_spec1/ExampleService.proto _d1/ExampleService.proto -cmp ./service_spec1/ExampleService.proto _d2/ExampleService.proto -cmp ./service_spec1/ExampleService.proto _d3/ExampleService.proto - -rm -r _d1 _d2 _d3 - -# client side -snet account balance -snet account deposit 123456 -y -q -snet account transfer 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 42 -y -q -snet account withdraw 1 -y -q - -#open channel usig org and group -snet --print-traceback channel open-init-metadata testo group1 42 1 -y -q -snet channel print-initialized -snet channel claim-timeout 0 -y -q -snet channel print-initialized -# we do not send transaction second time -snet channel claim-timeout 0 -y -q && exit 1 || echo "fail as expected" - -snet channel extend-add 0 --expiration 10000 --amount 42 -y -q -snet channel print-initialized -snet channel extend-add 0 --amount 42 -y -q -snet channel print-initialized -snet channel extend-add 0 --expiration +10000blocks -y -q -snet channel extend-add 0 --expiration +10000days -y -q && exit 1 || echo "fail as expected" -snet channel extend-add 0 --expiration +10000days --force -y -q -snet channel extend-add 0 --expiration 57600000 --force -y -q && exit 1 || echo "fail as expected" - -EXPIRATION1=$(($(snet channel block-number) + 57600000)) -snet channel extend-add 0 --expiration $EXPIRATION1 --force --amount 0 -y -q - -snet channel open-init testo group1 9712.1234 +14days -y -q - -# test print_initialized_channels and print_all_channels. We should have channels openned for specific identity -snet channel print-initialized -snet --print-traceback channel print-initialized | grep 84 -snet channel print-all-filter-sender | grep 0x42A605c07EdE0E1f648aB054775D6D4E38496144 - -# we have two initilized channels one for group1 and anther for group1 (recipient=0x42A605c07EdE0E1f648aB054775D6D4E38496144) - -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --group-name group2 --fixed-price 0.0001 --endpoints 8.8.8.8:2020 --metadata-file service_metadata2.json -grep "8.8.8.8:2020" service_metadata2.json -snet service metadata-update-endpoints group2 8.8.8.8:2025 --metadata-file service_metadata2.json -grep "8.8.8.8:2025" service_metadata2.json -grep "8.8.8.8:2020" service_metadata2.json && exit 1 || echo "fail as expected" - -snet service publish testo tests2 -y -q --metadata-file service_metadata2.json - -snet channel open-init testo group2 7234.345 1 -y -q --signer 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB - -snet --print-traceback channel print-initialized-filter-org testo group2 -snet channel print-initialized-filter-org testo group2 | grep 7234.345 -snet channel print-initialized-filter-org testo group2 | grep 9712.1234 && exit 1 || echo "fail as expected" - -snet channel print-initialized -snet channel print-initialized | grep 84 -snet channel print-initialized | grep 7234.345 - -snet channel print-initialized --only-id -snet channel print-initialized --only-id | grep 7234.345 && exit 1 || echo "fail as expected" - -snet channel print-initialized --filter-signer | grep 7234.345 && exit 1 || echo "fail as expected" -snet channel print-initialized --filter-signer --wallet-index 1 | grep 7234.345 - -snet channel print-initialized-filter-org testo group2 -snet channel print-initialized-filter-org testo group2 | grep 7234.345 - -rm -rf ~/.snet/mpe_client/ - -# snet shoundn't try to open new channels. He simply should reinitilize old ones -snet channel open-init testo group1 0 0 -y -q -snet channel open-init testo group2 0 0 -y -q -snet channel open-init testo group2 0 0 --signer 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB -y -q -snet channel print-initialized | grep 7234.345 -snet channel print-initialized | grep 84 -snet channel open-init-metadata testo group2 0 0 - -rm -rf ~/.snet/mpe_client/ -# this should open new channel instead of using old one -snet channel open-init testo group2 111222 1 --open-new-anyway -yq -snet channel print-initialized | grep 9712.1234 && exit 1 || echo "fail as expected" -snet channel print-initialized-filter-org testo group2 | grep 111222 - -rm -rf ~/.snet/mpe_client/ - -snet --print-traceback channel print-all-filter-group testo group2 -snet channel print-all-filter-sender -snet channel print-all-filter-recipient - -#Uncomment this when all testing is done -#snet channel print-all-filter-sender | grep 0x42A605c07EdE0E1f648aB054775D6D4E38496144 -# -#snet channel print-all-filter-recipient | grep 0x52653A9091b5d5021bed06c5118D24b23620c529 && exit 1 || echo "fail as expected" -#snet channel print-all-filter-recipient --wallet-index 9 |grep 0x52653A9091b5d5021bed06c5118D24b23620c529 -#snet channel print-all-filter-recipient --recipient 0x52653A9091b5d5021bed06c5118D24b23620c529 |grep 0x52653A9091b5d5021bed06c5118D24b23620c529 -# -#snet channel print-all-filter-group testo group2 | grep 0x52653A9091b5d5021bed06c5118D24b23620c529 -#snet channel print-all-filter-group testo group2 | grep 0x42A605c07EdE0E1f648aB054775D6D4E38496144 && exit 1 || echo "fail as expected" -# -#snet channel print-all-filter-group testo group2 |grep 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 -# -#snet channel print-all-filter-group-sender testo group2 | grep 0x52653A9091b5d5021bed06c5118D24b23620c529 -#snet channel print-all-filter-group-sender testo group2 | grep 0x42A605c07EdE0E1f648aB054775D6D4E38496144 && exit 1 || echo "fail as expected" - -# should fail because of wrong groupId -snet channel init-metadata testo metadata-tests 0 --metadata-file service_metadata2.json && exit 1 || echo "fail as expected" -snet channel init testo wrong_group_name 1 && exit 1 || echo "fail as expected" - -snet --print-traceback channel init-metadata testo group1 1 -snet --print-traceback channel init testo group2 1 -snet channel print-initialized -snet channel print-all-filter-sender -snet service delete testo tests -y -q -snet organization list-services testo - -# open channel with sender=signer=0x32267d505B1901236508DcDa64C1D0d5B9DF639a - -snet account transfer 0x32267d505B1901236508DcDa64C1D0d5B9DF639a 1 -y -q -snet channel open-init testo group2 1 314156700003452 --force -y -q --wallet-index 3 -snet channel print-all-filter-sender --sender 0x32267d505B1901236508DcDa64C1D0d5B9DF639a | grep 314156700003452 -snet channel print-all-filter-sender | grep 314156700003452 && exit 1 || echo "fail as expected" - -snet channel print-all-filter-group-sender testo group2 --sender 0x32267d505B1901236508DcDa64C1D0d5B9DF639a | grep 314156700003452 -snet organization list-services testo -# test migration to different network - -# get service metadata from registry and set mpe_address to wrong value -snet service print-metadata testo tests2 | jq '.mpe_address = "0x52653A9091b5d5021bed06c5118D24b23620c529"' >service_metadata.json - -# this should fail because of wrong mpe_address -snet service publish-in-ipfs && exit 1 || echo "fail as expected" - -snet service publish-in-ipfs --multipartyescrow-at 0x52653A9091b5d5021bed06c5118D24b23620c529 -snet service publish-in-ipfs && exit 1 || echo "fail as expected" -snet service publish-in-ipfs --update-mpe-address -snet --print-traceback service publish-in-ipfs - -snet --print-traceback service print-metadata testo tests2 | jq '.mpe_address = "0x52653A9091b5d5021bed06c5118D24b23620c529"' >service_metadata.json - -# this should fail because of wrong mpe_address -snet service publish testo tests4 && exit 1 || echo "fail as expected" - -snet --print-traceback service publish testo tests4 --multipartyescrow-at 0x52653A9091b5d5021bed06c5118D24b23620c529 -yq -snet service publish testo tests5 -yq && exit 1 || echo "fail as expected" -snet service publish testo tests6 --update-mpe-address -yq -snet service publish testo tests7 -yq - -# test snet service update-metadata -snet service metadata-add-group group1 -#group already added -snet service metadata-add-group group2 && exit 1 || echo "fail as expected" -snet service metadata-add-endpoints group1 8.8.8.8:22 1.2.3.4:8080 -snet service update-metadata testo tests7 -y - - -#testcase for updating fixed price -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 --fixed-price 0.01212 --endpoints 8.8.8.8:2020 9.8.9.8:8080 --metadata-file service_metadata_fixed_price.json -grep "1212000" service_metadata_fixed_price.json -snet service metadata-set-fixed-price group1 0.2323 --metadata-file service_metadata_fixed_price.json -grep "23230000" service_metadata_fixed_price.json diff --git a/snet/cli/test/functional_tests/script2_deposit_transfer.sh b/snet/cli/test/functional_tests/script2_deposit_transfer.sh deleted file mode 100755 index 806ea007..00000000 --- a/snet/cli/test/functional_tests/script2_deposit_transfer.sh +++ /dev/null @@ -1,24 +0,0 @@ -# test deposit and transfer functions in snet client - -# initial balance should be 0 -MPE_BALANCE=$(snet account balance|grep MPE) -test ${MPE_BALANCE##*:} = "0" - -snet account deposit 12345.678 -y -q - -MPE_BALANCE=$(snet account balance|grep MPE) -test ${MPE_BALANCE##*:} = "12345.678" - -snet account transfer 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 42.314 -y -q - -MPE_BALANCE=$(snet account balance --account 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18|grep MPE) -test ${MPE_BALANCE##*:} = "42.314" - - -MPE_BALANCE=$(snet account balance|grep MPE) -test ${MPE_BALANCE##*:} = "12303.364" - - -snet account withdraw 1.42 -y -q -MPE_BALANCE=$(snet account balance|grep MPE) -test ${MPE_BALANCE##*:} = "12301.944" diff --git a/snet/cli/test/functional_tests/script3_without_addresses.sh b/snet/cli/test/functional_tests/script3_without_addresses.sh deleted file mode 100755 index 6ed4c927..00000000 --- a/snet/cli/test/functional_tests/script3_without_addresses.sh +++ /dev/null @@ -1,77 +0,0 @@ -# service side -# check how snet-cli works if we pass contract address via command line interface - -# remove networks -rm -rf ../../snet/snet_cli/resources/contracts/networks/*.json - -#unset addresses -snet unset current_singularitynettoken_at || echo "could fail if hasn't been set (it is ok)" -snet unset current_registry_at || echo "could fail if hasn't been set (it is ok)" -snet unset current_multipartyescrow_at || echo "could fail if hasn't been set (it is ok)" - -# now snet-cli will work only if we pass contract addresses as commandline arguments - -# this should fail without addresses -snet account balance && exit 1 || echo "fail as expected" -snet organization create testo --org-id testo -y -q && exit 1 || echo "fail as expected" - -snet --print-traceback organization metadata-init org1 testo individual --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 -snet --print-traceback organization create testo -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 - -snet service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet service metadata-add-group group2 -snet service metadata-add-endpoints group1 8.8.8.8:2020 9.8.9.8:8080 -snet service metadata-add-endpoints group2 8.8.8.8:22 1.2.3.4:8080 -snet service metadata-set-fixed-price group1 0.0001 -snet service metadata-set-fixed-price group2 0.0001 - -snet service metadata-add-tags tag1 tag2 tag3 -grep "tag1" service_metadata.json -grep "tag2" service_metadata.json -grep "tag3" service_metadata.json -grep "tag4" service_metadata.json && exit 1 || echo "fail as expected" - -snet service metadata-remove-tags tag2 tag1 -grep "tag2" service_metadata.json && exit 1 || echo "fail as expected" -grep "tag1" service_metadata.json && exit 1 || echo "fail as expected" -grep "tag3" service_metadata.json - -IPFS_HASH=$(snet service publish-in-ipfs --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e) -ipfs cat $IPFS_HASH >service_metadata2.json - -# compare service_metadata.json and service_metadata2.json -cmp <(jq -S . service_metadata.json) <(jq -S . service_metadata2.json) - -snet service publish testo tests -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet service update-add-tags testo tests tag1 tag2 tag3 -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet service update-remove-tags testo tests tag2 tag1 -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet service print-tags testo tests --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet organization list --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -# it should have only tag3 now -cmp <(echo "tag3") <(snet service print-tags testo tests --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2) - -snet service print-metadata testo tests --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 | grep -v "We must check that hash in IPFS is correct" >service_metadata3.json - -# compare service_metadata.json and service_metadata3.json -cmp <(jq -S . service_metadata.json) <(jq -S . service_metadata3.json) - -# client side -snet account balance --snt 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet account deposit 12345 -y -q --snt 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet account transfer 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 42 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet account withdraw 1 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet channel open-init-metadata testo group1 42 1 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel claim-timeout 0 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet channel extend-add 0 --expiration 10000 --amount 42 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet channel open-init testo group2 1 1000000 -y -q --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel print-initialized --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel print-all-filter-sender --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -rm -rf ~/.snet/mpe_client/ -snet channel init-metadata testo group1 0 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel init testo group1 1 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel print-initialized --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e --registry 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet channel print-all-filter-sender --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet service delete testo tests -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet organization list-services testo --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 diff --git a/snet/cli/test/functional_tests/script4_only_with_networks.sh b/snet/cli/test/functional_tests/script4_only_with_networks.sh deleted file mode 100755 index 753131a1..00000000 --- a/snet/cli/test/functional_tests/script4_only_with_networks.sh +++ /dev/null @@ -1,96 +0,0 @@ -# We try to get config address from the differnt sources. -# The order of priorioty is following: -# - command line argument (at or _at) -# - current session configuration (current__at) -# - networks/*json - -# In this test we check this priority - -rm -rf ../../snet/snet_cli/resources/contracts/networks/*.json - -#unset addresses -snet unset current_singularitynettoken_at || echo "could fail if hasn't been set (it is ok)" -snet unset current_registry_at || echo "could fail if hasn't been set (it is ok)" -snet unset current_multipartyescrow_at || echo "could fail if hasn't been set (it is ok)" -snet session -# this should fail without addresses -snet account balance && exit 1 || echo "fail as expected" -snet --print-traceback organization metadata-init org1 testo individual && exit 1 || echo "fail as expected" -snet organization create testo testo -y -q && exit 1 || echo "fail as expected" - -# set networks -echo '{"829257324":{"events":{},"links":{},"address":"0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/MultiPartyEscrow.json -echo '{"829257324":{"events":{},"links":{},"address":"0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/Registry.json -echo '{"829257324":{"events":{},"links":{},"address":"0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/SingularityNetToken.json - -# this should work -snet account balance -snet --print-traceback organization metadata-init org1 testo individual -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 -snet organization create testo -y -q -snet organization delete testo -y -q - -# this should fail (addresses are INVALID) -snet organization create testo -y -q --registry-at 0x1e74fefa82e83e0964f0d9f53c68e03f7298a8b2 && exit 1 || echo "fail as expected" -snet account balance --snt 0x1e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e && exit 1 || echo "fail as expected" - -# set INVALID addresses -snet set current_singularitynettoken_at 0x1e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 -snet set current_registry_at 0x1e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet set current_multipartyescrow_at 0x1c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e - -# this should fail because INVALID address -snet account balance && exit 1 || echo "fail as expected" -snet --print-traceback organization metadata-init org1 testo individual && exit 1 || echo "fail as expected" -snet organization create testo -y -q && exit 1 || echo "fail as expected" - -# this should work because command line has more priority -snet account balance --snt 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet --print-traceback organization metadata-init org1 testo individual --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 - -snet organization create testo -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet organization delete testo -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 - -# set INVALID networks -echo '{"829257324":{"events":{},"links":{},"address":"0x1c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/MultiPartyEscrow.json -echo '{"829257324":{"events":{},"links":{},"address":"0x1e74fefa82e83e0964f0d9f53c68e03f7298a8b2","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/Registry.json -echo '{"829257324":{"events":{},"links":{},"address":"0x1e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14","transactionHash":""}}' >../../snet/snet_cli/resources/contracts/networks/SingularityNetToken.json - -# this should fail (because addresses in networks are invalid ) -snet account balance && exit 1 || echo "fail as expected" -snet --print-traceback organization metadata-init org1 testo individual && exit 1 || echo "fail as expected" -snet organization create testo -y -q && exit 1 || echo "fail as expected" - -# set VALID session -snet set current_singularitynettoken_at 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 -snet set current_registry_at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet set current_multipartyescrow_at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e - -# this should work -snet account balance -snet --print-traceback organization metadata-init org1 testo individual -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 -snet organization create testo -y -q -snet organization delete testo -y -q - -# set INVALID addresses -snet set current_singularitynettoken_at 0x1e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 -snet set current_registry_at 0x1e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet set current_multipartyescrow_at 0x1c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e - -# this should fail (because addresses in networks are invalid ) -snet account balance && exit 1 || echo "fail as expected" -snet --print-traceback organization metadata-init org1 testo individual && exit 1 || echo "fail as expected" -snet organization create testo -y -q && exit 1 || echo "fail as expected" - -# this should work because command line has more priority -snet account balance --snt 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 --mpe 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e -snet --print-traceback organization metadata-init org1 testo individual --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet --print-traceback organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet --print-traceback organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet organization create testo -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -snet organization delete testo -y -q --registry-at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 diff --git a/snet/cli/test/functional_tests/script5_identity1_rpc_mnemonic.sh b/snet/cli/test/functional_tests/script5_identity1_rpc_mnemonic.sh deleted file mode 100755 index e6126425..00000000 --- a/snet/cli/test/functional_tests/script5_identity1_rpc_mnemonic.sh +++ /dev/null @@ -1,73 +0,0 @@ -# test itentities managment. - -# This is first and second ganache identity -A0=0x592E3C0f3B038A0D673F19a18a773F993d4b2610 -A1=0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB - -assert_mpe_balance () { - MPE_BALANCE=$(snet account balance --account $1 |grep MPE) - test ${MPE_BALANCE##*:} = $2 -} - - -# this should fail because snet-user should be in use now -snet identity delete snet-user && exit 1 || echo "fail as expected" - -snet identity create key0 key --private-key 0xc71478a6d0fe44e763649de0a0deb5a080b788eefbbcf9c6f7aef0dd5dbd67e0 --network local - -snet identity create rpc0 rpc --network local -snet identity rpc0 - -# switch to main net (rpc0 is bind to the local network!) -snet network mainnet -snet account balance && exit 1 || echo "fail as expected" -snet network local - - -snet account deposit 100 -y -assert_mpe_balance $A0 100 - -# A0 -> A1 42 -snet account transfer $A1 42 -y -assert_mpe_balance $A1 42 - -snet identity create rpc1 rpc --network local --wallet-index 1 -snet identity rpc1 - -# A1 -> A0 1 -snet account transfer $A0 1 -y -assert_mpe_balance $A1 41 - -# A0 -> A1 2 -snet account transfer $A1 2 --wallet-index 0 -y -assert_mpe_balance $A1 43 - -snet identity create mne0 mnemonic --network local --mnemonic "a b c d" -snet identity mne0 -M0=`snet account print` -M1=`snet account print --wallet-index 1` - -snet identity create mne1 mnemonic --wallet-index 1 --network local --mnemonic "a b c d" -snet identity mne1 -M11=`snet account print` - -test $M1 = $M11 - -snet identity rpc0 - -# A0 -> M1 0.1 -snet account transfer $M1 0.1 -y -assert_mpe_balance $M1 0.1 - -# A0 -> M1 0.2 -snet identity key0 -snet account transfer $M1 0.1 -y -assert_mpe_balance $M1 0.2 - -snet identity snet-user -snet identity delete rpc0 -snet identity rpc0 && exit 1 || echo "fail as expected" - -snet identity delete rpc1 -snet identity delete mne0 -snet identity delete mne1 diff --git a/snet/cli/test/functional_tests/script6_organization.sh b/snet/cli/test/functional_tests/script6_organization.sh deleted file mode 100755 index 6bc1e2d2..00000000 --- a/snet/cli/test/functional_tests/script6_organization.sh +++ /dev/null @@ -1,104 +0,0 @@ -# Test "snet organization" - -snet organization metadata-init org1 testo individual -snet organization add-group group1 0x42A605c07EdE0E1f648aB054775D6D4E38496144 5.5.6.7:8089 -snet organization add-group group2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 1.2.1.1:8089 -snet organization create test0 -y -q - -# fail to create organization with the same id -snet organization create test0 -y -q && exit 1 || echo "fail as expected" - -## check if this feature is required --org-id and --auto are mutually exclusive -snet organization create test1 --org-id test1 --auto -y -q && exit 1 || echo "fail as expected" - -## create organization with random id -snet organization create test0 --auto -y -q && exit 1 || echo "fail as expected" - -snet organization create test1 --members 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB -y -q -snet organization create test2 --members 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB,0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 -y -q -snet organization add-members test2 0x32267d505B1901236508DcDa64C1D0d5B9DF639a -y -snet organization add-members test2 0x5c1011aB3C7f46EC5E78073D61DF6d002983F04a,0x42A605c07EdE0E1f648aB054775D6D4E38496144 -y -snet organization add-members test2 0x5c1011aB3C7f46EC5E78073D61DF6d002983F04a,0x42A605c07EdE0E1f648aB054775D6D4E38496144 -y | grep "No member was added" -snet organization add-members test2 0x5c1011aB3C7f46EC5E78073D61DF6d002983F04a,0x42A605c07EdE0E1f648aB054775D6D4E38496144,0xc990EEAad8c943E3C6bA4cbcd8a54a949Fb83f78 -y - -snet --print-traceback service metadata-init ./service_spec1/ ExampleService --encoding json --service-type jsonrpc --group-name group1 -snet service metadata-add-endpoints group1 8.8.8.8:22 1.2.3.4:8080 -snet service metadata-set-fixed-price group1 0.0001 -snet service publish test2 tests -y -q -snet service publish test2 tests2 -y -q -snet organization info test2 - -snet organization rem-members test2 0x32267d505B1901236508DcDa64C1D0d5B9DF639a,0x5c1011aB3C7f46EC5E78073D61DF6d002983F04a -y -snet organization rem-members test2 0x42A605c07EdE0E1f648aB054775D6D4E38496144 -y -snet organization rem-members test2 0x42A605c07EdE0E1f648aB054775D6D4E38496144,0xc990EEAad8c943E3C6bA4cbcd8a54a949Fb83f78 -y - -# second time shoudn't remove -snet organization rem-members test2 0x42A605c07EdE0E1f648aB054775D6D4E38496144,0xc990EEAad8c943E3C6bA4cbcd8a54a949Fb83f78 -y 2>&1 | grep "No member was removed" - -snet organization list -snet organization list-org-names -# test2 should be found here -snet organization list-my | grep test2 -snet organization info test2 - -snet --print-traceback organization metadata-add-assets ./service_spec1/test hero_image -result=$(< organization_metadata.json jq '.assets.hero_image') -test $result = '"QmWQhwwnvK4YHvEarEguTDhz8o2kwvyfPhv5favs1VS4xm/test"' && echo "add asset with single value test case passed " || exit 1 - -#remove assets -snet --print-traceback organization metadata-remove-assets hero_image -test "$(< organization_metadata.json jq '.assets.hero_image')" = '""' && echo "metadata-remove-assets test case passed " || exit 1 - -snet --print-traceback organization metadata-remove-all-assets -test "$(< organization_metadata.json jq '.assets')" = '{}' && echo "metadata-remove-all-assets test case passed " || exit 1 - -# description test -snet --print-traceback organization metadata-add-description --description "this is the dummy description of my org" \ ---short-description "this is short description" --url "dummy.com" - -(test "$(< organization_metadata.json jq '.description.description')" = '"this is the dummy description of my org"' \ -&& test "$(< organization_metadata.json jq '.description.short_description')" = '"this is short description"' \ -&& test "$(< organization_metadata.json jq '.description.url')" = '"dummy.com"' \ -&& echo "passed") || exit 1 - -# contacts test -# add contact -snet --print-traceback organization metadata-add-contact support --email dummy@dummy.io --phone 1234567890 -(test "$(< organization_metadata.json jq '.contacts | length')" = 1 \ -&& test "$(< organization_metadata.json jq '.contacts[0].contact_type')" = '"support"' \ -&& test "$(< organization_metadata.json jq '.contacts[0].phone')" = '"1234567890"' \ -&& test "$(< organization_metadata.json jq '.contacts[0].email_id')" = '"dummy@dummy.io"' \ -&& echo "passed") || exit 1 - -# add contact without email and phone -test "$(snet --print-traceback organization metadata-add-contact support)" = "email and phone both can not be empty" \ -|| exit 1 - -# remove contact by type -snet --print-traceback organization metadata-add-contact support --email support@dummy.io --phone 0987654321 -snet --print-traceback organization metadata-add-contact dummy --email dummy@dummy.io --phone 6789012345 -snet --print-traceback organization metadata-remove-contacts dummy -test "$(< organization_metadata.json jq '.contacts | length')" = 2 && echo "passed" || exit 1 - -# remove all contacts -snet --print-traceback organization metadata-remove-all-contacts -test "$(< organization_metadata.json jq '.contacts | length')" = 0 && echo "passed" || exit 1 - -## change test2 organization name to NEW_TEST2_NAME -#snet organization change-name test2 NEW_TEST2_NAME -y -#snet organization change-name test2 NEW_TEST2_NAME -y && exit 1 || echo "fail as expected" -## change test2 organization name back to test2 -#snet organization change-name test2 test2 -y - -snet organization change-owner test2 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB -y -snet organization change-owner test2 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB -y && exit 1 || echo "fail as expected" -snet organization add-members test2 0x32267d505B1901236508DcDa64C1D0d5B9DF639a -y && exit 1 || echo "fail as expected" - -# this should work because owner is the second account -snet organization add-members test2 0x32267d505B1901236508DcDa64C1D0d5B9DF639a --wallet-index 1 -y - -snet organization delete test2 -y && exit 1 || echo "fail as expected" - -snet organization delete test2 --wallet-index 1 -y - -snet organization info test2 || echo "fail as expected" diff --git a/snet/cli/test/functional_tests/script7_contracts.sh b/snet/cli/test/functional_tests/script7_contracts.sh deleted file mode 100644 index 28fd3f15..00000000 --- a/snet/cli/test/functional_tests/script7_contracts.sh +++ /dev/null @@ -1,31 +0,0 @@ -# Test "snet contracts" - -snet contract Registry --at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 createOrganization ExampleOrganization1 ExampleOrganization1 '["0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB"]' --transact -y -snet contract Registry createOrganization ExampleOrganization2 ExampleOrganization2 '["0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB","0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18"]' --transact -y -snet organization list 2>&1 | grep ExampleOrganization1 -snet organization list 2>&1 | grep ExampleOrganization2 - -# organization ExampleOrganization2 should alread have two given members -snet organization add-members ExampleOrganization2 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB,0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 -y 2>&1 | grep "No member was added" - -# deposit 1000000 cogs to MPE from the first address (0x592E3C0f3B038A0D673F19a18a773F993d4b2610) -snet contract SingularityNetToken --at 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 approve 0x5C7a4290F6F8FF64c69eEffDFAFc8644A4Ec3a4E 1000000 --transact -y -snet contract MultiPartyEscrow --at 0x5C7a4290F6F8FF64c69eEffDFAFc8644A4Ec3a4E deposit 1000000 --transact -y - -# deposit 1000000 cogs to MPE from the first address (0x592E3C0f3B038A0D673F19a18a773F993d4b2610) -snet contract SingularityNetToken approve 0x5C7a4290F6F8FF64c69eEffDFAFc8644A4Ec3a4E 1000000 --transact -y -snet contract MultiPartyEscrow deposit 1000000 --transact -y - -# check balance of the First account in MPE (it should be 2000000 cogs) -REZ=`snet contract MultiPartyEscrow --at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e balances 0x592E3C0f3B038A0D673F19a18a773F993d4b2610` -test $REZ = 2000000 - -# We set expiration as current_block - 1 -EXPIRATION=$((`snet channel block-number` - 1)) -snet contract MultiPartyEscrow --at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e openChannel 0x3b2b3C2e2E7C93db335E69D827F3CC4bC2A2A2cB 0x0067b427E299Eb2A4CBafc0B04C723F77c6d8a18 0 420000 $EXPIRATION --transact -y - -REZ=`snet contract MultiPartyEscrow nextChannelId` -test $REZ = 1 - -#We can immediately claim timeout because expiration was set in the past -snet contract MultiPartyEscrow --at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e channelClaimTimeout 0 --transact -y \ No newline at end of file diff --git a/snet/cli/test/functional_tests/script8_networks.sh b/snet/cli/test/functional_tests/script8_networks.sh deleted file mode 100644 index 520d29e3..00000000 --- a/snet/cli/test/functional_tests/script8_networks.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Test "snet network" - -snet network create local_bad http://localhost:8080 && exit 1 || echo "fail as expected" - -# create network without check -snet network create local_bad http://localhost:8080 --skip-check - -#switch to this network -snet network local_bad - -#switch to mainnet -snet network mainnet - -#switch to goerli -snet network goerli - diff --git a/snet/cli/test/functional_tests/script9_treasurer.sh b/snet/cli/test/functional_tests/script9_treasurer.sh deleted file mode 100644 index 638cca34..00000000 --- a/snet/cli/test/functional_tests/script9_treasurer.sh +++ /dev/null @@ -1,90 +0,0 @@ -# Test 'snet treasurer' - -# run daemon -cd simple_daemon -python test_simple_daemon.py & -DAEMON=$! -cd .. - - -snet account deposit 12345 -y -q - -# service provider has --wallet-index==9 (0x52653A9091b5d5021bed06c5118D24b23620c529) -# make two endpoints (both are actually valid) - -snet organization metadata-init org1 testo individual -snet organization add-group group0 0x52653A9091b5d5021bed06c5118D24b23620c529 5.5.6.7:8089 -snet organization create testo -y -q - - - - -snet service metadata-init ./service_spec1/ ExampleService --group-name group0 --fixed-price 0.0001 --endpoints 127.0.0.1:50051 -snet service publish testo tests -y -q - - - -assert_balance () { -MPE_BALANCE=$(snet account balance --account 0x52653A9091b5d5021bed06c5118D24b23620c529 |grep MPE) -test ${MPE_BALANCE##*:} = $1 -} - -EXPIRATION0=$((`snet channel block-number` + 100)) -EXPIRATION1=$((`snet channel block-number` + 100000)) -EXPIRATION2=$((`snet channel block-number` + 100000)) - -snet channel open-init-metadata testo group0 1 $EXPIRATION0 -yq #channe id =0 - -# add second endpoint to metadata (in order to test case with two endpoints in metadata) -snet service metadata-add-endpoints group0 localhost:50051 - -# formally we will have two open chanels (channnel_id = 1,2) for the same group (testo/group0) -snet channel open-init-metadata testo group0 1 $EXPIRATION1 -yq --open-new-anyway #channel id =1 -snet channel open-init-metadata testo group0 1 $EXPIRATION2 -yq --open-new-anyway #channel id =2 - -#low level equivalent to "snet client call testo tests0 classify {}" -snet --print-traceback client call-lowlevel testo tests group0 0 0 10000 classify {} -# should fail because nonce is incorect -snet client call-lowlevel testo tests group0 0 1 20000 classify {} && exit 1 || echo "fail as expected" -# should fail because amount is incorect -snet client call-lowlevel testo tests group0 0 0 10000 classify {} && exit 1 || echo "fail as expected" -snet client call testo tests group0 classify {} --save-response response.pb --channel-id 1 --endpoint http://127.0.0.1:50051 -y -snet client call testo tests group0 classify {} --save-field binary_field out.bin --channel-id 2 --endpoint http://localhost:50051 -y -snet client call testo tests group0 classify {} --save-field predictions out.txt --channel-id 2 -y -rm -f response.pb out.bin out.txt -snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -assert_balance 0.0004 -snet client call testo tests group0 classify {} -y --channel-id 0 -snet client call testo tests group0 classify {} -y --channel-id 1 -snet client get-channel-state 0 http://localhost:50051 -snet client get-channel-state 1 http://127.0.0.1:50051 - -# low level equivalent to "snet client call testo tests1 classify {} --channel-id 1" -snet client call-lowlevel testo tests group0 1 1 20000 classify {} - -snet client call testo tests group0 classify {} --channel-id 2 -y - -#only channel 0 should be claimed -snet treasurer claim-expired --expiration-threshold 1000 --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -assert_balance 0.0005 -snet treasurer claim 1 2 --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -assert_balance 0.0008 - -echo y | snet client call testo tests group0 classify {} --channel-id 0 -snet client call testo tests group0 classify {} --channel-id 0 -y -snet client call testo tests group0 classify {} --channel-id 1 -y -snet client call testo tests group0 classify {} --channel-id 2 -y - -# we will start claim of all channels but will not write then to blockchain -echo n | snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 && exit 1 || echo "fail as expected" -assert_balance 0.0008 - -snet client call testo tests group0 classify {} --channel-id 1 -y -snet client call testo tests group0 classify {} --channel-id 2 -y - -# and now we should claim everything (including pending payments) -snet treasurer claim-all --endpoint 127.0.0.1:50051 --wallet-index 9 -yq -assert_balance 0.0014 - -kill $DAEMON diff --git a/snet/cli/test/functional_tests/service_spec1/ExampleService.proto b/snet/cli/test/functional_tests/service_spec1/ExampleService.proto deleted file mode 100644 index 2b3cca6b..00000000 --- a/snet/cli/test/functional_tests/service_spec1/ExampleService.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -service ExampleService { - rpc classify(ClassifyRequest) returns (ClassifyResponse); -} - -message ClassifyRequest { - string image_type = 1; - string image = 2; -} - -message ClassifyResponse { - repeated string predictions = 1; - repeated float confidences = 2; - bytes binary_field = 3; -} - diff --git a/snet/cli/test/functional_tests/service_spec1/test b/snet/cli/test/functional_tests/service_spec1/test deleted file mode 100644 index 9daeafb9..00000000 --- a/snet/cli/test/functional_tests/service_spec1/test +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/snet/cli/test/utils/reset_environment.sh b/snet/cli/test/utils/reset_environment.sh deleted file mode 100755 index bbecd7e8..00000000 --- a/snet/cli/test/utils/reset_environment.sh +++ /dev/null @@ -1,61 +0,0 @@ -# This is a part of circleci functional tests -# This script does following: -# - restart ipfs -# - restart ganache and remigrate platform-contracts -# - set correct networks/*json for Registry and MultiPartyEscrow (but not for SingularityNetToken !) -# - reset .snet configuration -# - add snet-user to snet-cli with first ganache idenity - -if [ ! $1 = "--i-no-what-i-am-doing" ]; then - echo "This script is intended to be run from circleci" - exit 1 -fi - -cwd=$(pwd) - -# I. restart ipfs -ipfs shutdown || echo "supress an error" - -rm -rf ~/.ipfs -ipfs init -ipfs bootstrap rm --all -ipfs config Addresses.API /ip4/127.0.0.1/tcp/5002 -ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8081 -nohup ipfs daemon >ipfs.log 2>&1 & - -# II. restart ganache and remigrate platform-contracts -killall node || echo "supress an error" - -# cd ../platform-contracts -# nohup ./node_modules/.bin/ganache-cli --mnemonic 'gauge enact biology destroy normal tunnel slight slide wide sauce ladder produce' --networkId 829257324 >/dev/null & -# ./node_modules/.bin/truffle migrate --network local - -# III. remove old snet-cli configuration -rm -rf ~/.snet - -# IV. Configure SNET-CLI. - -# set correct ipfs endpoint -# (the new new configuration file with default values will be created automatically) -# snet set default_ipfs_endpoint http://localhost:5002 - -# Add local network and switch to it -# snet network create local http://localhost:8545 - -# swith to local network -# snet network local - -# Configure contract addresses for local network (it will not be necessary for goerli or mainnet! ) -# snet set current_singularitynettoken_at 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14 -# snet set current_registry_at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2 -# snet set current_multipartyescrow_at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e - -# Create First identity (snet-user = first ganache). -# (snet will automatically swith to this new identity) -# snet identity create snet-user rpc --network local -snet identity create --private-key "$SNET_TEST_WALLET_PRIVATE_KEY" test key --network sepolia -sed -i "s/$FORMER_SNET_TEST_INFURA_KEY/$SNET_TEST_INFURA_KEY/g" ~/.snet/config -snet session -export PYTHONPATH=$cwd -python $cwd"./snet/cli/test/functional_tests/mint/mint.py" -snet account balance diff --git a/snet/cli/test/utils/run_all_functional.sh b/snet/cli/test/utils/run_all_functional.sh deleted file mode 100755 index 2815a9cb..00000000 --- a/snet/cli/test/utils/run_all_functional.sh +++ /dev/null @@ -1,11 +0,0 @@ -for f in snet/cli/test/functional_tests/script?_* -do - bash -ex ./snet/cli/test/utils/reset_environment.sh --i-no-what-i-am-doing - bash -ex -c "cd snet/cli/test/functional_tests; bash -ex `basename $f`" -done - -for f in snet/cli/test/functional_tests/script??_* -do - bash -ex ./snet/cli/test/utils/reset_environment.sh --i-no-what-i-am-doing - bash -ex -c "cd snet/cli/test/functional_tests; bash -ex `basename $f`" -done