From 6e60fcda9605469ffc3b12a8578406da52f3078d Mon Sep 17 00:00:00 2001 From: Larry Date: Tue, 26 May 2026 14:10:16 +0100 Subject: [PATCH] Add test for empty game_id rejection --- contracts/escrow/src/tests.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/contracts/escrow/src/tests.rs b/contracts/escrow/src/tests.rs index 1ae8522..26ebbcf 100644 --- a/contracts/escrow/src/tests.rs +++ b/contracts/escrow/src/tests.rs @@ -72,6 +72,27 @@ fn test_initialize_emits_event() { assert_eq!(ev_admin, admin); } +#[test] +fn test_empty_game_id_rejected() { + let env = Env::default(); + env.mock_all_auths(); + + let admin = Address::generate(&env); + let oracle = Address::generate(&env); + + let contract_id = env.register_contract(None, EscrowContract); + let client = EscrowContractClient::new(&env, &contract_id); + + // initialize contract first (very important) + client.initialize(&oracle, &admin); + + // call with empty game_id + let result = client.try_create_match(&"".into()); + + // assert error + assert_eq!(result, Err(Error::InvalidGameId)); +} + #[test] fn test_is_initialized_false_before_initialize_and_true_after() { let env = Env::default();