Skip to content

Commit

Permalink
Fix alloc_mlir_array. (#503)
Browse files Browse the repository at this point in the history
* Fix `alloc_mlir_array`.

* Add test.
  • Loading branch information
azteca1998 authored Mar 27, 2024
1 parent 7a4d510 commit 4cd14b1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ pub(crate) mod handler {

ArrayAbi {
ptr,
since: len,
since: 0,
until: len,
capacity: len,
}
Expand Down
60 changes: 56 additions & 4 deletions tests/tests/starknet/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,20 @@ impl StarknetSyscallHandler for SyscallHandler {
_calldata: &[Felt],
_remaining_gas: &mut u128,
) -> SyscallResult<Vec<Felt>> {
Ok(Vec::new())
Ok(vec![
Felt::from_dec_str(
"3358892263739032253767642605669710712087178958719188919195252597609334880396",
)
.unwrap(),
Felt::from_dec_str(
"1104291043781086177955655234103730593173963850634630109574183288837411031513",
)
.unwrap(),
Felt::from_dec_str(
"3346377229881115874907650557159666001431249650068516742483979624047277128413",
)
.unwrap(),
])
}

fn call_contract(
Expand All @@ -171,7 +184,20 @@ impl StarknetSyscallHandler for SyscallHandler {
_calldata: &[Felt],
_remaining_gas: &mut u128,
) -> SyscallResult<Vec<Felt>> {
Ok(Vec::new())
Ok(vec![
Felt::from_dec_str(
"3358892263739032253767642605669710712087178958719188919195252597609334880396",
)
.unwrap(),
Felt::from_dec_str(
"1104291043781086177955655234103730593173963850634630109574183288837411031513",
)
.unwrap(),
Felt::from_dec_str(
"3346377229881115874907650557159666001431249650068516742483979624047277128413",
)
.unwrap(),
])
}

fn storage_read(
Expand Down Expand Up @@ -588,7 +614,20 @@ fn library_call() {
JitValue::Enum {
tag: 0,
value: Box::new(JitValue::Struct {
fields: vec![JitValue::Array(Vec::new())],
fields: vec![JitValue::Array(vec![
JitValue::Felt252(Felt::from_dec_str(
"3358892263739032253767642605669710712087178958719188919195252597609334880396"
)
.unwrap()),
JitValue::Felt252(Felt::from_dec_str(
"1104291043781086177955655234103730593173963850634630109574183288837411031513"
)
.unwrap()),
JitValue::Felt252(Felt::from_dec_str(
"3346377229881115874907650557159666001431249650068516742483979624047277128413"
)
.unwrap()),
])],
debug_name: None,
}),
debug_name: None,
Expand All @@ -611,7 +650,20 @@ fn call_contract() {
JitValue::Enum {
tag: 0,
value: Box::new(JitValue::Struct {
fields: vec![JitValue::Array(Vec::new())],
fields: vec![JitValue::Array(vec![
JitValue::Felt252(Felt::from_dec_str(
"3358892263739032253767642605669710712087178958719188919195252597609334880396"
)
.unwrap()),
JitValue::Felt252(Felt::from_dec_str(
"1104291043781086177955655234103730593173963850634630109574183288837411031513"
)
.unwrap()),
JitValue::Felt252(Felt::from_dec_str(
"3346377229881115874907650557159666001431249650068516742483979624047277128413"
)
.unwrap()),
])],
debug_name: None,
}),
debug_name: None,
Expand Down

0 comments on commit 4cd14b1

Please sign in to comment.