I have a function in a contract that dispatches an event. But it also executes functions on other contracts that dispatch an event each. The first event is part of the transaction, the latter events not.
Example code:
function assignTeamVesting(address teamVesting) public onlyOwner {
require(teamVesting != address(0), "xxxTokenSale: no Zero address allowed as team vesting address");
_teamVesting = teamVesting;
emit TeamVestingAssigned(_teamVesting);
// update time locks/token vesting contracts as well
if(_timeLocks.length > 0) {
for(uint256 i = 0; i < _timeLocks.length; i++) {
TokenVesting vesting = _timeLocks[i];
vesting.updateBeneficiary(teamVesting);
}
}
}
The TokenVesting
contracts function updateBeneficiary
is:
function updateBeneficiary(address beneficiary) public onlyOwnerOrUpdater {
address oldBeneficiary = _beneficiary;
_beneficiary = beneficiary;
emit BeneficiaryUpdate(_beneficiary, oldBeneficiary);
}
truffle test --show-events
shows that all events was dispatched as expected:
TeamVestingAssigned(teamVesting: 0x90dAE34cb6e655868e1ee6D358591548D605d7D8 (address)) BeneficiaryUpdate(beneficiary: 0x90dAE34cb6e655868e1ee6D358591548D605d7D8 (address), oldBeneficiary: 0xFcCe0b0346cde1e6c609757345Fc34d5D9a60102 (address)) BeneficiaryUpdate(beneficiary: 0x90dAE34cb6e655868e1ee6D358591548D605d7D8 (address), oldBeneficiary: 0xFcCe0b0346cde1e6c609757345Fc34d5D9a60102 (address))
But in a test, when I execute the following line:
const tx = await this.tokenSale.assignTeamVesting(another, {from: owner});
only the first event can be found in tx.logs:
[ { logIndex: 0,
transactionIndex: 0,
transactionHash:
'0x2323194579b38689dd14cb1c81f4e69683cb3f6005f60b6c17bced36ea06c291',
blockHash:
'0x37506a8e1f0500422efa530ef187dd182c46995f160fce3c0f8e25109d87d7d1',
blockNumber: 4696,
address: '0x5BEd044dc960763E7C058B11dbc18e37C45CAe05',
type: 'mined',
id: 'log_65c362d2',
event: 'TeamVestingAssigned',
args:
Result {
'0': '0x90dAE34cb6e655868e1ee6D358591548D605d7D8',
__length__: 1,
teamVesting: '0x90dAE34cb6e655868e1ee6D358591548D605d7D8' } } ]
Is there any way to test for the other events as well?
(Maybe I should also ask on truffle-repo)