Skip to content

Commit cf8ccc1

Browse files
committed
[SPT-777] New functional tests: service metadata daemon, endpoints
1 parent ddedf9e commit cf8ccc1

21 files changed

+57
-1284
lines changed

snet/cli/test/functional_tests/func_tests.py

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ def test_deposit(self):
117117
execute(["account", "deposit", f"{self.amount}", "-y", "-q"], self.parser, self.conf)
118118
result = execute(["account", "balance"], self.parser, self.conf)
119119
self.balance_2 = float(result.split("\n")[3].split()[1])
120-
assert round(self.balance_2, 3) == round(self.balance_1, 3) + self.amount
120+
assert round(self.balance_2, 2) == round(self.balance_1, 2) + self.amount
121121

122122
def test_withdraw(self):
123123
result = execute(["account", "balance"], self.parser, self.conf)
124124
self.balance_1 = float(result.split("\n")[3].split()[1])
125125
execute(["account", "withdraw", f"{self.amount}", "-y", "-q"], self.parser, self.conf)
126126
result = execute(["account", "balance"], self.parser, self.conf)
127127
self.balance_2 = float(result.split("\n")[3].split()[1])
128-
assert round(self.balance_2, 3) == round(self.balance_1, 3) - self.amount
128+
assert round(self.balance_2, 2) == round(self.balance_1, 2) - self.amount
129129

130130
def test_transfer(self):
131131
result = execute(["account", "transfer", ADDR, f"{self.amount}", "-y"], self.parser, self.conf)
@@ -240,26 +240,20 @@ def setUp(self):
240240
self.password = "12345"
241241
self.group = "default_group"
242242
data = execute(["channel", "print-filter-group", self.org_id, "default_group"], self.parser, self.conf)
243-
max_id = None
244-
for line in data.splitlines()[2:]:
245-
parts = line.split()
246-
if len(parts) < 7:
247-
continue
248-
249-
channel_id = int(parts[0].lstrip("#"))
250-
value = int(parts[6])
243+
lines = data.split("\n")
251244

252-
if value > 0:
253-
if max_id is None or channel_id > max_id:
254-
max_id = channel_id
255-
self.max_id = str(max_id) if max_id is not None else None
245+
for line in lines:
246+
parts = line.split()
247+
if len(parts) >= 6 and parts[0].isdigit() and parts[-1].isdigit():
248+
channel_id, expiration = parts[0], int(parts[-1])
249+
self.max_id=channel_id
256250

257251
def test_channel_1_extend(self):
258252
execute(["account", "deposit", self.amount, "-y", "-q"], self.parser, self.conf)
259253
result1 = execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf)
260-
result2 = execute(["channel", "extend-add-for-org", self.org_id, "default_group", "--channel-id", f"{self.max_id}", "-y"], self.parser, self.conf)
261-
print(result2)
262-
assert f"channelId: ", self.max_id in result1
254+
# result2 = execute(["channel", "extend-add-for-org", self.org_id, "default_group", "--channel-id", f"{self.max_id}", "-y"], self.parser, self.conf)
255+
# print(result2)
256+
assert "channelId: ", self.max_id in result1
263257

264258
def test_channel_2_print_filter_sender(self):
265259
result = execute(["channel", "print-filter-sender"], self.parser, self.conf)
@@ -270,11 +264,11 @@ def test_channel_3_print_filter_group_sender(self):
270264
result = execute(["channel", "print-filter-group-sender", self.org_id, self.group], self.parser, self.conf)
271265
assert "Channels for sender: ", ADDR in result
272266

273-
def test_channel_3_print_filter_group(self):
267+
def test_channel_4_print_filter_group(self):
274268
result = execute(["channel", "print-filter-group", self.org_id, self.group], self.parser, self.conf)
275269
assert self.max_id in result
276270

277-
def test_channel_4_claim(self):
271+
def test_channel_5_claim(self):
278272
execute(["account", "deposit", self.amount, "-y", "-q"], self.parser, self.conf)
279273
execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf)
280274
result1 = execute(["channel", "claim-timeout", f"{self.max_id}", "-y"], self.parser, self.conf)
@@ -302,13 +296,13 @@ def setUp(self):
302296
def test_0_preparations(self):
303297
identity_list=execute(["identity", "list"], self.parser, self.conf)
304298
if self.identity_name not in identity_list:
305-
execute(["identity", "create", self.identity_name, "key", "--private-key", "faaf0c972a152459d97e7267280689583aae2d1caaa518cce7e412dd13f7b3e8", "-de"], self.parser, self.conf)
299+
execute(["identity", "create", self.identity_name, "key", "--private-key", PRIVATE_KEY, "-de"], self.parser, self.conf)
306300
execute(["network", "sepolia"], self.parser, self.conf)
307301
result = execute(["session"], self.parser, self.conf)
308302
assert "network: sepolia" in result
309303

310304
def test_1_channel_open(self):
311-
execute(["set", "default_eth_rpc_endpoint", "https://sepolia.infura.io/v3/047c3c4404ef4cbc90938371a8e34604"], self.parser, self.conf)
305+
execute(["set", "default_eth_rpc_endpoint", INFURA], self.parser, self.conf)
312306
execute(["account", "deposit", "0.0001", "-y"], self.parser, self.conf)
313307
self.block=int(execute(["channel", "block-number"], self.parser, self.conf))
314308
print(self.block)
@@ -332,7 +326,7 @@ def test_3_service_get_channel_state(self):
332326
assert "current_unspent_amount_in_cogs = " in result
333327

334328
def test_4_call_low_level(self):
335-
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)
329+
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)
336330
assert "spam" in result
337331

338332
def test_5_get_api_registry(self):
@@ -374,7 +368,7 @@ def setUp(self):
374368
self.free_calls = "100"
375369
self.contributor = "Stasy"
376370
self.contributor_mail = "[email protected]"
377-
self.tags = "new", "text2text", "t2t", "punctuality"
371+
self.tags = ["new", "text2text", "t2t", "punctuality"]
378372
self.hero_image = "./img.jpg"
379373
self.contact = "author"
380374
self.email = "[email protected]"
@@ -426,20 +420,30 @@ def test_3_create_service(self):
426420
result = execute(["service", "publish", self.org_id, self.service_id, "-y"], self.parser, self.conf)
427421
assert "event: ServiceCreated" in result
428422

429-
def test_4_lists(self):
430-
result1 = execute(["organization", "list"], self.parser, self.conf)
431-
result2 = execute(["organization", "list-org-names"], self.parser, self.conf)
432-
result3 = execute(["organization", "list-my"], self.parser, self.conf)
433-
result4 = execute(["organization", "list-services", self.org_id], self.parser, self.conf)
434-
assert (self.org_id in result1) and (self.org_name in result2) and (self.org_id in result3) and (self.service_id in result4)
423+
def test_41_list(self):
424+
result = execute(["organization", "list"], self.parser, self.conf)
425+
assert self.org_id in result
426+
427+
def test_42_list_org_names(self):
428+
result = execute(["organization", "list-org-names"], self.parser, self.conf)
429+
assert self.org_name in result
430+
431+
def test_43_list_my(self):
432+
result = execute(["organization", "list-my"], self.parser, self.conf)
433+
assert self.org_id in result
434+
435+
def test_44_list_services(self):
436+
result = execute(["organization", "list-services", self.org_id], self.parser, self.conf)
437+
assert self.service_id in result
438+
435439

436440
def test_5_change_members(self):
437441
result_add = execute(["organization", "add-members", self.org_id, ADDR, "-y"], self.parser, self.conf)
438442
result_rem = execute(["organization", "rem-members", self.org_id, ADDR, "-y"], self.parser, self.conf)
439443
# result_change_owner = execute(["organization", "change-owner", self.org_id, ADDR], self.parser, self.conf)
440444
assert "event: OrganizationModified" in result_rem
441445

442-
def test_6_change_org_metadata(self):
446+
def test_61_change_org_metadata(self):
443447
hero_image = open("img.jpg", "w+")
444448
hero_image.close()
445449
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):
453457
result = execute(["organization", "print-metadata", self.org_id], self.parser, self.conf)
454458
assert self.new_description in result
455459

456-
def test_7_change_service_metadata(self):
460+
def test_62_change_service_metadata(self):
457461
execute(["service", "metadata-remove-group", self.group_name], self.parser, self.conf)
458462
execute(["service", "metadata-add-group", self.group_name], self.parser, self.conf)
459463
execute(["organization", "update-group", self.group_name], self.parser, self.conf)
464+
execute(["service", "metadata-add-daemon-addresses", self.group_name, ADDR], self.parser, self.conf)
465+
execute(["service", "metadata-remove-all-daemon-addresses", self.group_name], self.parser, self.conf)
466+
execute(["service", "metadata-update-daemon-addresses", self.group_name, ADDR], self.parser, self.conf)
467+
execute(["service", "metadata-add-endpoints", self.group_name, self.endpoint], self.parser, self.conf)
468+
execute(["service", "metadata-remove-all-endpoints", self.group_name], self.parser, self.conf)
469+
execute(["service", "metadata-add-endpoints", self.group_name, self.endpoint], self.parser, self.conf)
460470
execute(["service", "metadata-set-free-calls", self.group_name, self.free_calls], self.parser, self.conf)
461471
execute(["service", "metadata-set-freecall-signer-address", self.group_name, ADDR], self.parser, self.conf)
462472
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):
471481
execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf)
472482
execute(["service", "metadata-remove-media", "1"], self.parser, self.conf)
473483
execute(["service", "metadata-remove-all-media"], self.parser, self.conf)
474-
execute(["service", "metadata-add-tags", self.tags], self.parser, self.conf)
484+
execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf)
485+
execute(["service", "metadata-add-media", self.hero_image], self.parser, self.conf)
486+
execute(["service", "metadata-swap-media-order", "1", "2"], self.parser, self.conf)
487+
execute(["service", "metadata-change-media-order"], self.parser, self.conf)
475488
execute(["service", "update-metadata", self.org_id, self.service_id, "-y"], self.parser, self.conf)
476489
result = execute(["service", "print-metadata", self.org_id, self.service_id], self.parser, self.conf)
477490
print(execute(["service", "print-metadata", self.org_id, self.service_id], self.parser, self.conf))
478491
print(execute(["service", "print-service-status", self.org_id, self.service_id], self.parser, self.conf))
479492
assert self.contributor in result
480493

481-
def test_8_get_api_metadata(self):
494+
def test_63_tags(self):
495+
execute(["service", "metadata-add-tags", self.tags], self.parser, self.conf)
496+
execute(["service", "update-metadata", self.org_id, self.service_id, "-y"], self.parser, self.conf)
497+
print(execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf))
498+
result=execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf)
499+
print(result)
500+
assert self.tags in result
501+
502+
def test_64_get_api_metadata(self):
482503
os.remove(f"./ExampleService.proto")
483504
execute(["service", "get-api-metadata", "./"], self.parser, self.conf)
484505
assert os.path.exists(f"./ExampleService.proto")
485506

486-
def test_9_delete_service(self):
507+
def test_7_delete_service(self):
487508
result = execute(["service", "delete", self.org_id, self.service_id, "-y"], self.parser, self.conf)
488509
os.remove(f"./service_metadata.json")
489510
assert "event: ServiceDeleted" in result
490511

491-
def test_91_delete_organization(self):
492-
result=execute(["organization", "delete", self.org_id, "-y"], self.parser, self.conf)
512+
def test_8_delete_organization(self):
513+
result = execute(["organization", "delete", self.org_id, "-y"], self.parser, self.conf)
493514
os.remove(f"./organization_metadata.json")
494515
os.remove(f"img.jpg")
495516
assert "event: OrganizationDeleted" in result

snet/cli/test/functional_tests/mint/mint.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

snet/cli/test/functional_tests/script10_claim_timeout_all.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

snet/cli/test/functional_tests/script11_update_metadata.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)