小编lth*_*ron的帖子

测试以太坊事件日志与松露

我有一个合约的功能,它会在每次通话时发出事件.

我想在每个测试中发出一个正在传递的事件,这里有一些测试:

it("should emit Error event when sending 5 ether", function(done){
  var insurance = CarInsurance.deployed();

  insurance.send({from: accounts[0], value: web3.toWei(5, 'ether')}).then(done).catch(done);
});

it("should emit Error event when sending 5 ether", function(done){
  var insurance = CarInsurance.deployed();

  insurance.send({from: accounts[0], value: web3.toWei(5, 'ether')}).then(function(txHash){
    assert.notEqual(txHash, null);
  }).then(done).catch(done);
});

it("should emit Error event when sending 5 ether", function(done){
  var insurance = CarInsurance.deployed();

  insurance.send({from: accounts[0], value: web3.toWei(5, 'ether')}).then(function(done){
    done();
  }).catch(done);
});
Run Code Online (Sandbox Code Playgroud)

结果是:

1) should emit Error event when sending 5 ether

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

Error(error: …
Run Code Online (Sandbox Code Playgroud)

events logging mocha.js ethereum truffle

11
推荐指数
3
解决办法
8969
查看次数

标签 统计

ethereum ×1

events ×1

logging ×1

mocha.js ×1

truffle ×1