Skip to content

Commit

Permalink
chore: add execution environment to merged tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Jan 23, 2024
1 parent 38dd382 commit 7fcc6cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import {
Shr,
Xor,
} from './bitwise.js';
import { initExecutionEnvironment } from '../fixtures/index.js';

describe('Bitwise instructions', () => {
let machineState: AvmMachineState;
let stateManager = mock<AvmStateManager>();

beforeEach(() => {
machineState = new AvmMachineState([]);
machineState = new AvmMachineState([], initExecutionEnvironment());
stateManager = mock<AvmStateManager>();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Add, Div, Mul, Sub } from './arithmetic.js';
import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js';
//import { Eq, Lt, Lte } from './comparators.js';
import {SLoad, SStore} from './storage.js';
import { InternalCall, InternalReturn, Jump, JumpI, Return } from './control_flow.js';
import { Instruction } from './instruction.js';
import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js';
Expand Down Expand Up @@ -75,8 +76,8 @@ export const INSTRUCTION_SET: Map<Opcode, InstructionConstructorAndMembers> = ne

//// World State
//[Opcode.BLOCKHEADERBYNUMBER, Blockheaderbynumber],
//[Opcode.SLOAD, Sload], // Public Storage
//[Opcode.SSTORE, Sstore], // Public Storage
[Opcode.SLOAD, SLoad], // Public Storage
[Opcode.SSTORE, SStore], // Public Storage
//[Opcode.READL1TOL2MSG, Readl1tol2msg], // Messages
//[Opcode.SENDL2TOL1MSG, Sendl2tol1msg], // Messages
//[Opcode.EMITNOTEHASH, Emitnotehash], // Notes & Nullifiers
Expand Down
9 changes: 5 additions & 4 deletions yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { mock } from 'jest-mock-extended';
import { AvmMachineState } from '../avm_machine_state.js';
import { AvmStateManager } from '../avm_state_manager.js';
import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js';
import { initExecutionEnvironment } from '../fixtures/index.js';

describe('Memory instructions', () => {
let machineState: AvmMachineState;
let stateManager = mock<AvmStateManager>();

beforeEach(() => {
machineState = new AvmMachineState([]);
machineState = new AvmMachineState([], initExecutionEnvironment());
stateManager = mock<AvmStateManager>();
});

Expand Down Expand Up @@ -141,7 +142,7 @@ describe('Memory instructions', () => {
const previousValue = new Fr(123456n);
const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)];

machineState = new AvmMachineState(calldata);
machineState = new AvmMachineState(calldata, initExecutionEnvironment());
machineState.writeMemory(0, previousValue);

new CalldataCopy(/*cdOffset=*/ 2, /*copySize=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager);
Expand All @@ -154,7 +155,7 @@ describe('Memory instructions', () => {
const previousValue = new Fr(123456n);
const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)];

machineState = new AvmMachineState(calldata);
machineState = new AvmMachineState(calldata, initExecutionEnvironment());
machineState.writeMemory(0, previousValue);

new CalldataCopy(/*cdOffset=*/ 0, /*copySize=*/ 3, /*dstOffset=*/ 0).execute(machineState, stateManager);
Expand All @@ -167,7 +168,7 @@ describe('Memory instructions', () => {
const previousValue = new Fr(123456n);
const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)];

machineState = new AvmMachineState(calldata);
machineState = new AvmMachineState(calldata, initExecutionEnvironment());
machineState.writeMemory(0, previousValue);

new CalldataCopy(/*cdOffset=*/ 1, /*copySize=*/ 2, /*dstOffset=*/ 0).execute(machineState, stateManager);
Expand Down

0 comments on commit 7fcc6cf

Please sign in to comment.