From 86af08377ab3ae8f504134cf7c3f2d9dabb2b833 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:06:38 +0000 Subject: [PATCH] fixup --- .../src/avm/opcodes/arithmetic.test.ts | 4 ++++ .../src/avm/opcodes/bitwise.test.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/yarn-project/acir-simulator/src/avm/opcodes/arithmetic.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/arithmetic.test.ts index 8d108ffabf23..a9911f8d82df 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/arithmetic.test.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/arithmetic.test.ts @@ -47,6 +47,10 @@ describe('Arithmetic Instructions', () => { describe('Sub', () => { it('Should subtract correctly over field elements', async () => { + const a = new Field(1n); + const b = new Field(2n); + + machineState.memory.set(0, a); machineState.memory.set(1, b); await new Sub(0, 1, 2).execute(machineState, journal); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts index 75ddc08776b1..ae8ce8027242 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts @@ -33,7 +33,10 @@ describe('Bitwise instructions', () => { machineState.memory.set(1, b); await new Or(TypeTag.UINT32, 0, 1, 2).execute(machineState, journal); + + const expected = new Uint32(0b11111110111011101111n); const actual = machineState.memory.get(2); + expect(actual).toEqual(expected); }); it('Should XOR correctly over integral types', async () => { @@ -59,7 +62,11 @@ describe('Bitwise instructions', () => { machineState.memory.set(1, b); await new Shr(TypeTag.UINT32, 0, 1, 2).execute(machineState, journal); + + const expected = a; const actual = machineState.memory.get(2); + expect(actual).toEqual(expected); + }); it('Should shift correctly 2 positions over integral types', async () => { const a = new Uint32(0b11111110010011100100n); @@ -76,6 +83,10 @@ describe('Bitwise instructions', () => { }); it('Should shift correctly 19 positions over integral types', async () => { + const a = new Uint32(0b11111110010011100100n); + const b = new Uint32(19n); + + machineState.memory.set(0, a); machineState.memory.set(1, b); await new Shr(TypeTag.UINT32, 0, 1, 2).execute(machineState, journal); @@ -109,7 +120,10 @@ describe('Bitwise instructions', () => { machineState.memory.set(1, b); await new Shl(TypeTag.UINT32, 0, 1, 2).execute(machineState, journal); + + const expected = new Uint32(0b1111111001001110010000n); const actual = machineState.memory.get(2); + expect(actual).toEqual(expected); }); it('Should shift correctly over bit limit over integral types', async () => { @@ -134,7 +148,10 @@ describe('Bitwise instructions', () => { machineState.memory.set(1, b); await new Shl(TypeTag.UINT16, 0, 1, 2).execute(machineState, journal); + + const expected = new Uint16(0b1001001110011100n); const actual = machineState.memory.get(2); + expect(actual).toEqual(expected); }); });