Issue with Running Tests on Local Node (fhevm 0.3.0)

Issue with Running Tests on Local Node

Greetings Zama team,

I’m currently facing an issue while running tests on my local node, which is set up using Docker as per the provided instructions. The node is running perfectly, and deploying contracts works as expected. However, I’m encountering an issue when running tests.

Here is the relevant test code:

describe("Unit Tests", function () {
    // We define a fixture to reuse the same setup in every test.
    async function deploymentFixture() {
        const [deployer, tester] = await ethers.getSigners();
        const instance = await createInstance();

        const erc20Factory = await ethers.getContractFactory("StableCoinMain");
        const erc20Contract = await erc20Factory.connect(deployer).deploy();

        // Deploying and setting up the event contract
        const eventFactory = await ethers.getContractFactory("EventMain");
        const eventContract = await eventFactory
            .connect(deployer)
            .deploy(deployer.address, eventData.uri, eventData.details._name, [], [], [], [], []);

        console.log("Event Contract Address is:", eventContract.address);
   
        priceData.priceBase[1].currencyAddress = erc20Contract.address;

        return { instance, erc20Contract, eventContract, deployer, tester }
    }

    it("Main - Owner Role Checker", async () => {
        const { instance, erc20Contract, eventContract, deployer, tester } = await deploymentFixture();
        // Owner setup tests
        const OWNER_ROLE = await eventContract.OWNER_ROLE();
        expect(await eventContract.hasRole(OWNER_ROLE, deployer.address)).to.equal(true);
    });
});

When running this test, I encounter the following error:

Error: data out-of-bounds (length=0, offset=32, code=BUFFER_OVERRUN, version=abi/5.7.0)

Interestingly, these same test cases run perfectly on the Inco testnet. I am under the assumption that fhEVM 0.3.0 and Inco testnet fhEVM are the same.

Could you please assist in resolving this issue?


Thank you for your help!

Hello, fhevm 0.3.0 is outdated and no longer maintained. Many bugs were fixed then. Could you try to run your test on fhevm 0.4.0 instead? You can use this template if you need some guidance GitHub - zama-ai/fhevm-hardhat-template: fhEVM hardhat template

But will this fhevm be compatible with the inco-genetry testnet? I believe they use 0.3.0.

I am not familiar with Inco, but I think they will upate their test net very soon as well. Better ask them directly and use their libraries if you want to develop directly on their network.