I'm migrating from Truffle to Hardhat. I've been using an upgradable contract for my smart contract. While hardhat-truffle5 works fine for tests with normal contracts, I find myself forced to use Ethers contract initialization for the upgradable contract. How can I test the events that occur in my contracts? I'm encountering an error while using the test-helpers library.
Code to reproduce
hardhat.config.js
require("@nomiclabs/hardhat-truffle5");
require("@nomiclabs/hardhat-ganache");
require('@openzeppelin/hardhat-upgrades');
...
marketplace.test.js
...
const Marketplace = await ethers.getContractFactory("Marketplace");
this.marketplace = await upgrades.deployProxy(Marketplace, [], {
kind: "uups",
from: owner,
initializer: "initialize",
});
await this.marketplace.waitForDeployment();
...
const tx = await this.marketplace.connect(this.buyer).buyItem(this.collection.target, 0, {
from: buyer,
value: price,
});
const receipt = await tx.wait();
expectEvent(receipt.logs, "ItemBought", {
from: other,
to: buyer,
collection: this.collection.target,
tokenId: new BN(0),
amount: new BN(1),
price: new BN(price),
});
Result:
Error: Unknown transaction receipt object
If anyone has insights or suggestions on how to effectively test events in upgradable contracts within the Hardhat framework, your guidance would be greatly appreciated. Thank you!