-
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
Showing
11 changed files
with
205 additions
and
166 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,49 @@ | ||
import allure | ||
import iroha | ||
import pytest | ||
|
||
from tests import client, fake | ||
from tests.helpers import generate_public_key | ||
|
||
|
||
@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_new_asset_id(): | ||
"""Fixture to provide a new asset id.""" | ||
asset_name = str(len(client.query_all_assets())) + fake.word()[:3].upper() | ||
with allure.step(f'GIVEN a "{asset_name}" asset'): | ||
return asset_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 | ||
|
||
@pytest.fixture() | ||
def GIVEN_registered_domain_with_registered_accounts(GIVEN_registered_domain, GIVEN_new_account_id): | ||
"""Fixture to provide domain with accounts""" | ||
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")])])) | ||
return GIVEN_registered_domain |
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 |
Empty file.
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,32 @@ | ||
import allure | ||
import time | ||
import pytest | ||
|
||
from tests import client | ||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def story_account_register_account(): | ||
allure.dynamic.story("Account queries accounts") | ||
allure.dynamic.label("permission", "no_permission_required") | ||
|
||
@allure.label("sdk_test_id", "query_all_accounts") | ||
def test_query_all_accounts(): | ||
with allure.step('WHEN client queries all accounts'): | ||
all_accounts = client.query_all_accounts() | ||
with allure.step('THEN there should be some accounts present'): | ||
assert len(all_accounts) > 0, "No accounts found in the system" | ||
|
||
|
||
@allure.label("sdk_test_id", "query_all_accounts_in_domain") | ||
def test_query_all_accounts_in_domain( | ||
GIVEN_registered_domain_with_registered_accounts): | ||
with allure.step( | ||
f'WHEN client queries all accounts in domain "{GIVEN_registered_domain_with_registered_accounts}"'): | ||
time.sleep(3) | ||
accounts_in_domain = client.query_all_accounts_in_domain(GIVEN_registered_domain_with_registered_accounts) | ||
with allure.step( | ||
f'THEN the response should be a non-empty list of accounts in domain "{GIVEN_registered_domain_with_registered_accounts}"'): | ||
assert isinstance(accounts_in_domain, list) and accounts_in_domain, \ | ||
f"Expected a non-empty list of accounts in the domain {GIVEN_registered_domain_with_registered_accounts}, got {accounts_in_domain}" | ||
|
||
|
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,25 @@ | ||
import allure | ||
import time | ||
import pytest | ||
|
||
from tests import client | ||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def story_account_register_account(): | ||
allure.dynamic.story("Account queries assets") | ||
allure.dynamic.label("permission", "no_permission_required") | ||
|
||
@pytest.mark.xfail(reason="TO DO") | ||
@allure.label("sdk_test_id", "query_all_assets_owned_by_account") | ||
def test_query_all_assets_owned_by_account( | ||
GIVEN_registered_account_with_assets): | ||
with allure.step( | ||
f'WHEN client queries all assets owned by account "{GIVEN_registered_account_with_assets}"'): | ||
time.sleep(3) | ||
assets_owned_by_account = client.query_all_assets_owned_by_account(GIVEN_registered_account_with_assets) | ||
with allure.step( | ||
f'THEN the response should be a non-empty list of assets owned by account "{GIVEN_registered_account_with_assets}"'): | ||
assert isinstance(assets_owned_by_account, list) and assets_owned_by_account, \ | ||
f"Expected a non-empty list of assets owned by account {GIVEN_registered_account_with_assets}, got {assets_owned_by_account}" | ||
|
||
|
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,27 @@ | ||
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 | ||
from tests.helpers import generate_public_key | ||
|
||
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]) | ||
@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") | ||
|
||
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 | ||
|
||
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 | ||
|
||
@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() |
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
Oops, something went wrong.