question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find artifacts for Solidity tests (Windows only, v4.1.5)

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

In Version v4.1.5 truffle test will throw errors, If I downgrade the truffle version to v4.0.4 , it will work

TestMyContract 1) “before all” hook: prepare suite 0 passing (625ms) 1 failing

  1. TestMyContract “before all” hook: prepare suite: Error: Could not find artifacts for “path”

Steps to Reproduce

Truffle test

Environment

  • Operating System: Windows 10
  • Truffle version (truffle version): v4.1.5

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
cgeweckecommented, Apr 6, 2018

@woodenchalet @ismaelbej I tried to reproduce this using the MetaCoin project but wasn’t able (I’m on OSX). I’d like to figure out if this is Windows specific or if my model for the bug is wrong. My directory structure looked like this:

contracts /
  Parser /
    Tx.sol
  Metacoin.sol
  ConvertLib.sol
  Migrations.sol
test /
  TestMetacoin.sol

Imports at the top of MetaCoin.sol look like this:

pragma solidity ^0.4.18;

import "./ConvertLib.sol";
import "./Parser/Tx.sol";

contract MetaCoin is Tx  {
  ...etc...
}

Imports at the top of TestMetaCoin.sol look like this:

pragma solidity ^0.4.2;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/MetaCoin.sol";

contract TestMetacoin {
 ... etc ...
}

Output is as expected:

Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Parser/Tx.sol...
Compiling ./test/TestMetacoin.sol...
Compiling truffle/Assert.sol...
Compiling truffle/DeployedAddresses.sol...

Also tried running compile before test and everything worked. Should the project structure above trigger the error based on what you’ve seen in your own project?

2reactions
ismaelbejcommented, Apr 5, 2018

I’ll try to create a small reproducible example for now the stack trace output

   1) TestRelay "before all" hook: prepare suite:
      Error: Could not find artifacts for /D/test/contracts/Parser/Tx.sol from any sources
       at Resolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-resolver\index.js:37:1)
       at TestResolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
       at TestResolver.require (C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\testresolver.js:17:1)
       at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:141:1
       at Array.forEach (<anonymous>)
       at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\lib\testing\soliditytest.js:140:1
       at C:\Users\little\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-deployer\src\deferredchain.js:20:1
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:188:7)
 

The file Parser/Tx.sol is a dependency of RelayTests but compilation and migration run fine. Also executing javascript test will run without issues.

And the solidity test, but I think the content doesn’t matter too much because it is never run.

pragma solidity ^0.4.15;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/RelayTests.sol";

contract TestRelay {

    function testFlip32Bytes() {
        RelayTests dr = RelayTests(DeployedAddresses.RelayTests());
        uint expected = 0x201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201;
        Assert.equal(dr.flip32BytesPublic(0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20), expected, "flip32Bytes failed");
    }

}

Read more comments on GitHub >

github_iconTop Results From Across the Web

The reason for "Could not find artifacts for" in truffle?
I got the same problem just now, but I solved it in this way. After your compilation, go to your_folder_location\build\contracts folder.
Read more >
Truffle test fails with Error: Could not find artifacts
I updated my nodejs lastest, and installed window-build-tools,it does not work. TestAdoption.sol: pragma solidity ^0.5.0; import "truffle/Assert ...
Read more >
Compile contracts - Truffle Suite
Artifacts of your compilation will be placed in the build/contracts/ directory, relative to your project root. (This directory will be created if it...
Read more >
Truffle documentation
This is a test file written in Solidity which ensures that your ... This blockchain is local to your system and does not...
Read more >
ConsenSys/truffle - Gitter
That error means it can't locate truffle-default-builder ... suite: Error: Could not find artifacts for openzeppelin-solidity/contracts/GSN/Context.sol from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found