Skip to content

Commit

Permalink
add test for PrefixedDenom
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Jan 14, 2025
1 parent 56a3213 commit aeefb02
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cairo-contracts/packages/apps/src/transfer/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ impl MemoValidateBasic of ValidateBasic<Memo> {
pub mod tests {
use serde_json::to_byte_array;
use starknet_ibc_testkit::dummies::{PACKET_DATA_FROM_SN, ERC20};
use starknet_ibc_utils::{ComputeKey, LocalKeyBuilderImpl, LocalKeyBuilderTrait};

// Snapshot test to ensure serialization stays consistent.
#[test]
Expand All @@ -285,5 +286,19 @@ pub mod tests {
"{\"denom\":\"2087021424722619777119509474943472645767659996348769578120564519014510906823\",\"amount\":\"100\",\"sender\":\"340767163730\",\"receiver\":\"cosmos1wxeyh7zgn4tctjzs0vtqpc6p5cxq5t2muzl7ng\",\"memo\":\"\"}";
assert_eq!(json, expected);
}

#[test]
fn test_prefixed_denom_key() {
let prefixed_denom = PACKET_DATA_FROM_SN(ERC20()).denom;
let direct_key = prefixed_denom.key();
let base_key = {
let mut hasher = LocalKeyBuilderImpl::init();
hasher.append_serde(@prefixed_denom.base);
hasher.key()
};
let expected: felt252 = 0x2e74acb5f5dfbbc9cddcd69d5ee307713735fe038880606804515cf078fc1ee;
assert_eq!(direct_key, expected);
assert_eq!(base_key, expected);
}
}

0 comments on commit aeefb02

Please sign in to comment.