Skip to content

Commit

Permalink
Add test for testing invalid proof size on rvsol
Browse files Browse the repository at this point in the history
  • Loading branch information
mininny committed Dec 10, 2024
1 parent 2d5a55e commit b9189bb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rvsol/test/RISCV.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2371,11 +2371,22 @@ contract RISCV_Test is CommonTest {
riscv.step(encodedState, proof, 0);
}

function test_invalid_proof_size() public {
uint32 insn = encodeRType(0xff, 0, 0, 0, 0, 0);
(State memory state, bytes memory proof) = constructRISCVState(0, insn);
bytes memory encodedState = encodeState(state);
proof = hex"00"; // Invalid memory proof size

vm.expectRevert();
riscv.step(encodedState, proof, 0);
}

function test_invalid_proof() public {
uint32 insn = encodeRType(0xff, 0, 0, 0, 0, 0);
(State memory state, bytes memory proof) = constructRISCVState(0, insn);
bytes memory encodedState = encodeState(state);
proof = hex"00"; // Invalid memory proof
// Invalid memory proof
proof = hex"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

vm.expectRevert(hex"00000000000000000000000000000000000000000000000000000000badf00d1");
riscv.step(encodedState, proof, 0);
Expand Down

0 comments on commit b9189bb

Please sign in to comment.