简体   繁体   English

设置--network标志时,松露测试失败

[英]truffle test fail when --network flag is set

truffle config 松露配置

Below is my truffle.js file. 以下是我的truffle.js文件。 As you can see, development and privateLive are exactly the same. 如您所见, developmentprivateLive完全相同。

// 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

// 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. 谁能告诉我有什么区别,以及truffle为什么如此表现。

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. 我尝试了eth.getTransactioneth.getTransactionReceipt ,但发现没有任何帮助。

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 在此处查看有关如何使用松露进行调试的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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