-
Notifications
You must be signed in to change notification settings - Fork 139
KEVM Testing
- You need to be able to build the K framework as detailed here.
- Installing the required dependencies will need the
JAVA_HOMEenvironment variable to point to the installed JDK. - Having the
evm-semanticsgit repository cloned locally.
$ cd evm-semantics
$ make deps split-tests -B -j2
$ make build-java -j2
$ git submodule update --initAfter building the definition, you can run the tests using ./kevm.
Read the kevm script for more details.
Here is an example showing how to run the add0.json test file using the java backend:
$ MODE=VMTESTS SCHEDULE=DEFAULT ./kevm run --backend java tests/ethereum-tests/VMTests/vmArithmeticTest/add0.jsonNotes: You can also export MODE and SCHEDULE as environment variables to avoid specifying them on every run.
You can run the test using different backends: ocaml|java|haskell|haskell-perf. The preferred backend can be chosen using --backend argument. By default, OCaml is selected.
Run the same file as a test:
$ ./kevm test tests/ethereum-tests/VMTests/vmArithmeticTest/add0.jsonTo run proofs, you can similarly use ./kevm.
For example, to prove the specification tests/proofs/specs/vyper-erc20/totalSupply-spec.k:
$ ./kevm prove tests/proofs/specs/vyper-erc20/totalSupply-spec.kFinally, if you want to debug a given program (by stepping through its execution), you can use the debug option:
$ ./kevm debug tests/ethereum-tests/VMTests/vmArithmeticTest/add0.json
...
KDebug> s
1 Step(s) Taken.
KDebug> p
... Big Configuration Here ...
KDebug>Notes: options for KDebug:
| Instruction | Info |
|---|---|
s | step
|
execute one step |
s <n> | step <n>
|
execute <n> steps |
p | peek
|
print current configuration |
r | resume
|
execute all remaining steps |
b |
roll back one step |
b <n> |
roll back <n> steps |
j <i> |
jump to step <i>
|
Normal usage:
$ ./kevm run [--backend <backend>] <pgm> <K args>*
$ ./kevm search <pgm> <K args>*
$ ./kevm prove <spec> <K args>*-
runRun a single EVM program -
searchRun a program searching for all execution paths -
proveAttempt to prove the specification using K's RL prover
Notes:
-
<pgm>represents a path to a Ethereum test program -
<spec>represents a path to a specification file -
<K args>are any options you want to pass directly toKlike:-
--debug: output more debugging information when running/proving. -
--help: display the help message.
-
More commands for devs and CI servers:
$ ./kevm interpret <pgm>
$ ./kevm [test|test-profile] [--backend <backend>] <pgm> <output>
$ ./kevm sort-logs
$ ./kevm get-failing [<count>]-
interpretRun a single EVM program (in JSON testing format) using fast interpreter -
testRun a single EVM program like it's a test. -
test-profileSame as test, but generate list of failing tests and dump timing information -
sort-logsNormalize the test logs for CI servers to use -
get-failingReturn a list of failing tests, at most<count>.
Notes:
-
<output>is the expected output of the given test. - Unlike
run, thetestcommand will create a log file at the path.build/logs/<testName>.log. Where<testName>represents the whole given argument (i.e.tests/ethereum-tests/VMTests/vmArithmeticTest/add0.json) This command will also compare the execution output with the content of an expected file. The name of the file must be<testName>.out, otherwise the default expected file will betests/templates/output-success-<backend>.json.