Skip to content

Commit

Permalink
Add binaries of cairo1-runner, cairo-compile, sierra-compile-json, ad…
Browse files Browse the repository at this point in the history
…d fetching corelib when nonexistent
  • Loading branch information
MaksymMalicki committed Nov 26, 2024
1 parent c47fdd9 commit 194bad4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ integration_tests/BenchMarks.txt
.python-version
.DS_Store
.idea/
vendor/
vendor/
corelib/
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ integration:
@echo "Running integration tests..."
@$(MAKE) build
@if [ $$? -eq 0 ]; then \
if [ ! -d ./rust_vm_bin/corelib ]; then \
git clone --depth=1 -b v2.9.0-dev.0 https://github.com/starkware-libs/cairo.git \
&& mv cairo/corelib ./rust_vm_bin/ \
&& rm -rf cairo/; \
fi; \
go test ./integration_tests/... -v; \
else \
echo "Integration tests were not run"; \
exit 1; \
fi


testall:
@echo "Running all tests..."
@$(MAKE) build
Expand Down
30 changes: 25 additions & 5 deletions integration_tests/cairozero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func WriteBenchMarksToFile(benchmarkMap map[string][3]int) {

const (
compiledSuffix = "_compiled.json"
sierraSuffix = ".sierra"
pyTraceSuffix = "_py_trace"
pyMemorySuffix = "_py_memory"
rsTraceSuffix = "_rs_trace"
Expand All @@ -283,11 +284,29 @@ func compileCairoCode(path string, zero bool) (string, error) {
if filepath.Ext(path) != ".cairo" {
return "", fmt.Errorf("compiling non cairo file: %s", path)
}
compiledOutput := swapExtenstion(path, compiledSuffix)

cliCommand := "../rust_vm_bin/sierra-compile-json"
sierraOutput := swapExtenstion(path, sierraSuffix)
cliCommand := "../rust_vm_bin/cairo1-compile/cairo-compile"
args := []string{
"--single-file",
path,
sierraOutput,
"--replace-ids",
}

cmd := exec.Command(cliCommand, args...)

res, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf(
"%s %s: %w\n%s", cliCommand, path, err, string(res),
)
}

compiledOutput := swapExtenstion(path, compiledSuffix)
cliCommand = "../rust_vm_bin/cairo1-compile/sierra-compile-json"
args = []string{
sierraOutput,
compiledOutput,
}
if zero {
Expand All @@ -301,9 +320,9 @@ func compileCairoCode(path string, zero bool) (string, error) {
}
}

cmd := exec.Command(cliCommand, args...)
cmd = exec.Command(cliCommand, args...)

res, err := cmd.CombinedOutput()
res, err = cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf(
"%s %s: %w\n%s", cliCommand, path, err, string(res),
Expand Down Expand Up @@ -407,7 +426,7 @@ func runRustVm(testFilename, path string, zero bool) (time.Duration, string, str
args = append(args, "--layout", "all_cairo")
}

binaryPath := "./../rust_vm_bin/cairo1-run"
binaryPath := "./../rust_vm_bin/cairo1-compile/cairo1-run"
if zero {
binaryPath = "./../rust_vm_bin/cairo-vm-cli"
}
Expand Down Expand Up @@ -539,6 +558,7 @@ func swapExtenstion(path string, newSuffix string) string {

func isGeneratedFile(path string) bool {
return strings.HasSuffix(path, compiledSuffix) ||
strings.HasSuffix(path, sierraSuffix) ||
strings.HasSuffix(path, pyTraceSuffix) ||
strings.HasSuffix(path, pyMemorySuffix) ||
strings.HasSuffix(path, traceSuffix) ||
Expand Down
Binary file added rust_vm_bin/cairo1-compile/cairo-compile
Binary file not shown.
Binary file not shown.
Binary file added rust_vm_bin/cairo1-compile/sierra-compile-json
Binary file not shown.

0 comments on commit 194bad4

Please sign in to comment.