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
10 changes: 9 additions & 1 deletion contracts/milestone-escrow/src/admin_override_cancel_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
//! - Terminal milestones are correctly skipped in every scenario.

use super::*;
use crate::test::setup_funded_escrow;
use crate::{DataKey, Error, MilestoneEscrowClient, MilestoneStatus};
use soroban_sdk::testutils::Address as _;
use soroban_sdk::{token, vec, Address, Env};

// ────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -263,13 +265,19 @@ fn test_cancel_refund_all_terminal_returns_invalid_amount() {
let env = Env::default();
env.mock_all_auths();

let (client_addr, freelancer_addr, _, admin_addr, _, _, client) =
let (client_addr, freelancer_addr, _, admin_addr, token_id, contract_id, client) =
setup_funded_escrow(&env, vec![&env, 2_000_i128]);

// Fully release the single milestone via normal path.
client.mark_delivered(&freelancer_addr, &0u32);
client.approve_milestone(&client_addr, &0u32);

// Top up the contract so the zero-balance boundary guard in
// `cancel_escrow` still lets a cancel go through even though every
// milestone is now terminal and fully released.
let token_admin = token::StellarAssetClient::new(&env, &token_id);
token_admin.mint(&contract_id, &1_000_i128);

client.cancel_escrow(&client_addr);

let result = client.try_admin_override_cancel_refund(&admin_addr);
Expand Down
7 changes: 4 additions & 3 deletions contracts/milestone-escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,6 @@ impl MilestoneEscrow {
/// * `InvalidStatus` – `CancelLock` is not active.
/// * `InvalidAmount` – Total remaining balance is zero (nothing to refund).
pub fn admin_override_cancel_refund(env: Env, admin: Address) -> Result<(), Error> {
admin.require_auth();
Self::require_admin(&env, &admin)?;

// Only valid when a cancel lock is active.
Expand Down Expand Up @@ -4307,12 +4306,14 @@ impl MilestoneEscrow {
}
}

#[cfg(test)]
mod test;
#[cfg(test)]
mod test_emergency_pause;
#[cfg(test)]
mod test_payment_streaming_milestones;
#[cfg(test)]
mod admin_override_cancel_tests;

// ── escrow_interest_yield: admin emergency override endpoints ─────────────────
//
// Design rationale
// ─────────────────
Expand Down
2 changes: 1 addition & 1 deletion contracts/milestone-escrow/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl ReentrantToken {
}
}

fn setup_funded_escrow(
pub(crate) fn setup_funded_escrow(
env: &Env,
milestone_amounts: soroban_sdk::Vec<i128>,
) -> (
Expand Down
Loading
Loading