Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed erroneous tests (Issue # 53) #54

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ venv/*
__pycache__
/__pycache__/*
test/.secrets
.vscode
10 changes: 0 additions & 10 deletions akita_inu_asa_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions test/asa_faucet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down