0

I have create a truffle project with this command:

truffle unbox react

I have run this commands:

npm install @openzeppelin/contracts 
npm install @openzeppelin/test-helpers
npm install @openzeppelin/test-environment

I have removed all files in tests/ folder. I have kept sample contract SimpleStorage.sol in contracts/ folder.

I have wrote this test and i put it in a file in tests/ folder:

const { BN, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const SimpleStorage = contract.fromArtifact('SimpleStorage');

describe('SimpleStorage', function () {
   
}

I compile and launch the tests (no error at compile step)

truffe compile
truffle test

i get this error:

Error: Could not find local build/contracts when looking for local artifacts

Any idea ?

4
  • This happens when the build folder is not correctly updated. You can try to clear it and run again 'truffle compile`.
    – clement
    Commented Jan 31, 2021 at 10:21
  • I have no build folder...
    – Bob5421
    Commented Jan 31, 2021 at 10:24
  • Then create a folder build/contracts.
    – clement
    Commented Jan 31, 2021 at 10:36
  • It does not change anything, this folder stay empty. Please note i've create this project with "truffle unbox react" command so there might be a place where compiled contracts are stored
    – Bob5421
    Commented Jan 31, 2021 at 10:54

1 Answer 1

0

In truffle to import artifacts use artifacts.require like this:

const SimpleStorage = artifacts.require('SimpleStorage');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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