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

When a fake returns a function, we cannot have async data #197

Open
jptusername opened this issue Mar 22, 2024 · 0 comments
Open

When a fake returns a function, we cannot have async data #197

jptusername opened this issue Mar 22, 2024 · 0 comments

Comments

@jptusername
Copy link

Describe the bug
Returning from a fake function reverts with
Error: Transaction reverted: function returned an unexpected amount of data.

If the sendTransaction is left out, it works as expected

Reproduction steps

// test  for userWithdraw method
await fakeStrategy.withdraw.returns(async() => {
                await owner.sendTransaction({
                     to: yieldFarm.address,
                     value: TEN_ETH,
                 });
                return TEN_ETH;
            })

// contract
contract YieldFarm{
  function userWithdraw() {
    /// ... custom logic
    amountReceived = strategy.withdraw(); // this function moves funds from strategy to yieldFarm, ETH in this case
  }
}

Expected behavior
TEN_ETH value should be transferred to the yieldFarm contract. and this function withdraw should return the value TEN_ETH as well

@turtlemoji turtlemoji assigned 0xGorilla and unassigned 0xGorilla Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants