2

This is the error code: enter image description here

Adoption.sol code: enter image description here

TestAdoption.sol code: enter image description here

I dont know how to solve this, it fails when i try to use this comand: "truffle test". Thanks.

0
1

delete everything inside your build folder in your truffle root project. and then repeat

truffle compile
truffle migrate
truffle test

hope this help

1

npm uninstall -g truffle

npm install -g truffle@5.1.10 (always got me back on track)

0

Which truffle version are you using? I had same issue and I was using v5.1.15, the latest version for now. And I try an old v5.1.10 and it works. It's due to a compilation OS-compatibility path issue. Here you can find an article about it: https://github.com/trufflesuite/truffle/issues/2834#issuecomment-588321875

0

uninstall and install truffle helped me!

0

Also, this issue occurs when used several test suites that use async test-helpers without await (for example, OpenZeppelin Test Helpers: expectEvent, expectRevert).

Consider example:

contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract Test03 {
    address public owner;
    int32 public id;

    event ContractCreated();

    constructor() {
        owner = msg.sender;

        emit ContractCreated();
    }

    function doSmth(int32 _id) public {
        require(id != 0, "id is zero");
        id= _id;
    }
}

test

const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');

const TestContract = artifacts.require('Test03');

contract('Test03', function (accounts) {
    const [owner] = accounts;
    const txParams = { from: owner };

    beforeEach(async function () {
        this.testContract = await TestContract.new(txParams);
    });

    describe('construction', function () {
        it('initial state', async function () {
            expect(await this.testContract.owner()).to.equal(owner);

            // !! DONT FORGET await before expectEvent-call <<------------------------------
            await expectEvent.inConstruction(this.testContract, 'ContractCreated');
        });
    });

    describe('doSmth', function () {
      it('fail when passed zero id', async function () {

        // !! DONT FORGET await before expectRevert-call <<------------------------------
        await expectRevert(
          this.testContract.doSmth(0, txParams),
          "id is zero");
      });
  });    
});

package.json

{
..
  "devDependencies": {
    "@openzeppelin/test-helpers": "^0.5.10"
  }
..
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.