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.

Aftter truffle init, tests don't work

See original GitHub issue

We created a brand new project via truffle init. Then, after starting a private testnet, unlocking the primary address, starting the miner and running the tests, I get the following error.

Contract: MetaCoin
    ✓ should put 10000 MetaCoin in the first account
    1) should call a function that depends on a linked library  
    > No events were emitted
    2) should send coin correctly
    > No events were emitted

1) Contract: MetaCoin should call a function that depends on a linked library  :
     AssertionError: Library function returned unexpeced function, linkage may be broken: expected 0 to equal 20000

2) Contract: MetaCoin should send coin correctly:
     BigNumber Error: new BigNumber() not a number: [object Object]

We didn’t get to looking at the second error, but for the first one, we got the following info:

outCoinBalance: { [String: '10000'] s: 1, e: 4, c: [ 10000 ] }
outCoinBalance.toNumber(): 10000
outCoinBalanceEth: { [String: '0'] s: 1, e: 0, c: [ 0 ] }
metaCoinEthBalance: 0
2 * metaCoinBalance: 20000

It looks like meta.getBalanceInEth.call(accounts[0]), which is setting outCoinBalanceEth is not returning the correct value.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sarbogastcommented, Dec 29, 2016

Same thing still with Truffle 2.1.1. This issue should really be reopened.

0reactions
zihehuangcommented, Feb 28, 2017

For those of you that uses a private net geth for development, configure your genesis block as follows:

{
    "config": {
            "homesteadBlock": 10
    },
    "nonce": "0",
    "difficulty": "0x20000",
    "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x2FEFD8",
    "alloc": {}
}

The key point here is the homesteadBlock, which enables certain features including DELEGATECALL, which is what libraries are dependent on.

Homestead block is by default set to 1.150.000. This would explain why truffle works with testrpc but not with a private chain.

Source: https://blog.ethereum.org/2016/02/29/homestead-release/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Truffle Init - No Tests? · Issue #4041 · trufflesuite/truffle - GitHub
Yes but after truffle init there are really no contracts to test yet. All reactions.
Read more >
Truffle tests not running after truffle init | Edureka Community
I have installed Testrpc and Truffle globally with NPM. I ran testrpc in a terminal window and ran truffle test.
Read more >
Truffle does nothing and shows no output when running tests
I would run the command truffle init and that would run fine. When I tried to run truffle test nothing would happen. No...
Read more >
Can't test simple Truffle project - solidity - Stack Overflow
truffle create test TestSimpleProject command creates a file test/test_simple_project.js with the following contents:
Read more >
Test your contracts - Truffle Suite
Note: When the truffle test process exits, its exit code is equal to the number of failing tests. If there are more than...
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