From b9189bb6225defb4c6a89e44a4dd86b7d1a6a323 Mon Sep 17 00:00:00 2001 From: Minhyuk Kim Date: Tue, 10 Dec 2024 23:48:39 +0900 Subject: [PATCH] Add test for testing invalid proof size on rvsol --- rvsol/test/RISCV.t.sol | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rvsol/test/RISCV.t.sol b/rvsol/test/RISCV.t.sol index 79849ff..3b89c1d 100644 --- a/rvsol/test/RISCV.t.sol +++ b/rvsol/test/RISCV.t.sol @@ -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);