Added another test to show what happens when decoding both local and downstream events
This commit is contained in:
parent
ea8fc1d93f
commit
58e08335b5
@ -44,4 +44,12 @@ contract TestLogDecoding {
|
|||||||
TestLogDecodingDownstream testLogDecodingDownstream = new TestLogDecodingDownstream();
|
TestLogDecodingDownstream testLogDecodingDownstream = new TestLogDecodingDownstream();
|
||||||
ITestLogDecodingDownstream(testLogDecodingDownstream).emitEvent();
|
ITestLogDecodingDownstream(testLogDecodingDownstream).emitEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Emits a local event and a downstream event
|
||||||
|
function emitEventsLocalAndDownstream()
|
||||||
|
public
|
||||||
|
{
|
||||||
|
emitEvent();
|
||||||
|
emitEventDownstream();
|
||||||
|
}
|
||||||
}
|
}
|
@ -55,9 +55,18 @@ describe('TestLogDecoding', () => {
|
|||||||
});
|
});
|
||||||
it('should not event args when no dependencies are passed into wrapper', async () => {
|
it('should not event args when no dependencies are passed into wrapper', async () => {
|
||||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
||||||
|
expect(txReceipt.logs.length).to.be.equal(1);
|
||||||
// tslint:disable no-unnecessary-type-assertion
|
// tslint:disable no-unnecessary-type-assertion
|
||||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
|
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 () => {
|
it('should decode locally emitted event args when dependencies are passed into wrapper', async () => {
|
||||||
const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync();
|
const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync();
|
||||||
expect(txReceipt.logs.length).to.be.equal(1);
|
expect(txReceipt.logs.length).to.be.equal(1);
|
||||||
@ -72,5 +81,15 @@ describe('TestLogDecoding', () => {
|
|||||||
expectedDownstreamEvent,
|
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,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user