-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: initiliased testcases * admin function tests * fix: max total balance check * feat: block token test * disable limit test * feat: add failing tc for withdraw limit * fixed testcases after rebase * chore: added messaging mock * Update src/bridge/token_bridge.cairo Co-authored-by: Apoorv Sadana <[email protected]> * resolve comments * add reactivate and unblock * add reactivate and unblock * unblock tests * reactivate and unblock tests * resolved merge conflicts * restructure testcases * fix: visibility modifier * deposit tests * make them unit * make them unit * deposit flow tests * change to mock usdc address * improve: not needed to deploy usdc in while mock testing * unit testcases * add token actions restructure * migrate to latest foundry * restructure * deposit failing tc * test: happy withdraw test * chore: ran formatter * fix settlement of message * change deposit tests to use message_payloads * add assert * failing withdraw tc * cancel request * deposit with message cancels * Update tests/deposit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * resolved comments * fix consume message * reclaim testcases * fix consume message check * consume message * add balance check * add events in actions * deactivate tc * send messages tc * change name * withdrawal limit tests initialised * fix build failure * remaining quota * withdrawal tests * Update src/withdrawal_limit/mock.cairo Co-authored-by: Apoorv Sadana <[email protected]> * Update src/withdrawal_limit/tests/withdrawal_limit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * Update src/withdrawal_limit/tests/withdrawal_limit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * Update src/withdrawal_limit/tests/withdrawal_limit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * should fail if message not registered (#12) * resolve commits * Update src/withdrawal_limit/tests/withdrawal_limit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * Update src/withdrawal_limit/tests/withdrawal_limit_test.cairo Co-authored-by: Apoorv Sadana <[email protected]> * move file to mocks * code repetition reduced * failing tests fixed --------- Co-authored-by: Apoorv Sadana <[email protected]>
- Loading branch information
1 parent
4f7a8ec
commit b753a64
Showing
16 changed files
with
437 additions
and
52 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#[starknet::contract] | ||
mod messaging_malicious { | ||
use piltover::messaging::interface::IMessaging; | ||
use starknet::ContractAddress; | ||
|
||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
|
||
#[abi(embed_v0)] | ||
impl MessagingImpl of IMessaging<ContractState> { | ||
fn send_message_to_appchain( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252> | ||
) -> (felt252, felt252) { | ||
(0, 0) | ||
} | ||
|
||
fn consume_message_from_appchain( | ||
ref self: ContractState, from_address: ContractAddress, payload: Span<felt252> | ||
) -> felt252 { | ||
0 | ||
} | ||
|
||
fn sn_to_appchain_messages(self: @ContractState, message_hash: felt252) -> felt252 { | ||
0 | ||
} | ||
|
||
fn appchain_to_sn_messages(self: @ContractState, message_hash: felt252) -> felt252 { | ||
0 | ||
} | ||
|
||
fn start_message_cancellation( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252>, | ||
nonce: felt252, | ||
) -> felt252 { | ||
0 | ||
} | ||
|
||
fn cancel_message( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252>, | ||
nonce: felt252, | ||
) -> felt252 { | ||
0 | ||
} | ||
} | ||
} |
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,80 @@ | ||
use starknet::ContractAddress; | ||
|
||
#[starknet::interface] | ||
pub trait IMockWithdrawalLimit<TState> { | ||
fn toggle_withdrawal_limit_for_token( | ||
ref self: TState, token: ContractAddress, is_applied: bool | ||
); | ||
fn consume_quota(ref self: TState, token: ContractAddress, amount: u256); | ||
fn write_daily_withdrawal_limit_pct(ref self: TState, limit_percent: u8); | ||
fn get_daily_withdrawal_limit_pct(self: @TState) -> u8; | ||
} | ||
|
||
#[starknet::contract] | ||
pub mod withdrawal_limit_mock { | ||
use starknet_bridge::withdrawal_limit::component::WithdrawalLimitComponent::InternalTrait; | ||
use starknet_bridge::withdrawal_limit::{ | ||
component::WithdrawalLimitComponent, | ||
interface::{IWithdrawalLimitDispatcher, IWithdrawalLimitDispatcherTrait, IWithdrawalLimit} | ||
}; | ||
use starknet_bridge::bridge::interface::IWithdrawalLimitStatus; | ||
use starknet::ContractAddress; | ||
|
||
|
||
component!(path: WithdrawalLimitComponent, storage: withdrawal, event: WithdrawalEvent); | ||
|
||
// WithdrawalLimit | ||
#[abi(embed_v0)] | ||
impl WithdrawalLimitImpl = | ||
WithdrawalLimitComponent::WithdrawalLimitImpl<ContractState>; | ||
impl WithdrawalLimitInternal = WithdrawalLimitComponent::InternalImpl<ContractState>; | ||
|
||
|
||
#[storage] | ||
struct Storage { | ||
limits: LegacyMap<ContractAddress, bool>, | ||
#[substorage(v0)] | ||
withdrawal: WithdrawalLimitComponent::Storage, | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
pub enum Event { | ||
#[flat] | ||
WithdrawalEvent: WithdrawalLimitComponent::Event, | ||
} | ||
|
||
#[constructor] | ||
pub fn constructor(ref self: ContractState) { | ||
self.withdrawal.initialize(5); | ||
} | ||
|
||
|
||
#[abi(embed_v0)] | ||
impl MockWithdrawalLimitImpl of super::IMockWithdrawalLimit<ContractState> { | ||
fn toggle_withdrawal_limit_for_token( | ||
ref self: ContractState, token: ContractAddress, is_applied: bool | ||
) { | ||
self.limits.write(token, is_applied); | ||
} | ||
|
||
fn consume_quota(ref self: ContractState, token: ContractAddress, amount: u256) { | ||
self.withdrawal.consume_withdrawal_quota(token, amount); | ||
} | ||
|
||
fn write_daily_withdrawal_limit_pct(ref self: ContractState, limit_percent: u8) { | ||
self.withdrawal.write_daily_withdrawal_limit_pct(limit_percent); | ||
} | ||
|
||
fn get_daily_withdrawal_limit_pct(self: @ContractState) -> u8 { | ||
self.withdrawal.daily_withdrawal_limit_pct.read() | ||
} | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl WithdrawalLimitStatusImpl of IWithdrawalLimitStatus<ContractState> { | ||
fn is_withdrawal_limit_applied(self: @ContractState, token: ContractAddress) -> bool { | ||
self.limits.read(token) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.