Some good news, I have found and fixed some of the errors I was getting. For the Simple ERC777 token example, both the Simple777Recipient.test.js and Simple777Sender.test.js had problems in the code lines that use expectEvent…
Simple777Recipient.test.js
await this.token.send(holder, amount, data, { from: creator });
this.recipient = await Simple777Recipient.new(this.token.address, { from: creator });
});
it('sends to a contract from an externally-owned account', async function () {
const amount = new BN(1000);
const receipt = await this.token.send(this.recipient.address, amount, data, { from: holder });
await expectEvent.inTransaction(receipt.tx, Simple777Recipient, 'DoneStuff', { from: holder, to: this.recipient.address, amount: amount, userData: data, operatorData: null });
const recipientBalance = await this.token.balanceOf(this.recipient.address);
recipientBalance.should.be.bignumber.equal(amount);
});
I changed the 2nd parameter in expectEvent.inTransaction from Simple777Recipient to this.recipient and the DoneStuff event was found and the test passed. Similarly for Simple777Sender.test.js
I have not however been able to pass the Simple777Token.test.js test
it('assigns the initial total supply to the creator', async function () {
const totalSupply = await this.token.totalSupply();
const creatorBalance = await this.token.balanceOf(creator);
expect(creatorBalance).to.be.bignumber.equal(totalSupply);
await expectEvent.inConstruction(this.token, 'Transfer', {
from: ZERO_ADDRESS,
to: creator,
value: totalSupply,
});
});
Here is the output from truffle test:
Contract: Simple777Token
√ has a name (234ms)
Events emitted during test:
---------------------------
Warning: Could not decode event!
Warning: Could not decode event!
Simple777Token.Minted(
operator: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
to: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
amount: 10000000000000000000000 (type: uint256),
data: hex'' (type: bytes),
operatorData: hex'' (type: bytes)
)
Simple777Token.Transfer(
from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
to: <indexed> 0x856bFAFaB009C586BA043d2202B734c1eb56bBdE (type: address),
value: 10000000000000000000000 (type: uint256)
)
Clearly the Transfer event is being fired. Yet expectEvent.inConstruction does not find this ‘Transfer’ event. Would you have any idea why the event is not found?