diff --git a/contracts/escrow/src/lib.rs b/contracts/escrow/src/lib.rs index 325efe4..9947cbc 100644 --- a/contracts/escrow/src/lib.rs +++ b/contracts/escrow/src/lib.rs @@ -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 = env diff --git a/contracts/escrow/src/tests/ttl.rs b/contracts/escrow/src/tests/ttl.rs index 9688647..a087eab 100644 --- a/contracts/escrow/src/tests/ttl.rs +++ b/contracts/escrow/src/tests/ttl.rs @@ -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();