Truffle: Files imported from the test directory cannot find already generated artifacts

Created on 4 Dec 2017  路  14Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Whenever there is a file imported into a test file when running truffle test, and the contract object itself doesn't match the file name, truffle complains that it cannot find the artifacts.

Steps to Reproduce

Take your standard owned contract:

pragma solidity ^0.4.16;

contract owned {
    function owned() public { owner = msg.sender; }
    address owner;

    // This contract only defines a modifier but does not use
    // it - it will be used in derived contracts.
    // The function body is inserted where the special symbol
    // "_;" in the definition of a modifier appears.
    // This means that if the owner calls this function, the
    // function is executed and otherwise, an exception is
    // thrown.
    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    function changeOwner(address newOwner) public onlyOwner {
        owner = newOwner;
    }
}
  • put it into the contracts directory under the filename "Utils.sol".
  • use it in a contract (inherit the owned principle into some Widget contract).
  • create a TestWidget.sol contract in the test directory. Import the Widget contract.
  • Try to run truffle test

Expected Behavior

It should be able to find it based on the artifacts in the build directory by scanning through each of the artifacts and looking to the sourcePath key in all of the artifacts to see if it matches...or it could just recompile. Whichever you think works best given the project needs.

Actual Results

  1) TestRoleManager "before all" hook: prepare suite:
     Error: Could not find artifacts for /Users/vor0220/itpeople/fit-repo-bitbucket/contracts/Utils.sol from any sources

Environment

  • Operating System: OS X High Sierra 10.13.1
  • Truffle version: v4.0.1
  • Ethereum client: Ganache I suppose?
  • node version: v8.0.0
  • npm version: 5.5.1

All 14 comments

Can confirm same issue

hello, i have been dealing with this for a while also, and have asked about this on gitter.
i am getting the
""before all" hook: prepare suite: Error: Could not find artifacts"
regardless if i test all or a specific file.

I have been following along with the truffle framework pet shop tutorial,

running a windows 10
Truffle v4.1.5
ganache-cli/ganache-gui
node v8.10.0
npm v5.6.0

was wondering if i should even pursue this anymore? or is the problem for much smarter people to solve soewhere in the depths of the EVM?

same like @takageRoshi
It is definitely not about the name of file and contract, because their the same.

Truffle v4.1.5
ganache-cli/ganache-gui
node v8.11.1
npm v5.8.0
Code from http://truffleframework.com/tutorials/pet-shop

`TestAdoption
1) "before all" hook: prepare suite

0 passing (2s)
1 failing

1) TestAdoption "before all" hook: prepare suite:
Error: Could not find artifacts for /C/Proj/TrufflePetShop/src/contracts/Adoption.sol from any sources
at Resolver.require (C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-resolver\index.js:37:1)
at TestResolver.require (C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
at TestResolver.require (C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
at C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:141:1
at Array.forEach ()
at C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:140:1
at C:\Users\Alex\AppData\Roaming\npmnode_modules\truffle\build\webpack:\~\truffle-deployer\src\deferredchain.js:20:1
at
at process._tickCallback (internal/process/next_tick.js:188:7)`

Looks like we catch a bug.
https://ethereum.stackexchange.com/questions/44568/truffle-test-fails-in-petshop-tutorial
@takageRoshi @VoR0220 it is worked when rollback to 4.1.4

in shot: pet shop tutorial tests did not work in truffle 4.1.5 but worked in 4.1.4
Error: Could not find artifacts for /C/Proj/TrufflePetShop/src/contracts/Adoption.sol from any sources
at Resolver.require

This truffle framework is total bullshit, with release 4.1.5 it is not possible to even apply the tutorials correctly. It does not ease the work of the developers.

@aligokalppeker Sincere apologies - I believe the bug you're facing affect Windows users running Solidity tests only and can be worked around by using 4.1.4 instead. We should be publishing a patch that fixes this tomorrow. If you're seeing a different problem please let us know.

This problem is still happening with latest version on windows.

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

There has been no new activity on this issue since it was marked as stale 7 days ago, so it is being automatically closed. If you'd like help with this or a different problem, please open a new issue. Thanks!

This is still an issue, why are you automatically closing all issues after 7 days?

Thanks for your response! This issue is no longer considered stale and someone from the Truffle team will try to respond as soon as they can.

(We have a 90 or 180 days policy to mark issues as stale. If there are no comments within 7 days of an issue being marked stale, then it gets closed)

Anyway, to follow-up here, is this actually still an issue? Can anyone comment? Thanks!

Actually, thinking about this a bit more, and with @CruzMolina's help, I'm pretty sure this is still a problem. Likely this will be fixed by #1718

Was this page helpful?
0 / 5 - 0 ratings