Skip to content

Commit

Permalink
fix: e2e event logs test (#9621)
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy authored Oct 31, 2024
1 parent 1c53459 commit 737c573
Showing 1 changed file with 11 additions and 11 deletions.
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
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit 737c573

Please sign in to comment.