Warning: Could not decode event

Hi,
I am unable to get ‘Simple ERC777 token example’ to work properly. I get error messages “Warning: Could not decode event!”.
When I run truffle test --show-events

Contract: Simple777Recipient
1) sends to a contract from an externally-owned account

Events emitted during test:
---------------------------

Warning: Could not decode event!

Warning: Could not decode event!

IERC777.Minted(
  operator: <indexed> 0x06C88a93492Fb6A1B6F2F200Db4C482Eca300F18 (type: address),
  to: <indexed> 0x06C88a93492Fb6A1B6F2F200Db4C482Eca300F18 (type: address),
  amount: 10000000000000000000000 (type: uint256),
  data: hex'' (type: bytes),
  operatorData: hex'' (type: bytes)
)

IERC20.Transfer(
  from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
  to: <indexed> 0x06C88a93492Fb6A1B6F2F200Db4C482Eca300F18 (type: address),
  value: 10000000000000000000000 (type: uint256)

I get the same warning messages for the other tests. I am using…

OpenZeppelin v4.1.0
Truffle v5.3.6
npm 6.14.4
Solidity 0.8.0
Ganache v2.5.4

Same errors on both Windows 10 and Ubuntu 20.04

The tests report back that the events are not found…

  1. Contract: Simple777Recipient
    sends to a contract from an externally-owned account:

    No ‘DoneStuff’ events found

    • expected - actual

    -false
    +true

    at inLogs (node_modules/@openzeppelin/test-helpers/src/expectEvent.js:51:32)
    at Function.inTransaction (node_modules/@openzeppelin/test-helpers/src/expectEvent.js:97:10)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Context. (test/Simple777Recipient.test.js:21:5)

  2. Contract: Simple777Sender
    sends from an externally-owned account:

    No ‘DoneStuff’ events found

    • expected - actual

    -false
    +true

    at inLogs (node_modules/@openzeppelin/test-helpers/src/expectEvent.js:51:32)
    at Function.inTransaction (node_modules/@openzeppelin/test-helpers/src/expectEvent.js:97:10)
    at runMicrotasks ()
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Context. (test/Simple777Sender.test.js:26:5)
    .
    .

What could be the cause of this? What can I do to fix this?
Thanks.

Jules

Hi @Jules23. Can you show your test code where you call expectEvent?

Some good news, I have found and fixed some of the errors I was getting. For the Simple ERC777 token example, both the Simple777Recipient.test.js and Simple777Sender.test.js had problems in the code lines that use expectEvent…

Simple777Recipient.test.js

    await this.token.send(holder, amount, data, { from: creator });
    this.recipient = await Simple777Recipient.new(this.token.address, { from: creator });
  });

it('sends to a contract from an externally-owned account', async function () {
    const amount = new BN(1000);
    const receipt = await this.token.send(this.recipient.address, amount, data, { from: holder });

    await expectEvent.inTransaction(receipt.tx, Simple777Recipient, 'DoneStuff', { from: holder, to: this.recipient.address, amount: amount, userData: data, operatorData: null });

    const recipientBalance = await this.token.balanceOf(this.recipient.address);
    recipientBalance.should.be.bignumber.equal(amount);
  });

I changed the 2nd parameter in expectEvent.inTransaction from Simple777Recipient to this.recipient and the DoneStuff event was found and the test passed. Similarly for Simple777Sender.test.js

I have not however been able to pass the Simple777Token.test.js test

   it('assigns the initial total supply to the creator', async function () {
    const totalSupply = await this.token.totalSupply();
    const creatorBalance = await this.token.balanceOf(creator);

    expect(creatorBalance).to.be.bignumber.equal(totalSupply);

    await expectEvent.inConstruction(this.token, 'Transfer', {
      from: ZERO_ADDRESS,
      to: creator,
      value: totalSupply,
    });
  });

Here is the output from truffle test:

 Contract: Simple777Token
    √ has a name (234ms)

    Events emitted during test:
    ---------------------------

    Warning: Could not decode event!

    Warning: Could not decode event!

    Simple777Token.Minted(
      operator: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
      to: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
      amount: 10000000000000000000000 (type: uint256),
      data: hex'' (type: bytes),
      operatorData: hex'' (type: bytes)
    )

    Simple777Token.Transfer(
      from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
      to: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
      value: 10000000000000000000000 (type: uint256)
    )

Clearly the Transfer event is being fired. Yet expectEvent.inConstruction does not find this ‘Transfer’ event. Would you have any idea why the event is not found?

Have you tried to see if the Transfer event is found when you don’t pass in any argument values?

await expectEvent.inConstruction(this.token, 'Transfer');

Thanks, I’ve removed the arguments as you specified but the ‘Transfer’ event is still not found. Here is the output from truffle test:

5 passing (9s)
1 failing

  1. Contract: Simple777Token
    assigns the initial total supply to the creator:

No ‘Transfer’ events found

  • expected - actual

-false
+true

at inLogs (node_modules@openzeppelin\test-helpers\src\expectEvent.js:51:32)
at inTransaction (node_modules@openzeppelin\test-helpers\src\expectEvent.js:97:10)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at Context. (test\Simple777Token.test.js:32:5)

Sorry not really sure why this could be happening. :confused: