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

expectEvent() not capturing expected event #195

Open
inmarelibero opened this issue Apr 11, 2023 · 0 comments
Open

expectEvent() not capturing expected event #195

inmarelibero opened this issue Apr 11, 2023 · 0 comments

Comments

@inmarelibero
Copy link

expectEvent() is not capturing an expected event (SmartContract is correct and tested in other ways)

in expectEvent() I has to put:

return ({ event: receipt.events[name].event, args: receipt.events[name].args });

instead of:

return ({ event: name, args: receipt.events[name].returnValues });

I guess because of the different Event format expected. In concrete, Event names are expected to be the array keys (which are not: they are _item_.event), and args are expected to be _item.returnValues (I have _item_.args instead)

I attach here a sample of the transaction receipt I get:

{
  to: '...',
  from: '0x709...97970C51812dc3A010C7d01b50e0d17dc79C8',
  ...
  logs: [
    ...,
    {
      transactionIndex: 0,
      blockNumber: 23,
      transactionHash: '0xe8fe248cc5334ee1bb2b3fabf069409724ff05dde5594316387864fd871d7bd8',
      address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
      topics: [Array],
      data: '0x',
      logIndex: 2,
      blockHash: '0x7a8251b36220cdc989df062d06f882b0560d174ac43baa27e63fe3601badf8a6'
    }
  ],
  ...
  events: [
    ...,
    {
      transactionIndex: 0,
      blockNumber: 23,
      transactionHash: '0xe8fe248cc5334ee1bb2b3fabf069409724ff05dde5594316387864fd871d7bd8',
      address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
      topics: [Array],
      data: '0x',
      logIndex: 2,
      blockHash: '0x7a8251b36220cdc989df062d06f882b0560d174ac43baa27e63fe3601badf8a6',
      args: [Array],
      decode: [Function (anonymous)],
      event: 'MintElementsEvent',
      eventSignature: 'MintElementsEvent(uint32[],address)',
      removeListener: [Function (anonymous)],
      getBlock: [Function (anonymous)],
      getTransaction: [Function (anonymous)],
      getTransactionReceipt: [Function (anonymous)]
    }
  ]
}

My environment:

Solidity: 0.8.17


"hardhat": "^2.12.4",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomiclabs/hardhat-ethers": "^2.2.2",
"@openzeppelin/test-helpers": "^0.5.16",
"@typechain/hardhat": "^6.1.5",
"ethers": "^5.0.0",
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

1 participant