-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modify the testing pipeline, add cairo1 runner binary * Add cairo1 programs from lambdaclass * Add binaries of cairo1-runner, cairo-compile, sierra-compile-json, add fetching corelib when nonexistent * Code refactors, fixes of integration tests * Integration tests minor fixes * Add the integrations tests environment generation * Fixes in integration tests, refactoring of makefile * Remove cairo0 rust binary * Add unmarshaling option for gas_builtin * Include gas builtin in umarshaling and marshaling of cairo file * Change the naming convention of integration tests * Remove accidentaly added script * Rename cairozero_test.go, add tracker for failing integration tests * Remove the file with list of failing integration tests * modify writing to file functionality
- Loading branch information
1 parent
212c55b
commit f506eb5
Showing
159 changed files
with
1,563 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use array::ArrayTrait; | ||
|
||
fn main() -> Array<u32> { | ||
let mut numbers = ArrayTrait::new(); | ||
numbers.append(4_u32); | ||
numbers.append(2_u32); | ||
let _x = numbers.pop_front(); | ||
numbers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use array::ArrayTrait; | ||
|
||
fn main() -> u32 { | ||
let mut numbers = ArrayTrait::new(); | ||
numbers.append(4_u32); | ||
numbers.append(3_u32); | ||
numbers.append(2_u32); | ||
numbers.append(1_u32); | ||
*numbers.at(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use core::array::ArrayTrait; | ||
|
||
|
||
fn main() -> (Array<u32>, u32) { | ||
let mut numbers = ArrayTrait::new(); | ||
numbers.append(1); | ||
|
||
(numbers, 1) | ||
} |
11 changes: 11 additions & 0 deletions
11
integration_tests/cairo_1_programs/bitwise__recursive.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn main() -> u128 { | ||
let a = 1234_u128; | ||
let b = 5678_u128; | ||
|
||
let c0 = a & b; | ||
let c1 = a ^ b; | ||
let c2 = a | b; | ||
|
||
let c3 = c0 + c1 + c2; | ||
c3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fn main() -> bytes31 { | ||
let a: u128 = 123; | ||
let b: bytes31 = a.into(); | ||
b | ||
} |
28 changes: 28 additions & 0 deletions
28
integration_tests/cairo_1_programs/dict_non_squashed/dict_with_struct_non_squash.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
|
||
#[derive(Drop, Copy)] | ||
struct FP16x16 { | ||
mag: u32, | ||
sign: bool | ||
} | ||
|
||
fn main() -> Felt252Dict<Nullable<FP16x16>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<FP16x16>> = Default::default(); | ||
|
||
let box_a = BoxTrait::new(identity(FP16x16 { mag: 1, sign: false })); | ||
let box_b = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
let box_c = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
|
||
// Insert it as a `Span` | ||
d.insert(0, nullable_from_box(box_c)); | ||
d.insert(1, nullable_from_box(box_a)); | ||
d.insert(2, nullable_from_box(box_b)); | ||
|
||
d | ||
} | ||
|
||
// TODO: remove this temporary fix once fixed in cairo | ||
#[inline(never)] | ||
fn identity<T>(t: T) -> T { t } |
15 changes: 15 additions & 0 deletions
15
integration_tests/cairo_1_programs/dict_non_squashed/felt_dict_non_squash.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
fn main() -> Felt252Dict<Nullable<Span<felt252>>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default(); | ||
|
||
// Create the array to insert | ||
let a = array![8, 9, 10, 11]; | ||
let b = array![1, 2, 3]; | ||
|
||
// Insert it as a `Span` | ||
d.insert(66675, nullable_from_box(BoxTrait::new(a.span()))); | ||
d.insert(66676, nullable_from_box(BoxTrait::new(b.span()))); | ||
d | ||
} |
23 changes: 23 additions & 0 deletions
23
integration_tests/cairo_1_programs/dict_non_squashed/nullable_box_vec_non_squash.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
struct NullableVec<T> { | ||
items: Felt252Dict<Nullable<Box<T>>>, | ||
len: usize, | ||
} | ||
|
||
fn main() -> NullableVec<u32> { | ||
let mut d: Felt252Dict<Nullable<Box<u32>>> = Default::default(); | ||
|
||
// Populate the dictionary | ||
d.insert(0, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(10))))); | ||
d.insert(1, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(20))))); | ||
d.insert(2, nullable_from_box(BoxTrait::new(BoxTrait::new(identity(30))))); | ||
|
||
// Return NullableVec | ||
NullableVec { | ||
items: d, | ||
len: 3, | ||
} | ||
} | ||
|
||
// TODO: remove this temporary fix once fixed in cairo | ||
#[inline(never)] | ||
fn identity<T>(t: T) -> T { t } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
|
||
#[derive(Drop, Copy)] | ||
struct FP16x16 { | ||
mag: u32, | ||
sign: bool | ||
} | ||
|
||
fn main() -> SquashedFelt252Dict<Nullable<FP16x16>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<FP16x16>> = Default::default(); | ||
|
||
let box_a = BoxTrait::new(identity(FP16x16 { mag: 1, sign: false })); | ||
let box_b = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
let box_c = BoxTrait::new(identity(FP16x16 { mag: 1, sign: true })); | ||
|
||
// Insert it as a `Span` | ||
d.insert(0, nullable_from_box(box_c)); | ||
d.insert(1, nullable_from_box(box_a)); | ||
d.insert(2, nullable_from_box(box_b)); | ||
|
||
d.squash() | ||
} | ||
|
||
// TODO: remove this temporary fix once fixed in cairo | ||
#[inline(never)] | ||
fn identity<T>(t: T) -> T { t } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use dict::Felt252DictTrait; | ||
|
||
fn main() -> felt252 { | ||
let mut dict_u8 = felt252_dict_new::<u8>(); | ||
let mut dict_felt = felt252_dict_new::<felt252>(); | ||
let _dict_felt2 = felt252_dict_new::<felt252>(); | ||
|
||
dict_u8.insert(10, 110); | ||
dict_u8.insert(10, 110); | ||
|
||
let _val10 = dict_u8[10]; // 110 | ||
let _val11 = dict_felt[11]; // 0 | ||
dict_felt.insert(11, 1024); | ||
dict_felt[11] // 1024 | ||
} |
7 changes: 7 additions & 0 deletions
7
integration_tests/cairo_1_programs/ecdsa_recover__starknet.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
fn main() -> felt252 { | ||
let message_hash: felt252 = 0x503f4bea29baee10b22a7f10bdc82dda071c977c1f25b8f3973d34e6b03b2c; | ||
let signature_r: felt252 = 0xbe96d72eb4f94078192c2e84d5230cde2a70f4b45c8797e2c907acff5060bb; | ||
let signature_s: felt252 = 0x677ae6bba6daf00d2631fab14c8acf24be6579f9d9e98f67aa7f2770e57a1f5; | ||
core::ecdsa::recover_public_key(:message_hash, :signature_r, :signature_s, y_parity: false).unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
enum MyEnumShort { | ||
a: felt252, | ||
b: felt252 | ||
} | ||
enum MyEnumLong { | ||
a: felt252, | ||
b: felt252, | ||
c: felt252 | ||
} | ||
enum MyEnumGeneric<S, T> { | ||
a: T, | ||
b: S, | ||
c: T | ||
} | ||
|
||
impl MyEnumGenericDrop of Drop<MyEnumGeneric<(), felt252>>; | ||
|
||
fn main() -> felt252 { | ||
let es0 = MyEnumShort::a(10); | ||
match_short(es0); | ||
let es1 = MyEnumShort::b(11); | ||
match_short(es1); | ||
let el0 = MyEnumLong::a(20); | ||
match_long(el0); | ||
let el1 = MyEnumLong::b(21); | ||
match_long(el1); | ||
let el2 = MyEnumLong::c(22); | ||
match_long(el2); | ||
let _eg1: MyEnumGeneric<(), felt252> = MyEnumGeneric::<(), felt252>::a(30); | ||
let _eg2: MyEnumGeneric<(), felt252> = MyEnumGeneric::<(), felt252>::b(()); | ||
let _eg3: MyEnumGeneric<(), felt252> = MyEnumGeneric::<(), felt252>::c(32); | ||
300 | ||
} | ||
|
||
fn match_short(e: MyEnumShort) -> felt252 { | ||
match e { | ||
MyEnumShort::a(x) => { | ||
x | ||
}, | ||
MyEnumShort::b(x) => { | ||
x | ||
}, | ||
} | ||
} | ||
|
||
fn match_long(e: MyEnumLong) -> felt252 { | ||
match e { | ||
MyEnumLong::a(x) => { | ||
x | ||
}, | ||
MyEnumLong::b(x) => { | ||
x | ||
}, | ||
MyEnumLong::c(x) => { | ||
x | ||
}, | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
integration_tests/cairo_1_programs/enum_match__small.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
enum MyEnum { | ||
A: felt252, | ||
B: (felt252, felt252), | ||
} | ||
|
||
fn get_value(e: MyEnum) -> felt252 { | ||
match e { | ||
MyEnum::A(a) => a, | ||
MyEnum::B((x,y)) => x - y, | ||
} | ||
} | ||
|
||
fn main() -> (felt252, felt252) { | ||
( | ||
get_value(MyEnum::A(10)), | ||
get_value(MyEnum::B((20, 30))), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use core::felt252; | ||
|
||
fn main() -> felt252 { | ||
let n = 10; | ||
let result = factorial(n); | ||
result | ||
} | ||
|
||
fn factorial(n: felt252) -> felt252 { | ||
match n { | ||
0 => 1, | ||
_ => n * factorial(n - 1), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
fn main() -> SquashedFelt252Dict<Nullable<Span<felt252>>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default(); | ||
|
||
// Create the array to insert | ||
let a = array![8, 9, 10, 11]; | ||
let b = array![1, 2, 3]; | ||
|
||
// Insert it as a `Span` | ||
d.insert(66675, nullable_from_box(BoxTrait::new(a.span()))); | ||
d.insert(66676, nullable_from_box(BoxTrait::new(b.span()))); | ||
d.squash() | ||
} |
18 changes: 18 additions & 0 deletions
18
integration_tests/cairo_1_programs/felt_dict_squash__small.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
use core::dict::Felt252DictEntry; | ||
|
||
fn main() -> SquashedFelt252Dict<Nullable<Span<felt252>>> { | ||
// Create the dictionary | ||
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default(); | ||
|
||
// Create the array to insert | ||
let a = array![8, 9, 10, 11]; | ||
let b = array![1, 2, 3]; | ||
let c = array![4, 5, 6]; | ||
|
||
// Insert it as a `Span` | ||
d.insert(66675, nullable_from_box(BoxTrait::new(a.span()))); | ||
d.insert(66676, nullable_from_box(BoxTrait::new(b.span()))); | ||
d.insert(66675, nullable_from_box(BoxTrait::new(c.span()))); | ||
d.squash() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult}; | ||
|
||
fn main() -> Nullable<Span<felt252>> { | ||
let a = array![8, 9, 10, 11]; | ||
nullable_from_box(BoxTrait::new(a.span())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use core::felt252; | ||
|
||
fn main() -> felt252 { | ||
let n = 10; | ||
let result = fib(1, 1, n); | ||
result | ||
} | ||
|
||
fn fib(a: felt252, b: felt252, n: felt252) -> felt252 { | ||
match n { | ||
0 => a, | ||
_ => fib(b, a + b, n - 1), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
enum MyEnum { | ||
A: (), | ||
B: felt252, | ||
} | ||
|
||
fn main() -> MyEnum { | ||
MyEnum::B(1234) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() -> Nullable<u32> { | ||
null() | ||
} |
Oops, something went wrong.