def test_token_transfer(): test_address = Web3.toChecksumAddress( '068ed00cf0441e4829d9784fcbe7b9e26d4bd8d0') token = Token.get_instance() balance = token.get_token_balance(test_address) token.transfer(test_address, 3, consumer_account) new_balance = token.get_token_balance(test_address) assert new_balance == (balance + 3)
def test_token_allowance(): token = Token.get_instance() lock_reward_condition = LockPaymentCondition( LockPaymentCondition.CONTRACT_NAME) allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) if allowance > 0: token.decrease_allowance(lock_reward_condition.address, allowance, consumer_account) allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) assert allowance == 0 assert token.token_approve(lock_reward_condition.address, 77, consumer_account) is True allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) assert allowance == 77 assert token.token_approve(lock_reward_condition.address, 49, consumer_account) is True allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) assert allowance == 49 token.decrease_allowance(lock_reward_condition.address, 5, consumer_account) allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) assert allowance == 44 token.increase_allowance(lock_reward_condition.address, 10, consumer_account) allowance = token.get_allowance(consumer_account.address, lock_reward_condition.address) assert allowance == 54
def test_token_approve_invalid_tokens(): token = Token.get_instance() with pytest.raises(Exception): token.token_approve(consumer_account.address, -100, publisher_account)
def test_token_approve_invalid_address(): token = Token.get_instance() with pytest.raises(Exception): token.token_approve('10923019', 100, publisher_account)
def test_token_approve(): token = Token.get_instance() assert token.token_approve(consumer_account.address, 100, publisher_account)
def test_get_balance_invalid_address(): token = Token.get_instance() with pytest.raises(Exception): token.get_token_balance('not valid')
def test_get_balance(): token = Token.get_instance() assert isinstance(token.get_token_balance(consumer_account.address), int)
def test_token_contract(): token = Token.get_instance() assert token assert isinstance(token, Token)