PatrickAlphaC / defi-stake-yield-brownie-freecode

52 stars 62 forks source link

Token is currently not allowed Error #11

Closed kennisnutz closed 2 years ago

kennisnutz commented 2 years ago

Omg It was my ignorance

Markkop commented 2 years ago

I was having the same error for the test test_get_user_total_value_with_different_tokens. The problem was that I've coded the return false from isAllowedToken inside the for loop, so it was returning False after the first loop instead of looping trough all allowedTokens. If somebody else is having this issue, check if your returns are correct in the isAllowedToken solidity function:

    function tokenIsAllowed(address _token) public view returns (bool) {
        for (
            uint256 allowedTokensIndex = 0;
            allowedTokensIndex < allowedTokens.length;
            allowedTokensIndex++
        ) {
            if (allowedTokens[allowedTokensIndex] == _token) {
                return true;
            }
            // don't return false here 
        }
        return false;
    }
PatrickAlphaC commented 2 years ago

Closing for now, thanks both for adding your info!