forked from HerodotusDev/integrity
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_layouts.py
68 lines (52 loc) · 2.13 KB
/
test_layouts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import subprocess
import argparse
from colorama import Fore, Style
# Function to execute commands and log the process
def log_and_run(commands, description, cwd=None):
full_command = " && ".join(commands)
try:
print(f"{Fore.YELLOW}Starting: {description}...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Command: {full_command}{Style.RESET_ALL}")
# Execute the command
result = subprocess.run(
full_command, shell=True, check=True, cwd=cwd, text=True
)
print(f"{Fore.GREEN}Success: {description} completed!\n{Style.RESET_ALL}")
except subprocess.CalledProcessError as e:
print(
f"{Fore.RED}Error running command '{full_command}': {e}\n{Style.RESET_ALL}"
)
# List of layouts to test
LAYOUTS = ["dex", "recursive", "recursive_with_poseidon", "small", "starknet", "starknet_with_keccak"]
# Main function to run the tests and optionally restore the src folder
def main(restore_src=None):
for layout in LAYOUTS:
log_and_run(
[
f"python configure.py -l {layout} -s keccak",
"scarb build",
f"cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/{layout}/example_proof.json",
],
f"Testing {layout.lower()} layout",
cwd=".",
)
# Check if src folder restoration is required
if restore_src is None:
response = input("Do you want to restore the src folder? (y/n): ")
restore_src = response.lower() == "y"
# Restore the src folder if requested
if restore_src:
log_and_run(["git restore src/"], "Restoring src folder", cwd=".")
# Entry point of the script
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Test cairo1-verifier layouts on example proofs"
)
# Define command-line arguments
parser.add_argument(
"-r", "--restore-src", action="store_true", help="Restore src folder after run"
)
# Parse the arguments
args = parser.parse_args()
# Run main function with the specified arguments
main(args.restore_src)