-
Hello, starting_balance = dapp_token.balanceOf(account.address) The same approach is used then in the assertion part: assert (
dapp_token.balanceOf(account.address)
== amount_token_to_issue + starting_balance
) My question is, how is it possible to get non-zero values of balance even though there is a transfer function used once stakeTokens() function is applied (see the code below)? I would expect zero balance as the token was transferred to the token farm. function stakeTokens(uint256 _amount, address token) public {
// Require amount greater than 0
require(_amount > 0, "amount cannot be 0");
require(tokenIsAllowed(token), "Token currently isn't allowed");
updateUniqueTokensStaked(msg.sender, token);
IERC20(token).transferFrom(msg.sender, address(this), _amount);
stakingBalance[token][msg.sender] =
stakingBalance[token][msg.sender] +
_amount;
if (uniqueTokensStaked[msg.sender] == 1) {
stakers.push(msg.sender);
}
} Thank you very much in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @haraslub that's quite a good question and I'm not quite sure I will answer correctly so @PatrickAlphaC could you give us a hand on this one? As far I understand I would pretty much say that it happens due to how we deploy the token, as we give the balance to the msg-sender at the constructor, so if you stake the tokens using the same account, you don't actually stake all of them so the account will never be empty. But again I'm not sure, let's hope @PatrickAlphaC could give us more light on this. |
Beta Was this translation helpful? Give feedback.
Hello @haraslub that's quite a good question and I'm not quite sure I will answer correctly so @PatrickAlphaC could you give us a hand on this one?
As far I understand I would pretty much say that it happens due to how we deploy the token, as we give the balance to the msg-sender at the constructor, so if you stake the tokens using the same account, you don't actually stake all of them so the account will never be empty. But again I'm not sure, let's hope @PatrickAlphaC could give us more light on this.