Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions contracts/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ impl EscrowContract {
let next_id = id.checked_add(1).ok_or(Error::Overflow)?;
env.storage().instance().set(&DataKey::MatchCount, &next_id);
env.storage().persistent().set(&DataKey::GameId(m.game_id.clone()), &true);
env.storage().persistent().extend_ttl(
&DataKey::GameId(m.game_id.clone()),
MATCH_TTL_LEDGERS,
MATCH_TTL_LEDGERS,
);

// Add match ID to both players' match lists
let mut player1_matches: soroban_sdk::Vec<u64> = env
Expand Down
21 changes: 21 additions & 0 deletions contracts/escrow/src/tests/ttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ fn test_ttl_extended_on_create_match() {
assert_eq!(ttl, crate::MATCH_TTL_LEDGERS);
}

#[test]
fn test_game_id_ttl_extended_on_match_reservation() {
let (env, contract_id, _oracle, player1, player2, token, _admin) = setup();
let client = EscrowContractClient::new(&env, &contract_id);
let game_id = String::from_str(&env, "reserved_game_ttl");

client.create_match(
&player1,
&player2,
&100,
&token,
&game_id,
&Platform::Lichess,
);

let ttl = env.as_contract(&contract_id, || {
env.storage().persistent().get_ttl(&DataKey::GameId(game_id.clone()))
});
assert_eq!(ttl, crate::MATCH_TTL_LEDGERS);
}

#[test]
fn test_ttl_extended_on_deposit() {
let (env, contract_id, _oracle, player1, player2, token, _admin) = setup();
Expand Down