Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 运行块菌测试时出现非确定性异常_Testing_Mocha.js_Solidity_Truffle_Consensys Truffle - Fatal编程技术网

Testing 运行块菌测试时出现非确定性异常

Testing 运行块菌测试时出现非确定性异常,testing,mocha.js,solidity,truffle,consensys-truffle,Testing,Mocha.js,Solidity,Truffle,Consensys Truffle,我一直在编写自动化测试,使用他们的测试服务(我相信使用的是摩卡和柴)测试我在块菌中的众筹功能。我很难理解为什么测试不确定地失败(即,它们似乎在随机点失败,随机例外) 例如/ 我运行我的测试,有时他们都通过了 我运行测试,有时会收到以下错误消息: ✓ deadline is set when beneficiary clicks start ✓ should return a State of 'Funding' after start is clicked (101ms) ✓ should al

我一直在编写自动化测试,使用他们的测试服务(我相信使用的是摩卡和柴)测试我在块菌中的众筹功能。我很难理解为什么测试不确定地失败(即,它们似乎在随机点失败,随机例外)

例如/ 我运行我的测试,有时他们都通过了

我运行测试,有时会收到以下错误消息:

✓ deadline is set when beneficiary clicks start
✓ should return a State of 'Funding' after start is clicked (101ms)
✓ should allow someone to invest and record balance
✓ should send 1 ERC20 token to participant (184ms)
✓ softcap should not return reached when amountRaised is smaller
✓ softcap should return reached when amountRaised is bigger
✓ hardcap should not return reached when amountRaised is smaller
✓ hardcap should return reached when amountRaised is bigger
1) should give 1 ETH in change as hard cap was exceeded
> No events were emitted
✓ should return a State of 'Successful' when hardcap reached
✓ beneficiary should be able to withdraw funds
✓ should return a State of 'Finished' when beneficiary has funds


22 passing (2s)
1 failing

1) Contract: Sale should give 1 ETH in change as hard cap was exceeded:
 Uncaught AssertionError: deadline was not set after start pressed by beneficiary: expected '0' to not equal 0
  at test/2Crowdsale_Test.js:119:14
  at <anonymous>
  at process._tickDomainCallback (internal/process/next_tick.js:228:7)



 1
 truffle(develop)> 
 /usr/local/lib/node_modules/truffle/build/cli.bundled.js:320098
    throw reason;
    ^

 TypeError: Cannot read property 'currentRetry' of undefined
at 

/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js: 
552:28
at done 
(/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js 
:295:5)
at 
/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js: 
359:11
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
✓ 截止日期在受益人单击开始时设置
✓ 单击开始后应返回“资金”状态(101ms)
✓ 应该允许某人投资并记录余额
✓ 应向参与者发送1个ERC20令牌(184ms)
✓ 当未跟踪的数量较小时,softcap不应返回
✓ 当未追踪的数量较大时,软顶应返回
✓ 当未追踪的数量较小时,不应返回hardcap
✓ 当未追踪的数量较大时,应返回hardcap
1) 当超过硬上限时,应更换1 ETH
>没有发出任何事件
✓ 当达到hardcap时,应返回“成功”状态
✓ 受益人应该能够提取资金
✓ 当受益人有资金时,应返回“完成”状态
22传球(2秒)
1失败
1) 合同:由于超过硬上限,销售应提供1 ETH的变更:
未捕获的断言错误:受益人按开始后未设置截止日期:预期“0”不等于0
at test/2Crowdsale_test.js:119:14
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
1.
块菌(发展)>
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:320098
抛出理由;
^
TypeError:无法读取未定义的属性“currentRetry”
在
/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:
552:28
完成
(/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js
:295:5)
在
/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:
359:11
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
这是令人困惑的,因为断言与错误消息不匹配-更改断言失败,但是,返回的消息是已通过的早期测试的一部分(最后期限在受益人单击开始时设置)

再次运行测试我得到:

✓ approves contract by beneficiary
✓ should return a State of 'Not Started' before start is clicked (134ms)
✓ deadline is set when beneficiary clicks start
✓ should return a State of 'Funding' after start is clicked (98ms)
✓ should allow someone to invest and record balance
✓ should send 1 ERC20 token to participant (143ms)
✓ softcap should not return reached when amountRaised is smaller
✓ softcap should return reached when amountRaised is bigger
✓ hardcap should not return reached when amountRaised is smaller
✓ hardcap should return reached when amountRaised is bigger
1) should give 1 ETH in change as hard cap was exceeded
> No events were emitted
2) should return a State of 'Successful' when hardcap reached

Events emitted during test:
---------------------------

Transfer(_from: <indexed>, _to: <indexed>, _value: 5)
FundTransfer(backer: 0xf17f52151ebef6c7334fad080c5704d77216b732, amount: 5000000000000000000, isContribution: true)
reachedSoftCap(recipient: 0x627306090abab3a6e1400e9345bc60c78a8bef57, totalAmountRaised: 6000000000000000000)

---------------------------
✓ beneficiary should be able to withdraw funds
✓ should return a State of 'Finished' when beneficiary has funds


21 passing (2s)
2 failing

1) Contract: Sale should give 1 ETH in change as hard cap was exceeded:
 Uncaught AssertionError: deadline was not set after start pressed by beneficiary: expected '0' to not equal 0
  at test/2Crowdsale_Test.js:119:14
  at <anonymous>
  at process._tickDomainCallback (internal/process/next_tick.js:228:7)

2) Contract: Sale should return a State of 'Successful' when hardcap reached:
 Uncaught AssertionError: hardcap was not met when amountRaised was bigger: expected false to equal true
  at test/2Crowdsale_Test.js:195:14
  at <anonymous>
  at process._tickDomainCallback (internal/process/next_tick.js:228:7)



  2
  truffle(develop)> 
  /usr/local/lib/node_modules/truffle/build/cli.bundled.js:320098
    throw reason;
    ^

  TypeError: Cannot set property 'state' of undefined
  at 
  /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js: 
  576:20
  at done 
(/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js 
:295:5)
at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:353:11
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
✓ 受益人批准合同
✓ 在单击开始之前,应返回“未启动”状态(134ms)
✓ 截止日期在受益人单击开始时设置
✓ 单击开始后应返回“资金”状态(98毫秒)
✓ 应该允许某人投资并记录余额
✓ 应向参与者发送1个ERC20令牌(143ms)
✓ 当未跟踪的数量较小时,softcap不应返回
✓ 当未追踪的数量较大时,软顶应返回
✓ 当未追踪的数量较小时,不应返回hardcap
✓ 当未追踪的数量较大时,应返回hardcap
1) 当超过硬上限时,应更换1 ETH
>没有发出任何事件
2) 当达到hardcap时,应返回“成功”状态
测试期间发出的事件:
---------------------------
传输(_从:,_到:,_值:5)
资金转移(出资人:0xf17f52151ebef6c7334fad080c5704d77216b732,金额:5000000000000000000,isContribution:true)
达到Softcap(收件人:0x627306090ABAB3A6E1400E9345BC60C78A8BEF7,未经追踪的总数:600000000000000000)
---------------------------
✓ 受益人应该能够提取资金
✓ 当受益人有资金时,应返回“完成”状态
21传球(2秒)
2失败
1) 合同:由于超过硬上限,销售应提供1 ETH的变更:
未捕获的断言错误:受益人按开始后未设置截止日期:预期“0”不等于0
at test/2Crowdsale_test.js:119:14
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
2) 合同:当hardcap达到以下条件时,销售应返回“成功”状态:
未捕获断言错误:当未跟踪的值较大时,未满足硬限制:预期为false等于true
at test/2Crowdsale_test.js:195:14
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
2.
块菌(发展)>
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:320098
抛出理由;
^
TypeError:无法设置未定义的属性“状态”
在
/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:
576:20
完成
(/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js
:295:5)
at/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:353:11
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
我现在有了上一条错误消息,现在又有一条错误消息抛出,再次,错误消息与断言错误不匹配

第四次运行测试我得到:

✓ should allow someone to invest and record balance
✓ should send 1 ERC20 token to participant (120ms)
✓ softcap should not return reached when amountRaised is smaller
✓ softcap should return reached when amountRaised is bigger
✓ hardcap should not return reached when amountRaised is smaller
✓ hardcap should return reached when amountRaised is bigger
✓ should give 1 ETH in change as hard cap was exceeded (275ms)
✓ should return a State of 'Successful' when hardcap reached (61ms)
✓ beneficiary should be able to withdraw funds
1) should return a State of 'Finished' when beneficiary has funds
> No events were emitted


 22 passing (2s)
 1 failing

 1) Contract: Sale should return a State of 'Finished' when beneficiary has funds:
 AssertionError: State of contract was not 'Finished': expected '4' to equal 6
  at test/2Crowdsale_Test.js:243:14
  at <anonymous>
  at process._tickDomainCallback (internal/process/next_tick.js:228:7)
✓ 应该允许某人投资并记录余额
✓ 应向参与者发送1个ERC20令牌(120毫秒)
✓ 当未跟踪的数量较小时,softcap不应返回
✓ 当未追踪的数量较大时,软顶应返回
✓ 当未追踪的数量较小时,不应返回hardcap
✓ 当未追踪的数量较大时,应返回hardcap
✓ 当超过硬上限(275ms)时,应给出1 ETH的变化
✓ 当达到硬上限(61ms)时,应返回“成功”状态
✓ 受益人应该能够提取资金
1) 当受益人有资金时,应返回“完成”状态
>没有发出任何事件
22传球(2秒)
1失败
1) 合同:当受益人有资金时,销售应返回“完成”状态:
AssertionError:合约状态未“完成”:预期“4”等于6
at test/2Crowdsale_test.js:243:14
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:228:7)
这是一个与前两个完全不同的错误。这一项同样令人困惑,因为之前的测试(受益人应该能够提取资金)也测试了国家是否等于6