我有一个合约的功能,它会在每次通话时发出事件.
我想在每个测试中发出一个正在传递的事件,这里有一些测试:
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)