Skip to content

Commit

Permalink
Fixes in integration tests, refactoring of makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymMalicki committed Nov 27, 2024
1 parent ded9ec9 commit de64088
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ integration:
fi; \
if [ ! -f ./rust_vm_bin/cairo/cairo1-run ] || [ ! -f ./rust_vm_bin/cairo-vm-cli ]; then \
git clone https://github.com/lambdaclass/cairo-vm.git && \
cd cairo-vm/cairo1-run; \
cargo build --release; \
cd ../cairo-vm-cli; \
cargo build --release; \
cd ../../; \
cd cairo-vm/; \
cargo build --release --bin cairo-vm-cli --bin cairo1-run; \
cd ..; \
mv cairo-vm/target/release/cairo1-run ../cairo/ && \
mv cairo-vm/target/release/cairo-vm-cli ../../rust_vm_bin/ && \
rm -rf cairo-vm; \
Expand Down
31 changes: 17 additions & 14 deletions integration_tests/cairozero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ func runAndTestFile(t *testing.T, path string, name string, benchmarkMap map[str
t.Error(err)
return
}

elapsedRs, rsTraceFile, rsMemoryFile, err := runRustVm(name, path, zero)
layout := getLayoutFromFileName(path)
rustVmFilePath := path
if zero {
rustVmFilePath = compiledOutput
}
elapsedRs, rsTraceFile, rsMemoryFile, err := runRustVm(name, rustVmFilePath, layout, zero)
if errorExpected {
// we let the code go on so that we can check if the go vm also raises an error
assert.Error(t, err, path)
Expand All @@ -71,7 +75,7 @@ func runAndTestFile(t *testing.T, path string, name string, benchmarkMap map[str
}
}

elapsedGo, traceFile, memoryFile, _, err := runVm(compiledOutput, zero)
elapsedGo, traceFile, memoryFile, _, err := runVm(compiledOutput, layout, zero)
if errorExpected {
assert.Error(t, err, path)
return
Expand Down Expand Up @@ -103,7 +107,7 @@ func runAndTestFile(t *testing.T, path string, name string, benchmarkMap map[str
}

if zero {
elapsedPy, pyTraceFile, pyMemoryFile, err := runPythonVm(name, compiledOutput)
elapsedPy, pyTraceFile, pyMemoryFile, err := runPythonVm(name, compiledOutput, layout)
if errorExpected {
// we let the code go on so that we can check if the go vm also raises an error
assert.Error(t, err, path)
Expand Down Expand Up @@ -300,7 +304,7 @@ func compileCairoCode(path string, zero bool) (string, error) {
}
} else {
sierraOutput := swapExtenstion(path, sierraSuffix)
cliCommand = "../rust_vm_bin/cairo1-compile/cairo-compile"
cliCommand = "../rust_vm_bin/cairo/cairo-compile"
args = []string{
"--single-file",
path,
Expand All @@ -317,7 +321,7 @@ func compileCairoCode(path string, zero bool) (string, error) {
)
}

cliCommand = "../rust_vm_bin/cairo1-compile/sierra-compile-json"
cliCommand = "../rust_vm_bin/cairo/sierra-compile-json"
args = []string{
sierraOutput,
compiledOutput,
Expand All @@ -338,7 +342,7 @@ func compileCairoCode(path string, zero bool) (string, error) {

// given a path to a compiled cairo zero file, execute it using the
// python vm and returns the trace and memory files location
func runPythonVm(testFilename, path string) (time.Duration, string, string, error) {
func runPythonVm(testFilename, path, layout string) (time.Duration, string, string, error) {
traceOutput := swapExtenstion(path, pyTraceSuffix)
memoryOutput := swapExtenstion(path, pyMemorySuffix)

Expand All @@ -351,7 +355,7 @@ func runPythonVm(testFilename, path string) (time.Duration, string, string, erro
"--memory_file",
memoryOutput,
"--layout",
getLayoutFromFileName(testFilename),
layout,
}

cmd := exec.Command("cairo-run", args...)
Expand All @@ -373,7 +377,7 @@ func runPythonVm(testFilename, path string) (time.Duration, string, string, erro

// given a path to a compiled cairo zero file, execute it using the
// rust vm and return the trace and memory files location
func runRustVm(testFilename, path string, zero bool) (time.Duration, string, string, error) {
func runRustVm(testFilename, path, layout string, zero bool) (time.Duration, string, string, error) {
traceOutput := swapExtenstion(path, rsTraceSuffix)
memoryOutput := swapExtenstion(path, rsMemorySuffix)

Expand All @@ -384,14 +388,14 @@ func runRustVm(testFilename, path string, zero bool) (time.Duration, string, str
"--memory_file",
memoryOutput,
"--layout",
getLayoutFromFileName(testFilename),
layout,
}

if zero {
args = append(args, "--proof_mode")
}

binaryPath := "./../rust_vm_bin/cairo1-compile/cairo1-run"
binaryPath := "./../rust_vm_bin/cairo/cairo1-run"
if zero {
binaryPath = "./../rust_vm_bin/cairo-vm-cli"
}
Expand All @@ -414,15 +418,14 @@ func runRustVm(testFilename, path string, zero bool) (time.Duration, string, str

// given a path to a compiled cairo zero file, execute
// it using our vm
func runVm(path string, zero bool) (time.Duration, string, string, string, error) {
func runVm(path, layout string, zero bool) (time.Duration, string, string, string, error) {
traceOutput := swapExtenstion(path, traceSuffix)
memoryOutput := swapExtenstion(path, memorySuffix)

cliCommand := "cairo-run"
if zero {
cliCommand = "run"
}

args := []string{
cliCommand,
"--proofmode",
Expand All @@ -431,7 +434,7 @@ func runVm(path string, zero bool) (time.Duration, string, string, string, error
"--memoryfile",
memoryOutput,
"--layout",
getLayoutFromFileName(path),
layout,
path,
}

Expand Down
Binary file modified rust_vm_bin/cairo-vm-cli
Binary file not shown.

0 comments on commit de64088

Please sign in to comment.