Added another test to show what happens when decoding both local and downstream events

This commit is contained in:
Greg Hysen 2019-07-26 20:33:30 +02:00
parent ea8fc1d93f
commit 58e08335b5
2 changed files with 27 additions and 0 deletions

View File

@ -44,4 +44,12 @@ contract TestLogDecoding {
TestLogDecodingDownstream testLogDecodingDownstream = new TestLogDecodingDownstream();
ITestLogDecodingDownstream(testLogDecodingDownstream).emitEvent();
}
/// @dev Emits a local event and a downstream event
function emitEventsLocalAndDownstream()
public
{
emitEvent();
emitEventDownstream();
}
}

View File

@ -55,9 +55,18 @@ describe('TestLogDecoding', () => {
});
it('should not event args when no dependencies are passed into wrapper', async () => {
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
expect(txReceipt.logs.length).to.be.equal(1);
// tslint:disable no-unnecessary-type-assertion
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
});
it('should decode args for local but not downstream event when no dependencies are passed into wrapper', async () => {
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
expect(txReceipt.logs.length).to.be.equal(2);
// tslint:disable no-unnecessary-type-assertion
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
// tslint:disable no-unnecessary-type-assertion
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
});
it('should decode locally emitted event args when dependencies are passed into wrapper', async () => {
const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync();
expect(txReceipt.logs.length).to.be.equal(1);
@ -72,5 +81,15 @@ describe('TestLogDecoding', () => {
expectedDownstreamEvent,
);
});
it('should decode args for both local and downstream events when dependencies are passed into wrapper', async () => {
const txReceipt = await testLogDecodingWithDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
expect(txReceipt.logs.length).to.be.equal(2);
// tslint:disable no-unnecessary-type-assertion
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
// tslint:disable no-unnecessary-type-assertion
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(
expectedDownstreamEvent,
);
});
});
});