diff --git a/yarn-project/simulator/src/avm/journal/journal.test.ts b/yarn-project/simulator/src/avm/journal/journal.test.ts index 4a4db8e3304..bcee9bbea5a 100644 --- a/yarn-project/simulator/src/avm/journal/journal.test.ts +++ b/yarn-project/simulator/src/avm/journal/journal.test.ts @@ -70,7 +70,7 @@ describe('journal', () => { expect(exists).toEqual(false); const journalUpdates = journal.flush(); - expect(journalUpdates.nullifierChecks.map(c => [c.nullifier, c.exists])).toEqual([[utxo, false]]); + expect(journalUpdates.nullifierChecks).toEqual([expect.objectContaining({ nullifier: utxo, exists: false })]); }); it('checkNullifierExists works for existing nullifiers', async () => { const contractAddress = new Fr(1); @@ -82,7 +82,7 @@ describe('journal', () => { expect(exists).toEqual(true); const journalUpdates = journal.flush(); - expect(journalUpdates.nullifierChecks.map(c => [c.nullifier, c.exists])).toEqual([[utxo, true]]); + expect(journalUpdates.nullifierChecks).toEqual([expect.objectContaining({ nullifier: utxo, exists: true })]); }); it('Should maintain nullifiers', async () => { const contractAddress = new Fr(1); @@ -100,8 +100,8 @@ describe('journal', () => { expect(exists).toEqual(false); const journalUpdates = journal.flush(); - expect(journalUpdates.l1ToL2MessageChecks.map(c => [c.leafIndex, c.msgHash, c.exists])).toEqual([ - [leafIndex, utxo, false], + expect(journalUpdates.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: leafIndex, msgHash: utxo, exists: false }), ]); }); it('checkL1ToL2MessageExists works for existing nullifiers', async () => { @@ -113,8 +113,8 @@ describe('journal', () => { expect(exists).toEqual(true); const journalUpdates = journal.flush(); - expect(journalUpdates.l1ToL2MessageChecks.map(c => [c.leafIndex, c.msgHash, c.exists])).toEqual([ - [leafIndex, utxo, true], + expect(journalUpdates.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: leafIndex, msgHash: utxo, exists: true }), ]); }); it('Should maintain nullifiers', async () => { @@ -200,14 +200,14 @@ describe('journal', () => { { recipient, content: commitment }, { recipient, content: commitmentT1 }, ]); - expect(journalUpdates.nullifierChecks.map(c => [c.nullifier, c.exists])).toEqual([ - [commitment, true], - [commitmentT1, true], + expect(journalUpdates.nullifierChecks).toEqual([ + expect.objectContaining({ nullifier: commitment, exists: true }), + expect.objectContaining({ nullifier: commitmentT1, exists: true }), ]); expect(journalUpdates.newNullifiers).toEqual([commitment, commitmentT1]); - expect(journalUpdates.l1ToL2MessageChecks.map(c => [c.leafIndex, c.msgHash, c.exists])).toEqual([ - [index, commitment, false], - [indexT1, commitmentT1, false], + expect(journalUpdates.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: index, msgHash: commitment, exists: false }), + expect.objectContaining({ leafIndex: indexT1, msgHash: commitmentT1, exists: false }), ]); }); @@ -274,14 +274,14 @@ describe('journal', () => { // Check that the world state _traces_ are merged even on rejection expect(journalUpdates.newNoteHashes).toEqual([commitment, commitmentT1]); - expect(journalUpdates.nullifierChecks.map(c => [c.nullifier, c.exists])).toEqual([ - [commitment, true], - [commitmentT1, true], + expect(journalUpdates.nullifierChecks).toEqual([ + expect.objectContaining({ nullifier: commitment, exists: true }), + expect.objectContaining({ nullifier: commitmentT1, exists: true }), ]); expect(journalUpdates.newNullifiers).toEqual([commitment, commitmentT1]); - expect(journalUpdates.l1ToL2MessageChecks.map(c => [c.leafIndex, c.msgHash, c.exists])).toEqual([ - [index, commitment, false], - [indexT1, commitmentT1, false], + expect(journalUpdates.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: index, msgHash: commitment, exists: false }), + expect.objectContaining({ leafIndex: indexT1, msgHash: commitmentT1, exists: false }), ]); // Check that rejected Accrued Substate is absent diff --git a/yarn-project/simulator/src/avm/journal/trace.test.ts b/yarn-project/simulator/src/avm/journal/trace.test.ts index 1b2cb5880c1..a7b309fbb30 100644 --- a/yarn-project/simulator/src/avm/journal/trace.test.ts +++ b/yarn-project/simulator/src/avm/journal/trace.test.ts @@ -224,5 +224,9 @@ describe('world state access trace', () => { exists: c.exists, })), ).toEqual([expectedMessageCheck, expectedMessageCheckT1]); + expect(trace.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: msgLeafIndex, msgHash: msgHash, exists: msgExists }), + expect.objectContaining({ leafIndex: msgLeafIndexT1, msgHash: msgHashT1, exists: msgExistsT1 }), + ]); }); }); diff --git a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts index 9a116891602..bb002317e54 100644 --- a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts @@ -191,8 +191,9 @@ describe('Accrued Substate', () => { expect(exists).toEqual(new Uint8(0)); const journalState = context.persistableState.flush(); - expect(journalState.nullifierChecks.length).toEqual(1); - expect(journalState.nullifierChecks[0].exists).toEqual(false); + expect(journalState.nullifierChecks).toEqual([ + expect.objectContaining({ nullifier: value.toFr(), exists: false }), + ]); }); it('Should correctly show true when nullifier exists', async () => { @@ -214,8 +215,9 @@ describe('Accrued Substate', () => { expect(exists).toEqual(new Uint8(1)); const journalState = context.persistableState.flush(); - expect(journalState.nullifierChecks.length).toEqual(1); - expect(journalState.nullifierChecks[0].exists).toEqual(true); + expect(journalState.nullifierChecks).toEqual([ + expect.objectContaining({ nullifier: value.toFr(), exists: true }), + ]); }); }); @@ -314,8 +316,9 @@ describe('Accrued Substate', () => { expect(exists).toEqual(new Uint8(0)); const journalState = context.persistableState.flush(); - expect(journalState.l1ToL2MessageChecks.length).toEqual(1); - expect(journalState.l1ToL2MessageChecks[0].exists).toEqual(false); + expect(journalState.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: leafIndex.toFr(), msgHash: msgHash.toFr(), exists: false }), + ]); }); it('Should correctly show true when L1ToL2 message exists', async () => { @@ -340,8 +343,9 @@ describe('Accrued Substate', () => { expect(exists).toEqual(new Uint8(1)); const journalState = context.persistableState.flush(); - expect(journalState.l1ToL2MessageChecks.length).toEqual(1); - expect(journalState.l1ToL2MessageChecks[0].exists).toEqual(true); + expect(journalState.l1ToL2MessageChecks).toEqual([ + expect.objectContaining({ leafIndex: leafIndex.toFr(), msgHash: msgHash.toFr(), exists: true }), + ]); }); });