I'm trying to trigger event defined in another contract and get the event logs in transaction receipt but it's not working this way -
Base Contract --
pragma solidity ^0.4.0;
contract DataStore {
event Borrow(uint indexed bookId, address indexed borrower, uint timestamp);
function borrowEvent(uint id, address borrower) {
Borrow(id, msg.sender, now);
}
}
My Contract --
pragma solidity ^0.4.0;
import "./DataStore.sol";
contract Organisation {
function borrowBook(address bookStore, uint id) payable {
DataStore(bookStore).borrowEvent(id, msg.sender);
}
}
Test Case -
it.only("should generate Borrow event log", async function() {
let res = await org.borrowBook(orgAdr, 1, {from: accounts[1], value: web3.toWei(0.1)});
let log = res.logs[0].args;
assert.equal(log.bookId.valueOf(), 1);
assert.equal(log.borrower, accounts[1]);
assert.isAtMost(log.timestamp.valueOf(), Math.floor(Date.now() / 1000));
assert.isAbove(log.timestamp.valueOf(), Math.floor(Date.now() / 1000) - 300);
});
In test case res.logs[0] is coming as undefined, which seems correct to me since the event is triggered via parent contract. How can I get that event logs in borrowBook function transaction receipt?