Hi I am trying to use your library hardhat but have an error when trying to expectRevertCustomError
. Since the test-helper library
is not compatible with ethers.js I have to use truffle/web3. Below is my hardhat config:
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
require("@nomicfoundation/hardhat-chai-matchers");
import "hardhat-contract-sizer";
import "@nomiclabs/hardhat-web3";
require("@nomiclabs/hardhat-truffle5");
const config: HardhatUserConfig = {
// solidity: "0.8.0",
solidity: {
compilers: [
{ version: "0.8.17", settings: {} }
],
},
};
export default config;
With my current setup I am able to create test cases which follow the truffle pattern with no issues. I then try to unit test custom errors using the similar truffle pattern like below:
const {
balance,
ether,
expectEvent,
expectRevert,
BN,
} = require('@openzeppelin/test-helpers');
const { expectRevertCustomError } = require("custom-error-test-helper");
const Marketplace = artifacts.require("Marketplace");
describe("Marketplace contract", function () {
let marketplace;
beforeEach(async function () {
marketplace = await Marketplace.new();
});
it("Should validate listed 721 errors", async function () {
await expectRevertCustomError(Marketplace, marketplace.listNFT(marketplace.address, BigNumber.from("1"), BigNumber.from("1"), BigNumber.from(TOMORROW), BigNumber.from(IN_FIVE_DAYS),
{ from: TOKEN_OWNER, value: listingFee}), "UnsupportedNftInterface");
});
/* more test cases*/
});
Below is the error when this case is rase. Do you know what is causing this and how to fix the error?
1) Marketplace contract
Validate Listings
Should validate listed 721 errors:
TypeError: Cannot read properties of undefined (reading 'result')
at expectRevertCustomError (node_modules/custom-error-test-helper/build/index.js:17:88)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:533:9)
at processTimers (node:internal/timers:507:7)
at async Context.<anonymous> (test/Marketplace.js:374:9)