Skip to content

Commit 11f1cb9

Browse files
authored
Merge pull request #30 from ethereum-optimism/tip/import-disputetypes
rvsol: Import VMStatus from DisputeTypes.sol
2 parents 6e04b32 + e68b7ca commit 11f1cb9

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

rvsol/test/RISCV.t.sol

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { Test } from "forge-std/Test.sol";
55
import { RISCV } from "src/RISCV.sol";
66
import { PreimageOracle } from "@optimism/src/cannon/PreimageOracle.sol";
77
import { CommonTest } from "./CommonTest.sol";
8-
// FIXME: somehow this import gives a multiple declaration error
9-
// This import is for the VMStatus
10-
// import "@optimism/src/libraries/DisputeTypes.sol";
8+
import "@optimism/src/libraries/DisputeTypes.sol";
119

1210
contract RISCV_Test is CommonTest {
1311
/// @notice Stores the VM state.
@@ -2386,22 +2384,21 @@ contract RISCV_Test is CommonTest {
23862384
/// 1. Exited with success (Invalid)
23872385
/// 2. Exited with failure (Panic)
23882386
/// 3. Unfinished
2389-
// TODO: import DisputeTypes.sol. For some reason, import is not working
2390-
function vmStatus(State memory state) internal pure returns (uint8 out_) {
2387+
function vmStatus(State memory state) internal pure returns (VMStatus out_) {
23912388
if (!state.exited) {
2392-
return 3; // VMStatuses.UNFINISHED
2389+
return VMStatuses.UNFINISHED;
23932390
} else if (state.exitCode == 0) {
2394-
return 0; // VMStatuses.VALID
2391+
return VMStatuses.VALID;
23952392
} else if (state.exitCode == 1) {
2396-
return 1; // VMStatuses.INVALID
2393+
return VMStatuses.INVALID;
23972394
} else {
2398-
return 2; // VMStatuses.PANIC
2395+
return VMStatuses.PANIC;
23992396
}
24002397
}
24012398

24022399
function outputState(State memory state) internal pure returns (bytes32 out_) {
24032400
bytes memory enc = encodeState(state);
2404-
uint8 status = vmStatus(state);
2401+
VMStatus status = vmStatus(state);
24052402
assembly {
24062403
out_ := keccak256(add(enc, 0x20), 362)
24072404
out_ := or(and(not(shl(248, 0xFF)), out_), shl(248, status))

0 commit comments

Comments
 (0)