简体   繁体   中英

truffle test fail when --network flag is set

truffle config

Below is my truffle.js file. As you can see, development and privateLive are exactly the same.

// truffle.js
module.exports = {
  networks: {
    development: {
      provider: () => new PrivateKeyProvider(privateKey, sidechainEndpoint),
      host: 'http://222.200.180.185',
      port: 8545,
      network_id: '*', // eslint-disable-line camelcase
      from: '0xab2ec9c41aee37c87466fe54194bb88ba5c5ca31'
    },

    privateLive: {
      provider: () => new PrivateKeyProvider(privateKey, sidechainEndpoint),
      host: 'http://222.200.180.185',
      port: 8545,
      network_id: '*', // eslint-disable-line camelcase
      from: '0xab2ec9c41aee37c87466fe54194bb88ba5c5ca31'
      },

    ...
}

test case

I have an empty test file test/test.js .

// test/test.js
// empty 

the bug

Below command succeeds.

$ ./node_modules/truffle/build/cli.bundled.js test test/testp.js
Using network 'development'.



  0 passing (1ms)

However, below command fails.

$ ./node_modules/truffle/build/cli.bundled.js --network privateLive test test/test.js
Using network 'privateLive'.

Transaction: 0x4d11ca4f12122d8b70ad71bd272ef7fd01a70a96025c3b2249237e5631287507 exited with an error (status 0).
Please check that the transaction:
    - satisfies all conditions set by Solidity `require` statements.
    - does not trigger a Solidity `revert` statement.

Could anyone tell me what's the difference and why truffle behaved like that.

I also want to know how can I get the reason why transaction failed. I tried eth.getTransaction and eth.getTransactionReceipt and found nothing helpful.

Thanks a lot.

You can try to debug the transaction using truffle debug, as follow:

truffle debug 0x4d11ca4f12122d8b70ad71bd272ef7fd01a70a96025c3b2249237e5631287507 --network=privateLive

See more about how to debug using truffle here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM