RedSquirrelTech / hoscdev

Code for Hands on Smart Contract Development. We recommend https://quickbeam.xyz/ for a more interactive learning experience. (discount code: HOSCDEV100)
http://shop.oreilly.com/product/0636920216018.do
137 stars 51 forks source link

"truffle test" command does not work on chapter-4/greeter #70

Open shinriyo opened 2 years ago

shinriyo commented 2 years ago

I bought the book, "Hands-On Smart Contract Development with Solidity and Ethereum" in Japanese Edition.

I run the first truffle test command in chapter4 in hoscdev/chapter-4/greeter path.

const GreeterContract = artifacts.require("Greeter");

contract("Greeter", () => {
    it("has been deployed successfully", async () => {
        const greeter = await GreeterContract.deployed();
        assert(greeter, "contract failed to deploy");
    });
});

The book says the result is "Could not find artifacts got Greeter grom any sources". However, the commands stop forever.

ikmzkro commented 2 years ago

@shinriyo

I was in the same situation. However, I can get this result by using same testcode.

/greeter$ truffle test

Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Artifacts written to /tmp/test--1938-wSClWNsNdPfO
> Compiled successfully using:
   - solc: 0.8.9+commit.e5eed63a.Emscripten.clang

Error: Could not find artifacts for Greeter from any sources

I suspect that the problem is the versioning problem of Node.js and Truffle . Can you tell me each version?

Each version of me is below.

Truffle v5.4.16 (core: 5.4.16)
Node v14.18.0

Each version of this book is below

Truffle v5.1.31 (core: 5.1.30)
Node v10.21.0
lirlia commented 2 years ago

I was in the same situation in M1 mac and use asdf to install nodejs. after I run truffle compile, truffle test was succeeded. (why?)

my env

❯ truffle version
Truffle v5.4.32 (core: 5.4.32)
Solidity v0.5.16 (solc-js)
Node v16.4.2
Web3.js v1.5.3