From adc827d4933f025a676458bfea13a6fe07bbc2b2 Mon Sep 17 00:00:00 2001 From: DarbyBurbidge Date: Sat, 4 Jun 2022 11:01:22 -0700 Subject: [PATCH] fixed erroneous tests --- .gitignore | 1 + akita_inu_asa_utils.py | 10 ---------- test/asa_faucet_test.py | 14 +++++++------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 6023de4..e6e39ac 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ venv/* __pycache__ /__pycache__/* test/.secrets +.vscode \ No newline at end of file diff --git a/akita_inu_asa_utils.py b/akita_inu_asa_utils.py index 652a105..3a54c58 100644 --- a/akita_inu_asa_utils.py +++ b/akita_inu_asa_utils.py @@ -108,16 +108,6 @@ def pretty_print_state(state): print("\n\n\n") -def get_key_from_state(state, key): - for i in range(0, len(state)): - found_key = base64.b64decode(state[i]['key']) - if found_key == key: - if state[i]['value']['type'] == 1: - return base64.b64decode(state[i]['value']['bytes']) - elif state[i]['value']['type'] == 2: - return state[i]['value']['uint'] - - def dump_teal_assembly(file_path, program_fn_pointer): check_build_dir() with open('build/' + file_path, 'w') as f: diff --git a/test/asa_faucet_test.py b/test/asa_faucet_test.py index c1afb31..cb84ebd 100644 --- a/test/asa_faucet_test.py +++ b/test/asa_faucet_test.py @@ -7,7 +7,7 @@ from algosdk import account, mnemonic, constants from algosdk.encoding import encode_address, is_valid_address from algosdk.error import AlgodHTTPError, TemplateInputError -from akita_inu_asa_utils import read_local_state, read_global_state, wait_for_txn_confirmation, get_key_from_state +from akita_inu_asa_utils import read_local_state, read_global_state, wait_for_txn_confirmation from .testing_utils import clear_build_folder NUM_TEST_ASSET = int(1e6) @@ -90,10 +90,10 @@ def test_deploy(self, app_id, client, asset_id, wallet_1): public_key = wallet_1['public_key'] global_state = read_global_state(client, public_key, app_id) - assert get_key_from_state(global_state, b'asset_id_key') == asset_id - assert get_key_from_state(global_state, b'drip_time') == DRIP_TIME_SEC - assert get_key_from_state(global_state, b'min_algo_amount') == MIN_ALGO_AMOUNT - assert get_key_from_state(global_state, b'min_asset_amount') == MIN_ASA_AMOUNT + assert global_state['asset_id_key'] == asset_id + assert global_state['drip_time'] == DRIP_TIME_SEC + assert global_state['min_algo_amount'] == MIN_ALGO_AMOUNT + assert global_state['min_asset_amount'] == MIN_ASA_AMOUNT def test_opt_in(self, app_id, client, asset_id, wallet_1): from akita_inu_asa_utils import opt_in_app_signed_txn, wait_for_txn_confirmation @@ -105,7 +105,7 @@ def test_opt_in(self, app_id, client, asset_id, wallet_1): wait_for_txn_confirmation(client, txn_id, 5) local_state = read_local_state(client, public_key, app_id) - assert time.time() - 60 <= get_key_from_state(local_state, b'user_last_claim_time') <= time.time() + assert time.time() - 60 <= local_state['user_last_claim_time'] <= time.time() def test_opt_in_asset(self, app_id, client, asset_id, wallet_1): from akita_inu_asa_utils import get_application_address @@ -171,7 +171,7 @@ def test_claim(self, app_id, client, asset_id, wallet_1): local_state = read_local_state(client, public_key, app_id) assert get_asset_balance(client, public_key, asset_id) == wallet_balance_pre + DRIP_AMOUNT - assert get_key_from_state(local_state, b'user_last_claim_time') <= (time.time() + 15) + assert local_state['user_last_claim_time'] <= (time.time() + 15) def test_claim_to_soon(self, app_id, client, asset_id, wallet_1): from akita_inu_asa_utils import get_application_address