Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup of escrow clearing after withdrawing, added tests to check #246

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/blockchain/starknet/src/bridge.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ mod bridge {
};

use poseidon::poseidon_hash_span;
use snforge_std::{load, map_entry_address};

component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);

Expand Down
12 changes: 8 additions & 4 deletions apps/blockchain/starknet/src/tests/bridge_t.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod tests {

use snforge_std::{
declare, ContractClass, ContractClassTrait, start_prank, stop_prank, CheatTarget, L1Handler,
get_class_hash, spy_events, SpyOn
get_class_hash, spy_events, SpyOn, load, map_entry_address,
};

#[derive(Drop)]
Expand Down Expand Up @@ -1319,6 +1319,10 @@ mod tests {
let mut buf = array![];
req.serialize(ref buf);

start_prank(CheatTarget::One(bridge_address), BRIDGE_ADMIN);
bridge.set_l1_l2_collection_mapping(collection_l1, erc721b_address);
stop_prank(CheatTarget::One(bridge_address));

// Execute withdrawal
let mut l1_handler = L1Handler {
contract_address: bridge_address,
Expand All @@ -1332,12 +1336,12 @@ mod tests {
assert_eq!(erc721.owner_of(0), OWNER_L2, "Token should be transferred to OWNER_L2");

// Verify escrow is cleared
let is_escrowed = load(
let escrowed = load(
bridge_address,
map_entry_address(selector!("escrow"), array![erc721b_address.into(), 0, 0].span()),
1
)
.is_zero();
);
let is_escrowed = escrowed.len() == 0 && (*escrowed[0]).is_zero();
ptisserand marked this conversation as resolved.
Show resolved Hide resolved
assert!(!is_escrowed, "Escrow should be cleared after withdrawal");
}
}
Loading