Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e event logs test #9621

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions yarn-project/end-to-end/src/e2e_event_logs.test.ts
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ describe('Logs', () => {
afterAll(() => teardown());

describe('functionality around emitting an encrypted log', () => {
it.skip('emits multiple events as encrypted logs and decodes them one manually', async () => {
it('emits multiple events as encrypted logs and decodes them one manually', async () => {
const randomness = makeTuple(2, Fr.random);
const preimage = makeTuple(4, Fr.random);

@@ -68,31 +68,31 @@ describe('Logs', () => {
expect(event0?.value0).toStrictEqual(preimage[0].toBigInt());
expect(event0?.value1).toStrictEqual(preimage[1].toBigInt());

// We check that an event that does not match, is not decoded correctly due to an event type id mismatch
const badEvent0 = event0Metadata.decode(decryptedEvent0);
expect(badEvent0).toBe(undefined);

const decryptedEvent1 = L1EventPayload.decryptAsIncoming(encryptedLogs[2], wallets[0].getEncryptionSecret())!;

expect(decryptedEvent1.contractAddress).toStrictEqual(testLogContract.address);
expect(decryptedEvent1.randomness).toStrictEqual(randomness[1]);
expect(decryptedEvent1.eventTypeId).toStrictEqual(EventSelector.fromSignature('ExampleEvent1((Field),u8)'));

// We check our second event, which is a different type
const event1Metadata = new EventMetadata<ExampleEvent1>(
EventType.Encrypted,
TestLogContract.events.ExampleEvent1,
);

// We check our second event, which is a different type
const event1 = event1Metadata.decode(decryptedEvent1);

// We check that an event that does not match, is not decoded correctly due to an event type id mismatch
const badEvent0 = event1Metadata.decode(decryptedEvent0);
expect(badEvent0).toBe(undefined);

expect(decryptedEvent1.contractAddress).toStrictEqual(testLogContract.address);
expect(decryptedEvent1.randomness).toStrictEqual(randomness[1]);
expect(decryptedEvent1.eventTypeId).toStrictEqual(EventSelector.fromSignature('ExampleEvent1((Field),u8)'));

// We expect the fields to have been populated correctly
expect(event1?.value2).toStrictEqual(preimage[2]);
// We get the last byte here because value3 is of type u8
expect(event1?.value3).toStrictEqual(BigInt(preimage[3].toBuffer().subarray(31).readUint8()));

// Again, trying to decode another event with mismatching data does not yield anything
const badEvent1 = event1Metadata.decode(decryptedEvent1);
const badEvent1 = event0Metadata.decode(decryptedEvent1);
expect(badEvent1).toBe(undefined);
});