Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
5e998b27
Unverified
Commit
5e998b27
authored
Aug 10, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linting; assertEq
parent
28046fb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
96 deletions
+96
-96
CommonTest.t.sol
packages/contracts-bedrock/test/CommonTest.t.sol
+12
-20
MIPS.t.sol
packages/contracts-bedrock/test/MIPS.t.sol
+84
-76
No files found.
packages/contracts-bedrock/test/CommonTest.t.sol
View file @
5e998b27
...
@@ -679,31 +679,26 @@ contract FFIInterface is Test {
...
@@ -679,31 +679,26 @@ contract FFIInterface is Test {
return abi.decode(vm.ffi(cmds), (bytes32, bytes, bytes, bytes[]));
return abi.decode(vm.ffi(cmds), (bytes32, bytes, bytes, bytes[]));
}
}
function getCannonMemoryProof(uint32 pc, uint32 insn)
function getCannonMemoryProof(uint32 pc, uint32 insn) external returns (bytes32, bytes memory) {
external
returns (
bytes32,
bytes memory
) {
string[] memory cmds = new string[](4);
string[] memory cmds = new string[](4);
cmds[0] = "scripts/differential-testing/differential-testing";
cmds[0] = "scripts/differential-testing/differential-testing";
cmds[1] = "cannonMemoryProof";
cmds[1] = "cannonMemoryProof";
cmds[2] = vm.toString(pc);
cmds[2] = vm.toString(pc);
cmds[3] = vm.toString(insn);
cmds[3] = vm.toString(insn);
bytes memory result = vm.ffi(cmds);
bytes memory result = vm.ffi(cmds);
(
(bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes));
bytes32 memRoot,
bytes memory proof
) = abi.decode(result, (bytes32, bytes));
return (memRoot, proof);
return (memRoot, proof);
}
}
function getCannonMemoryProof(uint32 pc, uint32 insn, uint32 memAddr, uint32 memVal)
function getCannonMemoryProof(
external
uint32 pc,
returns (
uint32 insn,
bytes32,
uint32 memAddr,
bytes memory
uint32 memVal
) {
)
external
returns (bytes32, bytes memory)
{
string[] memory cmds = new string[](6);
string[] memory cmds = new string[](6);
cmds[0] = "scripts/differential-testing/differential-testing";
cmds[0] = "scripts/differential-testing/differential-testing";
cmds[1] = "cannonMemoryProof";
cmds[1] = "cannonMemoryProof";
...
@@ -712,10 +707,7 @@ contract FFIInterface is Test {
...
@@ -712,10 +707,7 @@ contract FFIInterface is Test {
cmds[4] = vm.toString(memAddr);
cmds[4] = vm.toString(memAddr);
cmds[5] = vm.toString(memVal);
cmds[5] = vm.toString(memVal);
bytes memory result = vm.ffi(cmds);
bytes memory result = vm.ffi(cmds);
(
(bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes));
bytes32 memRoot,
bytes memory proof
) = abi.decode(result, (bytes32, bytes));
return (memRoot, proof);
return (memRoot, proof);
}
}
}
}
...
...
packages/contracts-bedrock/test/MIPS.t.sol
View file @
5e998b27
...
@@ -59,7 +59,7 @@ contract MIPS_Test is CommonTest {
...
@@ -59,7 +59,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_addu_succeeds() external {
function test_addu_succeeds() external {
...
@@ -79,7 +79,7 @@ contract MIPS_Test is CommonTest {
...
@@ -79,7 +79,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_addi_succeeds() external {
function test_addi_succeeds() external {
...
@@ -99,7 +99,7 @@ contract MIPS_Test is CommonTest {
...
@@ -99,7 +99,7 @@ contract MIPS_Test is CommonTest {
expect.registers[17] = state.registers[17];
expect.registers[17] = state.registers[17];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_addui_succeeds() external {
function test_addui_succeeds() external {
...
@@ -119,7 +119,7 @@ contract MIPS_Test is CommonTest {
...
@@ -119,7 +119,7 @@ contract MIPS_Test is CommonTest {
expect.registers[17] = state.registers[17];
expect.registers[17] = state.registers[17];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sub_succeeds() external {
function test_sub_succeeds() external {
...
@@ -139,7 +139,7 @@ contract MIPS_Test is CommonTest {
...
@@ -139,7 +139,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_subu_succeeds() external {
function test_subu_succeeds() external {
...
@@ -159,7 +159,7 @@ contract MIPS_Test is CommonTest {
...
@@ -159,7 +159,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_and_succeeds() external {
function test_and_succeeds() external {
...
@@ -179,7 +179,7 @@ contract MIPS_Test is CommonTest {
...
@@ -179,7 +179,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_andi_succeeds() external {
function test_andi_succeeds() external {
...
@@ -199,7 +199,7 @@ contract MIPS_Test is CommonTest {
...
@@ -199,7 +199,7 @@ contract MIPS_Test is CommonTest {
expect.registers[17] = state.registers[17];
expect.registers[17] = state.registers[17];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_or_succeeds() external {
function test_or_succeeds() external {
...
@@ -219,7 +219,7 @@ contract MIPS_Test is CommonTest {
...
@@ -219,7 +219,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_ori_succeeds() external {
function test_ori_succeeds() external {
...
@@ -239,7 +239,7 @@ contract MIPS_Test is CommonTest {
...
@@ -239,7 +239,7 @@ contract MIPS_Test is CommonTest {
expect.registers[17] = state.registers[17];
expect.registers[17] = state.registers[17];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_xor_succeeds() external {
function test_xor_succeeds() external {
...
@@ -259,7 +259,7 @@ contract MIPS_Test is CommonTest {
...
@@ -259,7 +259,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_xori_succeeds() external {
function test_xori_succeeds() external {
...
@@ -279,7 +279,7 @@ contract MIPS_Test is CommonTest {
...
@@ -279,7 +279,7 @@ contract MIPS_Test is CommonTest {
expect.registers[17] = state.registers[17];
expect.registers[17] = state.registers[17];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_nor_succeeds() external {
function test_nor_succeeds() external {
...
@@ -299,7 +299,7 @@ contract MIPS_Test is CommonTest {
...
@@ -299,7 +299,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_slt_succeeds() external {
function test_slt_succeeds() external {
...
@@ -318,7 +318,7 @@ contract MIPS_Test is CommonTest {
...
@@ -318,7 +318,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
// swap and check again
// swap and check again
uint32 tmp = state.registers[17];
uint32 tmp = state.registers[17];
...
@@ -328,7 +328,7 @@ contract MIPS_Test is CommonTest {
...
@@ -328,7 +328,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
expect.registers[8] = state.registers[17] < state.registers[18] ? 1 : 0; // t0
expect.registers[8] = state.registers[17] < state.registers[18] ? 1 : 0; // t0
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sltu_succeeds() external {
function test_sltu_succeeds() external {
...
@@ -348,7 +348,7 @@ contract MIPS_Test is CommonTest {
...
@@ -348,7 +348,7 @@ contract MIPS_Test is CommonTest {
expect.registers[18] = state.registers[18];
expect.registers[18] = state.registers[18];
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lb_succeeds() external {
function test_lb_succeeds() external {
...
@@ -368,7 +368,7 @@ contract MIPS_Test is CommonTest {
...
@@ -368,7 +368,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lh_succeeds() external {
function test_lh_succeeds() external {
...
@@ -390,7 +390,7 @@ contract MIPS_Test is CommonTest {
...
@@ -390,7 +390,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lw_succeeds() external {
function test_lw_succeeds() external {
...
@@ -412,7 +412,7 @@ contract MIPS_Test is CommonTest {
...
@@ -412,7 +412,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lbu_succeeds() external {
function test_lbu_succeeds() external {
...
@@ -432,7 +432,7 @@ contract MIPS_Test is CommonTest {
...
@@ -432,7 +432,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lhu_succeeds() external {
function test_lhu_succeeds() external {
...
@@ -452,7 +452,7 @@ contract MIPS_Test is CommonTest {
...
@@ -452,7 +452,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lwl_succeeds() external {
function test_lwl_succeeds() external {
...
@@ -471,7 +471,7 @@ contract MIPS_Test is CommonTest {
...
@@ -471,7 +471,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
// test unaligned address
// test unaligned address
insn = encodeitype(0x22, 0x9, 0x8, 0x5); // lwl $t0, 5($t1)
insn = encodeitype(0x22, 0x9, 0x8, 0x5); // lwl $t0, 5($t1)
...
@@ -479,7 +479,7 @@ contract MIPS_Test is CommonTest {
...
@@ -479,7 +479,7 @@ contract MIPS_Test is CommonTest {
expect.memRoot = state.memRoot;
expect.memRoot = state.memRoot;
expect.registers[8] = 0x34_56_78_dd; // t0
expect.registers[8] = 0x34_56_78_dd; // t0
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lwr_succeeds() external {
function test_lwr_succeeds() external {
...
@@ -498,7 +498,7 @@ contract MIPS_Test is CommonTest {
...
@@ -498,7 +498,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
// test unaligned address
// test unaligned address
insn = encodeitype(0x26, 0x9, 0x8, 0x5); // lwr $t0, 5($t1)
insn = encodeitype(0x26, 0x9, 0x8, 0x5); // lwr $t0, 5($t1)
...
@@ -506,7 +506,7 @@ contract MIPS_Test is CommonTest {
...
@@ -506,7 +506,7 @@ contract MIPS_Test is CommonTest {
expect.memRoot = state.memRoot;
expect.memRoot = state.memRoot;
expect.registers[8] = 0xaa_bb_12_34; // t0
expect.registers[8] = 0xaa_bb_12_34; // t0
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sb_succeeds() external {
function test_sb_succeeds() external {
...
@@ -526,7 +526,7 @@ contract MIPS_Test is CommonTest {
...
@@ -526,7 +526,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sh_succeeds() external {
function test_sh_succeeds() external {
...
@@ -545,7 +545,7 @@ contract MIPS_Test is CommonTest {
...
@@ -545,7 +545,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_swl_succeeds() external {
function test_swl_succeeds() external {
...
@@ -564,7 +564,7 @@ contract MIPS_Test is CommonTest {
...
@@ -564,7 +564,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sw_succeeds() external {
function test_sw_succeeds() external {
...
@@ -583,7 +583,7 @@ contract MIPS_Test is CommonTest {
...
@@ -583,7 +583,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_swr_succeeds() external {
function test_swr_succeeds() external {
...
@@ -602,7 +602,7 @@ contract MIPS_Test is CommonTest {
...
@@ -602,7 +602,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_ll_succeeds() external {
function test_ll_succeeds() external {
...
@@ -624,7 +624,7 @@ contract MIPS_Test is CommonTest {
...
@@ -624,7 +624,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = t1;
expect.registers[9] = t1;
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sc_succeeds() external {
function test_sc_succeeds() external {
...
@@ -643,7 +643,7 @@ contract MIPS_Test is CommonTest {
...
@@ -643,7 +643,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_movn_succeeds() external {
function test_movn_succeeds() external {
...
@@ -664,13 +664,13 @@ contract MIPS_Test is CommonTest {
...
@@ -664,13 +664,13 @@ contract MIPS_Test is CommonTest {
expect.registers[10] = state.registers[10];
expect.registers[10] = state.registers[10];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
state.registers[10] = 0x0; // t2
state.registers[10] = 0x0; // t2
expect.registers[10] = 0x0; // t2
expect.registers[10] = 0x0; // t2
expect.registers[8] = state.registers[8];
expect.registers[8] = state.registers[8];
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_movz_succeeds() external {
function test_movz_succeeds() external {
...
@@ -691,13 +691,13 @@ contract MIPS_Test is CommonTest {
...
@@ -691,13 +691,13 @@ contract MIPS_Test is CommonTest {
expect.registers[10] = state.registers[10];
expect.registers[10] = state.registers[10];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
state.registers[10] = 0x1; // t2
state.registers[10] = 0x1; // t2
expect.registers[10] = 0x1; // t2
expect.registers[10] = 0x1; // t2
expect.registers[8] = state.registers[8];
expect.registers[8] = state.registers[8];
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mflo_succeeds() external {
function test_mflo_succeeds() external {
...
@@ -714,7 +714,7 @@ contract MIPS_Test is CommonTest {
...
@@ -714,7 +714,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = state.lo;
expect.registers[8] = state.lo;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mfhi_succeeds() external {
function test_mfhi_succeeds() external {
...
@@ -731,7 +731,7 @@ contract MIPS_Test is CommonTest {
...
@@ -731,7 +731,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = state.hi;
expect.registers[8] = state.hi;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mthi_succeeds() external {
function test_mthi_succeeds() external {
...
@@ -748,7 +748,7 @@ contract MIPS_Test is CommonTest {
...
@@ -748,7 +748,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = state.registers[8];
expect.registers[8] = state.registers[8];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mtlo_succeeds() external {
function test_mtlo_succeeds() external {
...
@@ -765,7 +765,7 @@ contract MIPS_Test is CommonTest {
...
@@ -765,7 +765,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = state.registers[8];
expect.registers[8] = state.registers[8];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mul_succeeds() external {
function test_mul_succeeds() external {
...
@@ -784,7 +784,7 @@ contract MIPS_Test is CommonTest {
...
@@ -784,7 +784,7 @@ contract MIPS_Test is CommonTest {
expect.registers[10] = 2;
expect.registers[10] = 2;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mult_succeeds() external {
function test_mult_succeeds() external {
...
@@ -805,7 +805,7 @@ contract MIPS_Test is CommonTest {
...
@@ -805,7 +805,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_multu_succeeds() external {
function test_multu_succeeds() external {
...
@@ -826,7 +826,7 @@ contract MIPS_Test is CommonTest {
...
@@ -826,7 +826,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_div_succeeds() external {
function test_div_succeeds() external {
...
@@ -847,7 +847,7 @@ contract MIPS_Test is CommonTest {
...
@@ -847,7 +847,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_divu_succeeds() external {
function test_divu_succeeds() external {
...
@@ -868,7 +868,7 @@ contract MIPS_Test is CommonTest {
...
@@ -868,7 +868,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_beq_succeeds() external {
function test_beq_succeeds() external {
...
@@ -887,14 +887,14 @@ contract MIPS_Test is CommonTest {
...
@@ -887,14 +887,14 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = 0xdeadbeef;
expect.registers[9] = 0xdeadbeef;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
// branch not taken
// branch not taken
state.registers[8] = 0xaa;
state.registers[8] = 0xaa;
expect.registers[8] = 0xaa;
expect.registers[8] = 0xaa;
expect.nextPC = state.nextPC + 4;
expect.nextPC = state.nextPC + 4;
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_bne_succeeds() external {
function test_bne_succeeds() external {
...
@@ -913,7 +913,7 @@ contract MIPS_Test is CommonTest {
...
@@ -913,7 +913,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = 0xaa;
expect.registers[9] = 0xaa;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_blez_succeeds() external {
function test_blez_succeeds() external {
...
@@ -930,7 +930,7 @@ contract MIPS_Test is CommonTest {
...
@@ -930,7 +930,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = 0;
expect.registers[8] = 0;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_bgtz_succeeds() external {
function test_bgtz_succeeds() external {
...
@@ -948,7 +948,7 @@ contract MIPS_Test is CommonTest {
...
@@ -948,7 +948,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_bltz_succeeds() external {
function test_bltz_succeeds() external {
...
@@ -965,7 +965,7 @@ contract MIPS_Test is CommonTest {
...
@@ -965,7 +965,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = 0xF0_00_00_00;
expect.registers[8] = 0xF0_00_00_00;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_bgez_succeeds() external {
function test_bgez_succeeds() external {
...
@@ -982,7 +982,7 @@ contract MIPS_Test is CommonTest {
...
@@ -982,7 +982,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = 0x00_00_00_01;
expect.registers[8] = 0x00_00_00_01;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_jump_succeeds() external {
function test_jump_succeeds() external {
...
@@ -997,7 +997,7 @@ contract MIPS_Test is CommonTest {
...
@@ -997,7 +997,7 @@ contract MIPS_Test is CommonTest {
expect.step = state.step + 1;
expect.step = state.step + 1;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_jal_succeeds() external {
function test_jal_succeeds() external {
...
@@ -1019,7 +1019,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1019,7 +1019,7 @@ contract MIPS_Test is CommonTest {
expect.registers[31] = state.pc + 8;
expect.registers[31] = state.pc + 8;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_jr_succeeds() external {
function test_jr_succeeds() external {
...
@@ -1036,7 +1036,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1036,7 +1036,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = tgt;
expect.registers[8] = tgt;
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_jalr_succeeds() external {
function test_jalr_succeeds() external {
...
@@ -1054,7 +1054,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1054,7 +1054,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.pc + 8; // t1
expect.registers[9] = state.pc + 8; // t1
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sll_succeeds() external {
function test_sll_succeeds() external {
...
@@ -1073,7 +1073,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1073,7 +1073,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_srl_succeeds() external {
function test_srl_succeeds() external {
...
@@ -1092,7 +1092,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1092,7 +1092,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sra_succeeds() external {
function test_sra_succeeds() external {
...
@@ -1111,7 +1111,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1111,7 +1111,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_sllv_succeeds() external {
function test_sllv_succeeds() external {
...
@@ -1131,7 +1131,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1131,7 +1131,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_srlv_succeeds() external {
function test_srlv_succeeds() external {
...
@@ -1151,7 +1151,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1151,7 +1151,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_srav_succeeds() external {
function test_srav_succeeds() external {
...
@@ -1171,7 +1171,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1171,7 +1171,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_lui_succeeds() external {
function test_lui_succeeds() external {
...
@@ -1187,7 +1187,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1187,7 +1187,7 @@ contract MIPS_Test is CommonTest {
expect.registers[8] = 0x00_04_00_00; // t0
expect.registers[8] = 0x00_04_00_00; // t0
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_clo_succeeds() external {
function test_clo_succeeds() external {
...
@@ -1204,7 +1204,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1204,7 +1204,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_clz_succeeds() external {
function test_clz_succeeds() external {
...
@@ -1221,7 +1221,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1221,7 +1221,7 @@ contract MIPS_Test is CommonTest {
expect.registers[9] = state.registers[9];
expect.registers[9] = state.registers[9];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_preimage_read_succeeds() external {
function test_preimage_read_succeeds() external {
...
@@ -1270,7 +1270,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1270,7 +1270,7 @@ contract MIPS_Test is CommonTest {
(expect.memRoot,) = ffi.getCannonMemoryProof(pc, insn, a1, 0xdeadbeef);
(expect.memRoot,) = ffi.getCannonMemoryProof(pc, insn, a1, 0xdeadbeef);
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_preimage_write_succeeds() external {
function test_preimage_write_succeeds() external {
...
@@ -1312,7 +1312,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1312,7 +1312,7 @@ contract MIPS_Test is CommonTest {
expect.registers[7] = 0; // errno
expect.registers[7] = 0; // errno
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_mmap_succeeds() external {
function test_mmap_succeeds() external {
...
@@ -1339,7 +1339,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1339,7 +1339,7 @@ contract MIPS_Test is CommonTest {
expect.registers[5] = 4095; // a1
expect.registers[5] = 4095; // a1
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_brk_succeeds() external {
function test_brk_succeeds() external {
...
@@ -1358,7 +1358,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1358,7 +1358,7 @@ contract MIPS_Test is CommonTest {
expect.registers[4] = state.registers[4]; // registers unchanged
expect.registers[4] = state.registers[4]; // registers unchanged
bytes32 postState = mips.step(encodedState, proof);
bytes32 postState = mips.step(encodedState, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_clone_succeeds() external {
function test_clone_succeeds() external {
...
@@ -1375,7 +1375,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1375,7 +1375,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_exit_succeeds() external {
function test_exit_succeeds() external {
...
@@ -1395,7 +1395,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1395,7 +1395,7 @@ contract MIPS_Test is CommonTest {
expect.exitCode = uint8(state.registers[4]);
expect.exitCode = uint8(state.registers[4]);
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_fcntl_succeeds() external {
function test_fcntl_succeeds() external {
...
@@ -1414,14 +1414,14 @@ contract MIPS_Test is CommonTest {
...
@@ -1414,14 +1414,14 @@ contract MIPS_Test is CommonTest {
expect.registers[5] = state.registers[5];
expect.registers[5] = state.registers[5];
bytes32 postState = mips.step(encodeState(state), proof);
bytes32 postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
// assert O_WRONLY
// assert O_WRONLY
state.registers[4] = 0x1; // a0
state.registers[4] = 0x1; // a0
expect.registers[4] = state.registers[4];
expect.registers[4] = state.registers[4];
expect.registers[2] = 1;
expect.registers[2] = 1;
postState = mips.step(encodeState(state), proof);
postState = mips.step(encodeState(state), proof);
assert
True(postState ==
outputState(expect), "unexpected post state");
assert
Eq(postState,
outputState(expect), "unexpected post state");
}
}
function test_prestate_exited_succeeds() external {
function test_prestate_exited_succeeds() external {
...
@@ -1431,7 +1431,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1431,7 +1431,7 @@ contract MIPS_Test is CommonTest {
bytes memory enc = encodeState(state);
bytes memory enc = encodeState(state);
bytes32 postState = mips.step(enc, proof);
bytes32 postState = mips.step(enc, proof);
assert
True(postState ==
outputState(state), "unexpected post state");
assert
Eq(postState,
outputState(state), "unexpected post state");
}
}
function test_illegal_instruction_fails() external {
function test_illegal_instruction_fails() external {
...
@@ -1455,7 +1455,7 @@ contract MIPS_Test is CommonTest {
...
@@ -1455,7 +1455,7 @@ contract MIPS_Test is CommonTest {
state.registers[4] = 0x5; // a0
state.registers[4] = 0x5; // a0
// invalidate proof
// invalidate proof
for (uint i = 0; i < proof.length; i++) {
for (uint
256
i = 0; i < proof.length; i++) {
proof[i] = 0x0;
proof[i] = 0x0;
}
}
vm.expectRevert(hex"000000000000000000000000000000000000000000000000000000000badf00d");
vm.expectRevert(hex"000000000000000000000000000000000000000000000000000000000badf00d");
...
@@ -1512,7 +1512,15 @@ contract MIPS_Test is CommonTest {
...
@@ -1512,7 +1512,15 @@ contract MIPS_Test is CommonTest {
}
}
}
}
function constructMIPSState(uint32 pc, uint32 insn, uint32 addr, uint32 val) internal returns (MIPS.State memory state, bytes memory proof) {
function constructMIPSState(
uint32 pc,
uint32 insn,
uint32 addr,
uint32 val
)
internal
returns (MIPS.State memory state, bytes memory proof)
{
(state.memRoot, proof) = ffi.getCannonMemoryProof(pc, insn, addr, val);
(state.memRoot, proof) = ffi.getCannonMemoryProof(pc, insn, addr, val);
state.pc = pc;
state.pc = pc;
state.nextPC = pc + 4;
state.nextPC = pc + 4;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment