From 227fea04879113053e6bdd4a72a5f16413c6384b Mon Sep 17 00:00:00 2001 From: thlpkee20-wq Date: Tue, 28 Jul 2026 18:41:48 +0530 Subject: [PATCH] test(admin): cover cancel_admin_transfer auth and idempotency boundaries cancel_admin_transfer had no direct test coverage for two boundaries that every other admin-gated entrypoint in the i22 series already covers: - unauthorized caller: cancel_admin_transfer_requires_admin_auth - idempotent no-op: cancelling with nothing pending must not panic, and must leave both Admin and PendingAdmin unchanged --- contracts/escrow/src/test.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/contracts/escrow/src/test.rs b/contracts/escrow/src/test.rs index 485cad5..44e5eb1 100644 --- a/contracts/escrow/src/test.rs +++ b/contracts/escrow/src/test.rs @@ -2689,6 +2689,16 @@ fn test_i20_wrong_caller_accept_rejected() { client.accept_admin_transfer(&intruder); } #[test] +fn test_i20_cancel_with_nothing_pending_is_a_noop() { + let env = Env::default(); + let (client, admin) = setup_initialized(&env); + // No propose_admin_transfer call: nothing is pending. Cancelling must + // be a no-op, not a panic — mirrors unpause()'s idempotency contract. + client.cancel_admin_transfer(); + assert_eq!(client.get_pending_admin(), None); + assert_eq!(client.get_admin(), Some(admin)); +} +#[test] fn test_i20_repropose_overwrites_pending() { let env = Env::default(); let (client, admin) = setup_initialized(&env); @@ -3022,6 +3032,13 @@ fn test_i22_propose_admin_transfer_requires_admin_auth() { } #[test] #[should_panic] +fn test_i22_cancel_admin_transfer_requires_admin_auth() { + let env = Env::default(); + let client = setup_scoped_auth(&env); + client.cancel_admin_transfer(); +} +#[test] +#[should_panic] fn test_i22_set_price_tiers_requires_admin_auth() { let env = Env::default(); let client = setup_scoped_auth(&env);