diff --git a/contracts/utils/contracts/test/TestLogDecoding.sol b/contracts/utils/contracts/test/TestLogDecoding.sol index 145cebf143..e692d8b75f 100644 --- a/contracts/utils/contracts/test/TestLogDecoding.sol +++ b/contracts/utils/contracts/test/TestLogDecoding.sol @@ -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(); + } } \ No newline at end of file diff --git a/contracts/utils/test/log_decoding.ts b/contracts/utils/test/log_decoding.ts index 141731892a..16ae7a6244 100644 --- a/contracts/utils/test/log_decoding.ts +++ b/contracts/utils/test/log_decoding.ts @@ -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).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).args).to.be.deep.equal(expectedEvent); + // tslint:disable no-unnecessary-type-assertion + expect((txReceipt.logs[1] as LogWithDecodedArgs).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).args).to.be.deep.equal(expectedEvent); + // tslint:disable no-unnecessary-type-assertion + expect((txReceipt.logs[1] as LogWithDecodedArgs).args).to.be.deep.equal( + expectedDownstreamEvent, + ); + }); }); });