-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for Bravos transfer #721
base: main
Are you sure you want to change the base?
Changes from 5 commits
793c278
91ff796
cee7bda
767806e
e7efb7a
f8fa5ef
62a5db9
9ba1c94
8cbed7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#[starknet::contract] | ||
mod MultiCall { | ||
use starknet::ContractAddress; | ||
use core::debug::PrintTrait; | ||
use core::integer::u256; | ||
#[storage] | ||
struct Storage {} | ||
|
||
#[derive(Drop, Serde)] | ||
pub struct Route { | ||
pub to: ContractAddress, | ||
pub selector: u256, | ||
pub calldata: Span<felt252> | ||
} | ||
|
||
#[external(v0)] | ||
fn multi_route_swap( | ||
self: @ContractState, | ||
token_from_address: ContractAddress, | ||
token_from_amount: u256, | ||
token_to_address: ContractAddress, | ||
token_to_amount: u256, | ||
token_to_min_amount: u256, | ||
beneficiary: ContractAddress, | ||
integrator_fee_amount_bps: u128, | ||
integrator_fee_recipient: ContractAddress, | ||
routes: Span<Route>, | ||
) -> bool { | ||
true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#[starknet::contract] | ||
mod MultiCall { | ||
// use starknet::account::Call; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check in the issue,
Can we add the two cases of this contract with the two different data types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pefontana which is the other calldata's type you are refering to? Because its type was Span when I first saw it. |
||
use starknet::ContractAddress; | ||
use core::debug::PrintTrait; | ||
use core::integer::u256; | ||
#[storage] | ||
struct Storage {} | ||
|
||
#[derive(Drop, Serde)] | ||
pub struct Call { | ||
pub to: ContractAddress, | ||
pub selector: u256, | ||
pub calldata: Span<felt252> | ||
} | ||
|
||
#[external(v0)] | ||
fn fib(self: @ContractState, calls: Span<Call>) -> felt252 { | ||
let mut calls = calls; | ||
loop { | ||
match calls.pop_front() { | ||
Option::Some(call) => { | ||
println!("To {:?}", (*call.to)); | ||
println!("Selector {}", (*call.selector)); | ||
//println!("Call[0] {:?}", (*(*call.calldata).at(0))); | ||
//println!("Call[0] {:?}", (*(*call.calldata).at(1))); | ||
println!("Call[0] {:?}", (*(call.calldata)[0])); | ||
println!("Call[1] {:?}", (*(call.calldata)[1])); | ||
}, | ||
Option::None => { break; }, | ||
} | ||
}; | ||
12 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,7 +9,7 @@ use test_case::test_case; | |||||
|
||||||
// Test cases for programs without input, it checks the outputs are correct automatically. | ||||||
|
||||||
// felt tests | ||||||
// // felt tests | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
#[test_case("tests/cases/felt_ops/add.cairo")] | ||||||
#[test_case("tests/cases/felt_ops/sub.cairo")] | ||||||
#[test_case("tests/cases/felt_ops/felt_is_zero.cairo")] | ||||||
|
@@ -176,6 +176,23 @@ fn test_program_cases(program_path: &str) { | |||||
#[test_case("tests/cases/cairo_vm/contracts/field_sqrt.cairo", &[])] | ||||||
#[test_case("tests/cases/cairo_vm/contracts/random_ec_point.cairo", &[])] | ||||||
#[test_case("tests/cases/cairo_vm/contracts/alloc_constant_size.cairo", &[10, 10, 10])] | ||||||
#[test_case("tests/cases/cairo_vm/contracts/multicall.cairo", &[ | ||||||
// n_calls | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add in the commented lines what these numbers are? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further, maybe using the serialized bytes and |
||||||
6, | ||||||
// call 1 | ||||||
12, 17, 3, 2, 1, 2, | ||||||
// call 2 | ||||||
13, 18, 4, 3, 1, 2, 3, | ||||||
// call 3 | ||||||
17, 16, 5, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, | ||||||
// call 4 | ||||||
17, 17, 0, 100, 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, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | ||||||
// call 5 | ||||||
17, 17, 0, 100, 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, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | ||||||
// call 6 | ||||||
17, 17, 0, 100, 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, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | ||||||
])] | ||||||
#[test_case("tests/cases/cairo_vm/contracts/multi_route_swap.cairo", &[1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 0])] | ||||||
fn test_contract_cases(program_path: &str, args: &[u128]) { | ||||||
let args = args.iter().map(|&arg| arg.into()).collect_vec(); | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?