Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

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

@jptusername

Description

@jptusername

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions