-
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.
tests: set up local component testing infrastructure and add initial …
…unit tests (#81) * imp: initialize a temp ChannelEnd * imp: better org around client-relevant validations under recv_validate * tests: add some local components tests
- Loading branch information
1 parent
540f292
commit 661b02b
Showing
43 changed files
with
646 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use openzeppelin_testing::events::{EventSpyExt, EventSpyExtImpl}; | ||
use snforge_std::EventSpy; | ||
use starknet::ContractAddress; | ||
use starknet_ibc_apps::tests::EMPTY_MEMO; | ||
use starknet_ibc_apps::transfer::TokenTransferComponent::{ | ||
Event, SendEvent, RecvEvent, CreateTokenEvent | ||
}; | ||
use starknet_ibc_apps::transfer::types::{Participant, PrefixedDenom, Memo}; | ||
|
||
#[generate_trait] | ||
pub impl TransferEventSpyExtImpl of TransferEventSpyExt { | ||
fn assert_send_event( | ||
ref self: EventSpy, | ||
contract_address: ContractAddress, | ||
sender: Participant, | ||
receiver: Participant, | ||
denom: PrefixedDenom, | ||
amount: u256 | ||
) { | ||
let expected = Event::SendEvent( | ||
SendEvent { sender, receiver, denom, amount, memo: EMPTY_MEMO(), } | ||
); | ||
self.assert_emitted_single(contract_address, expected); | ||
} | ||
|
||
fn assert_recv_event( | ||
ref self: EventSpy, | ||
contract_address: ContractAddress, | ||
sender: Participant, | ||
receiver: Participant, | ||
denom: PrefixedDenom, | ||
amount: u256, | ||
success: bool | ||
) { | ||
let expected = Event::RecvEvent( | ||
RecvEvent { sender, receiver, denom, amount, memo: EMPTY_MEMO(), success, } | ||
); | ||
self.assert_emitted_single(contract_address, expected); | ||
} | ||
|
||
fn assert_create_token_event( | ||
ref self: EventSpy, | ||
contract_address: ContractAddress, | ||
name: ByteArray, | ||
symbol: ByteArray, | ||
address: ContractAddress, | ||
initial_supply: u256 | ||
) { | ||
let expected = Event::CreateTokenEvent( | ||
CreateTokenEvent { name, symbol, address, initial_supply } | ||
); | ||
self.assert_emitted_single(contract_address, expected); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
cairo-contracts/packages/apps/src/tests/test_transfer.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,24 @@ | ||
use starknet_ibc_apps::tests::{MockTransferApp, CLASS_HASH}; | ||
use starknet_ibc_apps::transfer::TokenTransferComponent::{ | ||
TransferInitializerImpl, TransferReaderImpl | ||
}; | ||
use starknet_ibc_apps::transfer::TokenTransferComponent; | ||
|
||
type ComponentState = TokenTransferComponent::ComponentState<MockTransferApp::ContractState>; | ||
|
||
fn COMPONENT_STATE() -> ComponentState { | ||
TokenTransferComponent::component_state_for_testing() | ||
} | ||
|
||
fn setup() -> ComponentState { | ||
let mut state = COMPONENT_STATE(); | ||
state.initializer(CLASS_HASH()); | ||
state | ||
} | ||
|
||
#[test] | ||
fn test_init_state() { | ||
let state = setup(); | ||
let class_hash = state.read_erc20_class_hash(); | ||
assert_eq!(class_hash, CLASS_HASH()); | ||
} |
This file was deleted.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
cairo-contracts/packages/apps/src/transfer/components/transferrable.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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.