question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checking event spawned by fallback function

See original GitHub issue

Relayer:

    function relay(address payable recipient, uint amount) public {
        require(amount < address(this).balance, "insufficient funds");
        recipient.transfer(amount);
    }

EthWallet:

    function() external payable {
        // generate an event when receiving Eth
        require(msg.value > 0, "zero deposit");
        emit DepositEvent(msg.sender, msg.value);
    }
    return relay_instance.relay(EthWallet.address, value_out).then(function (result) {
        truffleAssert.prettyPrintEmittedEvents(result);
        //...

There are no events printed, even though (if the test fails) it announces that the event was emitted. I imagine this is because of the fact that the event isn’t directly emitted by the Relayer contract.

What is the work around here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rkaliscommented, Jul 3, 2019

Hey @hlb8122 sorry for dropping the ball on this one, I completely forgot to get into this issue. I haven’t tested this yet, but can you try this:

return relay_instance.relay(EthWallet.address, value_out).then(function (result) {
    const ethWalletResult = truffleAssert.createTransactionResult(ethwallet_instance, result.tx);
    truffleAssert.prettyPrintEmittedEvents(ethWalletResult);
    // ...
}
1reaction
naibacommented, Sep 9, 2019

@rkalis It works for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solidity 0.6.x features: fallback and receive functions
The main use case of the pre-0.6.x fallback function is to receive ... contracts to reject transfers, emit events or forward the ether....
Read more >
Fallback Functions - Ethereum Smart Contract Best Practices
Fallback functions are called when a contract is sent a message with no arguments (or when no function matches), and only has access...
Read more >
HackPedia: 16 Solidity Hacks/Vulnerabilities, their Fixes and ...
3. Unexpected Ether. Typically when ether is sent to a contract, it must execute either the fallback function, or another function described in...
Read more >
Child process | Node.js v19.3.0 Documentation
The child_process.spawn() method spawns the child process asynchronously, without blocking the Node.js event loop. The child_process.spawnSync() function ...
Read more >
Events in Chained Fallback Function Cause VirtualMachineError
I have a decent set of tests and everything passes successfully. However if I emit an event in the initial fallback function, contract...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found