-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexstroke <111361420+astrokov7@users.noreply.github.com>
- Loading branch information
1 parent
ac3d273
commit 495d3f4
Showing
8 changed files
with
141 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
python -m pytest tests | ||
maturin build | ||
poetry run python -m pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import iroha | ||
from faker import Faker | ||
|
||
key_pair = iroha.KeyPair.from_json(""" | ||
{ | ||
"public_key": "ed01207233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0", | ||
"private_key": { | ||
"digest_function": "ed25519", | ||
"payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" | ||
} | ||
} | ||
""") | ||
|
||
account_id = "alice@wonderland" | ||
web_login = "mad_hatter" | ||
password = "ilovetea" | ||
api_url = "http://127.0.0.1:8080/" | ||
telemetry_url = "http://127.0.0.1:8180/" | ||
|
||
client = iroha.Client.create( | ||
key_pair, | ||
account_id, | ||
web_login, | ||
password, | ||
api_url) | ||
|
||
fake = Faker() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import allure | ||
import iroha | ||
import pytest | ||
|
||
from tests import client, fake | ||
|
||
|
||
@pytest.fixture() | ||
def GIVEN_new_domain_id(): | ||
"""Fixture to provide a new fake domain id.""" | ||
name = str(len(client.query_all_domains()))+fake.word() | ||
with allure.step(f'GIVEN a "{name}" name'): | ||
return name | ||
|
||
@pytest.fixture() | ||
def GIVEN_new_account_id(GIVEN_registered_domain): | ||
"""Fixture to provide a new fake account id.""" | ||
name = str(len(client.query_all_accounts())) + fake.word() + '@' + GIVEN_registered_domain | ||
with allure.step(f'GIVEN a "{name}" name'): | ||
return name | ||
|
||
@pytest.fixture() | ||
def GIVEN_registered_domain(GIVEN_new_domain_id): | ||
"""Fixture to provide registered domain in Iroha""" | ||
with allure.step(f'GIVEN registered domain name "{GIVEN_new_domain_id}"'): | ||
(client.submit_executable( | ||
[iroha.Instruction | ||
.register_domain(GIVEN_new_domain_id)])) | ||
return GIVEN_new_domain_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import iroha | ||
|
||
def generate_public_key(seed="abcd1122"): | ||
|
||
""" | ||
Generate a public key using Ed25519PrivateKey. | ||
""" | ||
return iroha.KeyGenConfiguration.default().use_seed_hex(seed).generate().public_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,58 @@ | ||
import allure | ||
import iroha | ||
import time | ||
import pytest | ||
|
||
def start_client(): | ||
key_pair = iroha.KeyPair.from_json(""" | ||
{ | ||
"public_key": "ed01207233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0", | ||
"private_key": { | ||
"digest_function": "ed25519", | ||
"payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" | ||
} | ||
} | ||
""") | ||
|
||
account_id = "alice@wonderland" | ||
web_login = "mad_hatter" | ||
password = "ilovetea" | ||
api_url = "http://127.0.0.1:8080/" | ||
telemetry_url = "http://127.0.0.1:8180/" | ||
|
||
client = iroha.Client.create( | ||
key_pair, | ||
account_id, | ||
web_login, | ||
password, | ||
api_url) | ||
return client | ||
|
||
def test_register_account(): | ||
client = start_client() | ||
|
||
new_account_key_pair = iroha.KeyGenConfiguration.default().use_seed_hex("abcd1122").generate() | ||
|
||
accounts = client.query_all_accounts_in_domain("wonderland") | ||
|
||
print("Listing all accounts in wonderland...") | ||
for a in accounts: | ||
print(" - ", a,) | ||
|
||
new_account_id = "white_rabbit_" + str(len(accounts)) + "@wonderland" | ||
|
||
assert new_account_id not in accounts | ||
|
||
register = iroha.Instruction.register_account(new_account_id, [new_account_key_pair.public_key]) | ||
|
||
client.submit_executable([register]) | ||
from tests import client | ||
from tests.helpers import generate_public_key | ||
|
||
for x in range(30): | ||
accounts = client.query_all_accounts_in_domain("wonderland") | ||
|
||
if new_account_id in accounts: | ||
break | ||
|
||
time.sleep(1) | ||
|
||
|
||
assert new_account_id in accounts | ||
@pytest.fixture(scope="function", autouse=True) | ||
def story_account_register_account(): | ||
allure.dynamic.story("Account registers an account") | ||
allure.dynamic.label("permission", "no_permission_required") | ||
|
||
@allure.label("sdk_test_id", "register_account") | ||
def test_register_account( | ||
GIVEN_new_account_id): | ||
with allure.step( | ||
f'WHEN client registers the account "{GIVEN_new_account_id}"'): | ||
(client.submit_executable( | ||
[iroha.Instruction | ||
.register_account( | ||
GIVEN_new_account_id, | ||
[generate_public_key(seed="abcd1122")])])) | ||
time.sleep(3) | ||
with allure.step( | ||
f'THEN Iroha should have the "{GIVEN_new_account_id}" account'): | ||
assert GIVEN_new_account_id in client.query_all_accounts() | ||
|
||
def test_register_account_but_use_query_all(): | ||
client = start_client() | ||
|
||
new_account_key_pair = iroha.KeyGenConfiguration.default().use_seed_hex("abcd1144").generate() | ||
|
||
accounts = client.query_all_accounts() | ||
|
||
print("Listing all accounts...") | ||
for a in accounts: | ||
print(" - ", a,) | ||
|
||
new_account_id = "white_rabbit_query_all_test_" + str(len(accounts)) + "@wonderland" | ||
|
||
assert new_account_id not in accounts | ||
|
||
register = iroha.Instruction.register_account(new_account_id, [new_account_key_pair.public_key]) | ||
|
||
client.submit_executable([register]) | ||
|
||
for x in range(30): | ||
accounts = client.query_all_accounts() | ||
|
||
if new_account_id in accounts: | ||
break | ||
|
||
time.sleep(1) | ||
|
||
|
||
assert new_account_id in accounts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,32 @@ | ||
import iroha | ||
import time | ||
|
||
def start_client(): | ||
key_pair = iroha.KeyPair.from_json(""" | ||
{ | ||
"public_key": "ed01207233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0", | ||
"private_key": { | ||
"digest_function": "ed25519", | ||
"payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" | ||
} | ||
} | ||
""") | ||
|
||
account_id = "alice@wonderland" | ||
web_login = "mad_hatter" | ||
password = "ilovetea" | ||
api_url = "http://127.0.0.1:8080/" | ||
telemetry_url = "http://127.0.0.1:8180/" | ||
|
||
client = iroha.Client.create( | ||
key_pair, | ||
account_id, | ||
web_login, | ||
password, | ||
api_url) | ||
return client | ||
|
||
def test_register_account(): | ||
client = start_client() | ||
from tests import client | ||
|
||
|
||
def test_register_asset(): | ||
assets = client.query_all_assets_owned_by_account("alice@wonderland") | ||
|
||
print("Listing all assets owned by alice@wonderland...") | ||
for a in assets: | ||
print(" - ", a,) | ||
print(" - ", a, ) | ||
|
||
asset_definition_id = "time_" + str(len(assets)) + "#wonderland" | ||
asset_id = "time_" + str(len(assets)) + "##alice@wonderland" | ||
|
||
assert asset_id not in assets | ||
|
||
register_definition = iroha.Instruction.register_asset_definition(asset_definition_id, "Quantity") | ||
|
||
mint = iroha.Instruction.mint_asset(5, asset_id, "Quantity") | ||
|
||
client.submit_executable([register_definition, mint]) | ||
|
||
for x in range(30): | ||
assets = client.query_all_assets_owned_by_account("alice@wonderland") | ||
|
||
if asset_id in assets: | ||
break | ||
|
||
time.sleep(1) | ||
|
||
|
||
|
||
assert asset_id in assets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,22 @@ | ||
import allure | ||
import iroha | ||
import time | ||
import pytest | ||
|
||
def start_client(): | ||
key_pair = iroha.KeyPair.from_json(""" | ||
{ | ||
"public_key": "ed01207233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0", | ||
"private_key": { | ||
"digest_function": "ed25519", | ||
"payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" | ||
} | ||
} | ||
""") | ||
|
||
account_id = "alice@wonderland" | ||
web_login = "mad_hatter" | ||
password = "ilovetea" | ||
api_url = "http://127.0.0.1:8080/" | ||
telemetry_url = "http://127.0.0.1:8180/" | ||
|
||
client = iroha.Client.create( | ||
key_pair, | ||
account_id, | ||
web_login, | ||
password, | ||
api_url) | ||
return client | ||
from tests import client | ||
|
||
def test_register_account(): | ||
client = start_client() | ||
@pytest.fixture(scope="function", autouse=True) | ||
def story_account_registers_domain(): | ||
allure.dynamic.story("Account registers a domain") | ||
allure.dynamic.label("permission", "no_permission_required") | ||
|
||
domains = client.query_all_domains() | ||
|
||
print("Listing all domains...") | ||
for d in domains: | ||
print(" - ", d,) | ||
|
||
domain_id = "looking_glass_" + str(len(domains)) | ||
|
||
if domain_id in domains: | ||
print("'" + domain_id +"' domain already exists.") | ||
|
||
register = iroha.Instruction.register_domain(domain_id) | ||
|
||
client.submit_executable([register]) | ||
|
||
for x in range(30): | ||
domains = client.query_all_domains() | ||
|
||
if domain_id in domains: | ||
break | ||
|
||
time.sleep(1) | ||
|
||
assert domain_id in domains | ||
|
||
@allure.label("sdk_test_id", "register_domain") | ||
def test_register_domain( | ||
GIVEN_new_domain_id): | ||
with allure.step(f'WHEN client registers the domain name "{GIVEN_new_domain_id}"'): | ||
(client.submit_executable( | ||
[iroha.Instruction | ||
.register_domain(GIVEN_new_domain_id)])) | ||
time.sleep(2) | ||
with allure.step(f'THEN Iroha should have the domain name "{GIVEN_new_domain_id}"'): | ||
assert GIVEN_new_domain_id in client.query_all_domains() |