Skip to content

Commit

Permalink
fixed tests compilation error + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed May 14, 2024
1 parent 95de46d commit cb9ca36
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion starknet/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ starknet = "2.6.3"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.23.0" }

[[target.starknet-contract]]
casm = true
# casm = true

[tool.fmt]
sort-module-level-items = true
3 changes: 2 additions & 1 deletion starknet/src/L1_messages_proxy/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub mod L1MessagesProxy {
#[l1_handler]
fn receive_from_l1(ref self: ContractState, from_address: felt252, data: L1Payload) {
assert!(
from_address == self.get_l1_messages_sender().into(), "L1MessagesProxy: unauthorized sender"
from_address == self.get_l1_messages_sender().into(),
"L1MessagesProxy: unauthorized sender"
);
}

Expand Down
10 changes: 5 additions & 5 deletions starknet/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
mod types;
// pub mod test_utils;

pub mod test_utils;
mod types;

mod fact_registry {
pub mod fact_registry {
pub mod contract;
pub mod interface;
}

mod L1_headers_store {
pub mod L1_headers_store {
pub mod contract;
pub mod interface;
}

mod L1_messages_proxy {
pub mod L1_messages_proxy {
pub mod contract;
pub mod interface;
}
Expand Down
29 changes: 18 additions & 11 deletions starknet/src/test_utils.cairo → starknet/tests/test_utils.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
use snforge_std::{ declare, ContractClassTrait };
use fossil::fact_registry::{contract::FactRegistry, interface::{IFactRegistryDispatcher, IFactRegistryDispatcherTrait}};
use fossil::L1_headers_store::{contract::L1HeaderStore, interface::{IL1HeadersStoreDispatcher, IL1HeadersStoreDispatcherTrait}};
use fossil::L1_messages_proxy::{contract::L1MessagesProxy, interface::{IL1MessagesProxyDispatcher, IL1MessagesProxyDispatcherTrait}};
use fossil::L1_headers_store::{
contract::L1HeaderStore, interface::{IL1HeadersStoreDispatcher, IL1HeadersStoreDispatcherTrait}
};
use fossil::L1_messages_proxy::{
contract::L1MessagesProxy,
interface::{IL1MessagesProxyDispatcher, IL1MessagesProxyDispatcherTrait}
};
use fossil::fact_registry::{
contract::FactRegistry, interface::{IFactRegistryDispatcher, IFactRegistryDispatcherTrait}
};
use snforge_std::{declare, ContractClassTrait};

fn L1_messege_origin() -> starknet::EthAddress {
'L1_messege_origin'.try_into().unwrap()
}

fn OWNER() -> starknet::ContractAddress{
fn OWNER() -> starknet::ContractAddress {
starknet::contract_address_const::<'OWNER'>()
}
#[derive(Drop, Copy)]
Expand All @@ -20,19 +27,19 @@ struct Dispatchers {
pub fn setup() -> Dispatchers {
let contract = declare("FactRegistry").unwrap();
let (contract_address, _) = contract.deploy(@array![]).unwrap();
let fact_registry = IFactRegistryDispatcher{contract_address};
let fact_registry = IFactRegistryDispatcher { contract_address };

let contract = declare("L1HeadersStore").unwrap();
let (contract_address, _) = contract.deploy(@array![]).unwrap();
let l1_headers_store = IL1HeadersStoreDispatcher{contract_address};
let l1_headers_store = IL1HeadersStoreDispatcher { contract_address };

let contract = declare("L1MessagesProxy").unwrap();
let (contract_address, _) = contract.deploy(@array![]).unwrap();
let l1_messages_proxy = IL1MessagesProxyDispatcher{contract_address};
let l1_messages_proxy = IL1MessagesProxyDispatcher { contract_address };

fact_registry.initialize(l1_headers_store.contract_address);
l1_headers_store.initialize(l1_messages_proxy.contract_address);
l1_messages_proxy.initialize(L1_messege_origin(), l1_headers_store.contract_address, OWNER());

Dispatchers{fact_registry, l1_headers_store, l1_messages_proxy}
}
Dispatchers { fact_registry, l1_headers_store, l1_messages_proxy }
}

0 comments on commit cb9ca36

Please sign in to comment.