Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 99c7b3b

Browse files
authored
Remove cairo 1 tests (#1263)
* Remove cairo-1 related targets from Makefile * Push Progress * Remove feature gated code from tests * Fix tests * Push cairo2 version of multi_syscall contract * Delete cairo1 test files * Update CI * Update gitignore * clippy
1 parent c90c46b commit 99c7b3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+144
-1258
lines changed

.github/workflows/rust-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
strategy:
103103
fail-fast: false
104104
matrix:
105-
target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ]
105+
target: [ test, test-doctests, test-cairo-native ]
106106
name: Run tests
107107
runs-on: ubuntu-latest
108108
steps:

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ target/
3939

4040
.env
4141
# the starting `/` assures this matches only on the repo's root
42-
/cairo1
4342
/cairo2
4443

4544
starknet-venv/
4645
**/*.json
4746

48-
starknet_programs/cairo1/*.casm
49-
starknet_programs/cairo1/*.sierra
5047
starknet_programs/cairo2/*.casm
5148
starknet_programs/cairo2/*.sierra
5249
default.profraw

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ license = "Apache-2.0"
88
[features]
99
default = ["with_mimalloc"]
1010
with_mimalloc = ["dep:mimalloc"]
11-
cairo_1_tests = []
1211
metrics = []
1312
# Disclaimer: This feature enables state modifications being applied on reverted and failings txs, and also disables address availability check when deploying contracts.
1413
# Only use for benchmarking using the replay binary

Makefile

+10-64
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: usage build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \
1+
.PHONY: usage build check clean clippy compile-cairo compile-starknet \
22
compile-cairo-2-casm compile-cairo-2-sierra coverage deps test heaptrack check-python-version
33

44
export PATH:=$(shell pyenv root)/shims:$(PATH)
@@ -21,9 +21,6 @@ STARKNET_ABI_TARGETS=$(patsubst %.cairo,%_abi.json,$(STARKNET_SOURCES))
2121
BUILTIN_SOURCES=$(wildcard starknet_programs/*.cairo)
2222
BUILTIN_TARGETS=$(patsubst %.cairo,%.json,$(BUILTIN_SOURCES))
2323

24-
STARKNET_COMPILE_CAIRO_1:=cairo1/bin/starknet-compile
25-
STARKNET_SIERRA_COMPILE_CAIRO_1:=cairo1/bin/starknet-sierra-compile
26-
2724
STARKNET_COMPILE_CAIRO_2:=cairo2/bin/starknet-compile
2825
STARKNET_SIERRA_COMPILE_CAIRO_2:=cairo2/bin/starknet-sierra-compile
2926

@@ -36,7 +33,6 @@ usage:
3633
@echo ' clean: Cleans all build artifacts'
3734
@echo ' clippy: Runs clippy'
3835
@echo ' test: Runs all tests'
39-
@echo ' test-cairo-1: Runs the Cairo 1 tests'
4036
@echo ' test-cairo-2: Runs the Cairo 2 tests'
4137
@echo ' test-doctests: Runs the doctests'
4238
@echo ' coverage: Runs everything necessary to generate the coverage report'
@@ -69,42 +65,6 @@ starknet_programs/%.json starknet_programs/%_abi.json: starknet_programs/%.cairo
6965
|| rm ./$*.json ./$*_abi.json
7066
# Compiles .cairo files into .json files. if the command fails, then it removes all of the .json files
7167

72-
# ======================
73-
# Test Cairo 1 Contracts
74-
# ======================
75-
76-
CAIRO_1_CONTRACTS_TEST_DIR=starknet_programs/cairo1
77-
CAIRO_1_CONTRACTS_TEST_CAIRO_FILES:=$(wildcard $(CAIRO_1_CONTRACTS_TEST_DIR)/*.cairo)
78-
CAIRO_1_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.cairo, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_CAIRO_FILES))
79-
CAIRO_1_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_1_COMPILED_SIERRA_CONTRACTS))
80-
81-
$(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_1_CONTRACTS_TEST_DIR)/%.cairo
82-
$(STARKNET_COMPILE_CAIRO_1) --allowed-libfuncs-list-name experimental_v0.1.0 $< $@
83-
84-
$(CAIRO_1_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra
85-
$(STARKNET_SIERRA_COMPILE_CAIRO_1) --allowed-libfuncs-list-name experimental_v0.1.0 --add-pythonic-hints $< $@
86-
87-
compile-cairo-1-sierra: $(CAIRO_1_COMPILED_SIERRA_CONTRACTS)
88-
compile-cairo-1-casm: $(CAIRO_1_COMPILED_CASM_CONTRACTS)
89-
90-
91-
cairo-repo-1-dir = cairo1
92-
cairo-repo-1-dir-macos = cairo1-macos
93-
94-
build-cairo-1-compiler-macos: | $(cairo-repo-1-dir-macos)
95-
96-
$(cairo-repo-1-dir-macos):
97-
curl -L -o cairo-1.1.1.tar https://github.com/starkware-libs/cairo/releases/download/v1.1.1/release-aarch64-apple-darwin.tar \
98-
&& tar -xzvf cairo-1.1.1.tar \
99-
&& mv cairo/ cairo1/
100-
101-
build-cairo-1-compiler: | $(cairo-repo-1-dir)
102-
103-
$(cairo-repo-1-dir):
104-
curl -L -o cairo-1.1.1.tar https://github.com/starkware-libs/cairo/releases/download/v1.1.1/release-x86_64-unknown-linux-musl.tar.gz \
105-
&& tar -xzvf cairo-1.1.1.tar \
106-
&& mv cairo/ cairo1/
107-
10868
# ======================
10969
# Test Cairo 2 Contracts
11070
# ======================
@@ -153,13 +113,13 @@ cairo-%.tar:
153113
# Normal rules.
154114
# =================
155115

156-
build: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
116+
build: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
157117
cargo build --release --workspace
158118

159-
check: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
119+
check: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
160120
cargo check --workspace --all-targets
161121

162-
deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler
122+
deps: check-python-version build-cairo-2-compiler
163123
cargo install flamegraph --version 0.6.2 --locked
164124
cargo install cargo-llvm-cov --version 0.5.14 --locked
165125
-pyenv && pyenv install -s pypy3.9-7.3.9
@@ -168,7 +128,7 @@ deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler
168128
. starknet-venv/bin/activate && $(MAKE) deps-venv
169129
cargo install cargo-nextest --version 0.9.49 --locked
170130

171-
deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-compiler-macos
131+
deps-macos: check-python-version build-cairo-2-compiler-macos
172132
cargo install flamegraph --version 0.6.2 --locked
173133
cargo install cargo-llvm-cov --version 0.5.14 --locked
174134
-pyenv install -s pypy3.9-7.3.9
@@ -180,43 +140,29 @@ deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-comp
180140
clean:
181141
-rm -rf starknet-venv/
182142
-rm -f cairo_programs/*.json
183-
-rm -f cairo_programs/cairo_1_contracts/*.json
184-
-rm -f cairo_programs/cairo_1_contracts/*.casm
185143
-rm -f starknet_programs/*.json
186-
-rm -f starknet_programs/cairo1/*.casm
187-
-rm -f starknet_programs/cairo1/*.sierra
188144
-rm -f starknet_programs/cairo2/*.casm
189145
-rm -f starknet_programs/cairo2/*.sierra
190146
-rm -f tests/*.json
191-
-rm -rf cairo1/
192147
-rm -rf cairo2/
193148
-rm -rf cairo-*.tar
194149

195-
clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
150+
clippy: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
196151
cargo clippy --workspace --all-targets --all-features -- -D warnings
197152

198-
test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
199-
echo "Cairo1 tests"
200-
$(MAKE) test-cairo-1
201-
echo "Cairo2 tests"
202-
$(MAKE) test-cairo-2
203-
204-
test-cairo-1: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
205-
cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics,cairo-native
206-
207-
test-cairo-2: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
153+
test: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
208154
cargo nextest run --workspace --all-targets --features=metrics,cairo-native
209155

210-
test-cairo-native: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
156+
test-cairo-native: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
211157
cargo nextest run --workspace --test tests --features=cairo-native integration_tests::cairo_native
212158

213159
test-doctests:
214160
cargo test --workspace --doc
215161

216-
coverage: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm
162+
coverage: compile-cairo compile-starknet compile-cairo-2-casm
217163
$(MAKE) coverage-report
218164

219-
coverage-report: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra
165+
coverage-report: compile-cairo compile-starknet compile-cairo-2-casm compile-cairo-2-sierra
220166
cargo llvm-cov nextest --lcov --ignore-filename-regex 'main.rs' --output-path lcov.info --release
221167

222168
heaptrack:

src/core/contract_address/casm_contract_address.rs

+5-54
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,13 @@ mod tests {
117117
// Open the file in read-only mode with buffer.
118118
let file;
119119
let expected_result;
120-
#[cfg(not(feature = "cairo_1_tests"))]
121120
{
122121
file = File::open("starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm").unwrap();
123122
expected_result = Felt252::from_hex(
124123
"0x321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f",
125124
)
126125
.unwrap();
127126
}
128-
#[cfg(feature = "cairo_1_tests")]
129-
{
130-
file = File::open("starknet_programs/cairo1/contract_a.casm").unwrap();
131-
expected_result = Felt252::from_hex(
132-
"0x3a4f00bf75ba3b9230a94f104c7a4605a1901c4bd475beb59eeeeb7aceb9795",
133-
)
134-
.unwrap();
135-
}
136127
let reader = BufReader::new(file);
137128

138129
// Read the JSON contents of the file as an instance of `CasmContractClass`.
@@ -149,7 +140,6 @@ mod tests {
149140
// Open the file in read-only mode with buffer.
150141
let file;
151142
let expected_result;
152-
#[cfg(not(feature = "cairo_1_tests"))]
153143
{
154144
file = File::open("starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm").unwrap();
155145
expected_result = Felt252::from_hex(
@@ -158,14 +148,6 @@ mod tests {
158148
.unwrap();
159149
}
160150

161-
#[cfg(feature = "cairo_1_tests")]
162-
{
163-
file = File::open("starknet_programs/cairo1/deploy.casm").unwrap();
164-
expected_result = Felt252::from_hex(
165-
"0x3bd56f1c3c1c595ac2ee6d07bdedc027d09df56235e20374649f0b3535c1f15",
166-
)
167-
.unwrap();
168-
}
169151
let reader = BufReader::new(file);
170152

171153
// Read the JSON contents of the file as an instance of `CasmContractClass`.
@@ -180,25 +162,12 @@ mod tests {
180162
#[test]
181163
fn test_compute_casm_class_hash_fibonacci() {
182164
// Open the file in read-only mode with buffer.
183-
let file;
184-
let expected_result;
185-
#[cfg(not(feature = "cairo_1_tests"))]
186-
{
187-
file = File::open("starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm").unwrap();
188-
expected_result = Felt252::from_hex(
189-
"0x6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89",
190-
)
191-
.unwrap();
192-
}
193165

194-
#[cfg(feature = "cairo_1_tests")]
195-
{
196-
file = File::open("starknet_programs/cairo1/fibonacci.casm").unwrap();
197-
expected_result = Felt252::from_hex(
198-
"0x44f12e6e59232e9909d7428b913b3cc8d9059458e5027740a3ccdbdc4b1ffd2",
199-
)
200-
.unwrap();
201-
}
166+
let file = File::open("starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm").unwrap();
167+
let expected_result =
168+
Felt252::from_hex("0x6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89")
169+
.unwrap();
170+
202171
let reader = BufReader::new(file);
203172

204173
// Read the JSON contents of the file as an instance of `CasmContractClass`.
@@ -215,7 +184,6 @@ mod tests {
215184
// Open the file in read-only mode with buffer.
216185
let file;
217186
let expected_result;
218-
#[cfg(not(feature = "cairo_1_tests"))]
219187
{
220188
file = File::open("starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm").unwrap();
221189
expected_result = Felt252::from_hex(
@@ -224,14 +192,6 @@ mod tests {
224192
.unwrap();
225193
}
226194

227-
#[cfg(feature = "cairo_1_tests")]
228-
{
229-
file = File::open("starknet_programs/cairo1/factorial.casm").unwrap();
230-
expected_result = Felt252::from_hex(
231-
"0x189a9b8b852aedbb225aa28dce9cfc3133145dd623e2d2ca5e962b7d4e61e15",
232-
)
233-
.unwrap();
234-
}
235195
let reader = BufReader::new(file);
236196

237197
// Read the JSON contents of the file as an instance of `CasmContractClass`.
@@ -248,7 +208,6 @@ mod tests {
248208
// Open the file in read-only mode with buffer.
249209
let file;
250210
let expected_result;
251-
#[cfg(not(feature = "cairo_1_tests"))]
252211
{
253212
file = File::open("starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm").unwrap();
254213
expected_result = Felt252::from_hex(
@@ -257,14 +216,6 @@ mod tests {
257216
.unwrap();
258217
}
259218

260-
#[cfg(feature = "cairo_1_tests")]
261-
{
262-
file = File::open("starknet_programs/cairo1/emit_event.casm").unwrap();
263-
expected_result = Felt252::from_hex(
264-
"0x3335fe731ceda1116eda8bbc2e282953ce54618309ad474189e627c59328fff",
265-
)
266-
.unwrap();
267-
}
268219
let reader = BufReader::new(file);
269220

270221
// Read the JSON contents of the file as an instance of `CasmContractClass`.

src/lib.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,7 @@ mod test {
346346

347347
#[test]
348348
fn call_contract_fibonacci_with_10_should_return_89() {
349-
#[cfg(not(feature = "cairo_1_tests"))]
350349
let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.casm");
351-
#[cfg(feature = "cairo_1_tests")]
352-
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.casm");
353350

354351
let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
355352
let entrypoints = contract_class.clone().entry_points_by_type;
@@ -454,10 +451,7 @@ mod test {
454451

455452
#[test]
456453
fn test_skip_validation_flag() {
457-
#[cfg(not(feature = "cairo_1_tests"))]
458454
let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.casm");
459-
#[cfg(feature = "cairo_1_tests")]
460-
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.casm");
461455
let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
462456
let entrypoints = contract_class.clone().entry_points_by_type;
463457
let entrypoint_selector = Felt252::from(&entrypoints.external.get(0).unwrap().selector);
@@ -532,10 +526,7 @@ mod test {
532526
let entrypoint_selector = *EXECUTE_ENTRY_POINT_SELECTOR;
533527

534528
// test with fibonacci
535-
#[cfg(not(feature = "cairo_1_tests"))]
536529
let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.casm");
537-
#[cfg(feature = "cairo_1_tests")]
538-
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.casm");
539530

540531
let casm_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
541532

@@ -668,10 +659,7 @@ mod test {
668659
let entrypoint_selector = *EXECUTE_ENTRY_POINT_SELECTOR;
669660

670661
// test with fibonacci
671-
#[cfg(not(feature = "cairo_1_tests"))]
672662
let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.casm");
673-
#[cfg(feature = "cairo_1_tests")]
674-
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.casm");
675663

676664
let casm_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
677665

@@ -975,7 +963,7 @@ mod test {
975963
}
976964

977965
fn declarev2_tx() -> Declare {
978-
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.sierra");
966+
let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.sierra");
979967
let sierra_contract_class: SierraContractClass =
980968
serde_json::from_slice(program_data).unwrap();
981969

0 commit comments

Comments
 (0)