Skip to content

Commit

Permalink
cannon: Update MIPS.t.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton committed Sep 25, 2024
1 parent c9b68ac commit bbe3c35
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/contracts-bedrock/test/cannon/MIPS.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ contract MIPS_Test is CommonTest {
assertEq(postState, outputState(expect), "unexpected post state");
}

function test_fcntl_succeeds() external {
function test_fcntl_getfl_succeeds() external {
uint32 insn = 0x0000000c; // syscall
(MIPS.State memory state, bytes memory proof) = constructMIPSState(0, insn, 0x4, 0);
state.registers[2] = 4055; // fcntl syscall
Expand All @@ -1631,6 +1631,25 @@ contract MIPS_Test is CommonTest {
assertEq(postState, outputState(expect), "unexpected post state");
}

function test_fcntl_getfd_succeeds() external {
uint32 insn = 0x0000000c; // syscall
(MIPS.State memory state, bytes memory proof) = constructMIPSState(0, insn, 0x4, 0);
state.registers[2] = 4055; // fcntl syscall
state.registers[4] = 0x0; // a0
state.registers[5] = 0x1; // a1

MIPS.State memory expect;
expect.memRoot = state.memRoot;
expect.pc = state.nextPC;
expect.nextPC = state.nextPC + 4;
expect.step = state.step + 1;
expect.registers[2] = 0;
expect.registers[5] = state.registers[5];

bytes32 postState = mips.step(encodeState(state), proof, 0);
assertEq(postState, outputState(expect), "unexpected post state");
}

function test_prestate_exited_succeeds() external {
uint32 insn = 0x0000000c; // syscall
(MIPS.State memory state, bytes memory proof) = constructMIPSState(0, insn, 0x4, 0);
Expand Down

0 comments on commit bbe3c35

Please sign in to comment.