Ejemplo n.º 1
0
def test_transfer_random_tokens(multi, alice):
    random_token = ERC20()
    random_token._mint_for_testing(alice, 10**18, {"from": alice})
    random_token.transfer(multi, 10**18, {"from": alice})
    assert random_token.balanceOf(alice) == 0
    multi.recoverERC20(random_token, 10**18, {"from": alice})
    assert random_token.balanceOf(alice) == 10**18
Ejemplo n.º 2
0
def err_token(multi, reward_token, alice, bob, chain):
    err_token = ERC20()
    amount = 10 ** 18
    err_token._mint_for_testing(alice, amount, {"from": alice})
    err_token.approve(multi, amount, {"from": alice})
    err_token.transfer(multi, amount, {"from": alice})

    return err_token
Ejemplo n.º 3
0
def slow_token(multi, accounts, alice):
    slow_token = ERC20()
    amount = 10 ** 19
    slow_token._mint_for_testing(alice, amount)
    multi.addReward(slow_token, alice, 2630000, {"from": alice})
    slow_token.approve(multi, amount, {"from": alice})
    multi.setRewardsDistributor(slow_token, alice, {"from": alice})
    multi.notifyRewardAmount(slow_token, amount, {"from": alice})
    return slow_token
Ejemplo n.º 4
0
def test_n_rewards(multi, accounts, alice, base_token, chain):
    n = 5
    _tokens = {}
    for i in range(n):
        _tokens[i] = ERC20()
        _tokens[i]._mint_for_testing(accounts[i], 10**18)
        _tokens[i].approve(multi, 10**18, {"from": accounts[i]})
        base_token.approve(multi, 10**18, {"from": accounts[i]})

        multi.addReward(_tokens[i], accounts[i], 60, {"from": alice})
        multi.setRewardsDistributor(_tokens[i], accounts[i], {"from": alice})
        multi.notifyRewardAmount(_tokens[i], 10**10, {"from": accounts[i]})
        multi.stake(10000, {"from": accounts[i]})

    chain.mine(timedelta=120)
    for i in range(5):
        assert multi.earned(accounts[i], _tokens[i]) > 0
Ejemplo n.º 5
0
def test_only_owner_can_call(multi, alice, bob):
    token = ERC20()
    with brownie.reverts("Only the contract owner may perform this action"):
        multi.addReward(token, alice, 60, {"from": bob})
Ejemplo n.º 6
0
def test_reward_per_token_zero_supply(multi, alice):
    token = ERC20()
    multi.addReward(token, alice, 60, {"from": alice})
    assert multi.rewardPerToken(token) == 0
Ejemplo n.º 7
0
def test_rewards_properties_set(multi, alice, bob):
    token = ERC20()
    multi.addReward(token, alice, 60, {"from": alice})
    assert multi.rewardData(token)["rewardsDuration"] == 60
    assert multi.rewardData(token)["rewardsDistributor"] == alice
Ejemplo n.º 8
0
def test_duration_not_prior_set(multi, alice, bob):
    token = ERC20()
    assert multi.rewardData(token)["rewardsDuration"] == 0
    multi.addReward(token, alice, 60, {"from": alice})
    assert multi.rewardData(token)["rewardsDuration"] == 60
Ejemplo n.º 9
0
def test_owner_can_add_reward_token(multi, alice, bob):
    token = ERC20()
    multi.addReward(token, alice, 60, {"from": alice})
    assert multi.rewardTokens(0) == token
Ejemplo n.º 10
0
def test_fail_random_tokens(multi, alice):
    random_token = ERC20()
    random_token._mint_for_testing(alice, 10**18, {"from": alice})
    with brownie.reverts():
        multi.recoverERC20(random_token, 10**18, {"from": alice})
Ejemplo n.º 11
0
def reward_token2(multi, accounts, alice, charlie):
    _token = ERC20()
    _token._mint_for_testing(alice, 10 ** 18, {"from": alice})
    _token._mint_for_testing(charlie, 10 ** 18)
    multi.addReward(_token, charlie, 60, {"from": alice})
    return _token
Ejemplo n.º 12
0
def reward_token(multi, accounts, alice, bob):
    _token = ERC20()
    _token._mint_for_testing(alice, 10 ** 18, {"from": alice})
    _token._mint_for_testing(bob, 10 ** 19)
    multi.addReward(_token, bob, 60, {"from": alice})
    return _token
Ejemplo n.º 13
0
def base_token(accounts, alice):
    token = ERC20()
    token._mint_for_testing(alice, 10 ** 18, {"from": alice})
    for idx in range(1, 5):
        token._mint_for_testing(accounts[idx], 10 ** 19)
    return token