From e6d1fa735f782e77228e1510b2f4552e4c8dae26 Mon Sep 17 00:00:00 2001 From: StreamFi Dev Date: Mon, 31 Aug 2026 11:50:55 +0100 Subject: [PATCH] test(stream): add operator_can_extend_duration direct success test extend_duration is listed in the DataKey::Operator doc as a delegated action, but the only existing positive operator test (operator_passes_auth_gate_for_extend_duration) was indirect it cancelled the stream first and asserted StreamCancelled rather than verifying the operator actually succeeds on a live stream. Add operator_can_extend_duration: sets an operator, mints the exact deposit (extra_seconds * rate) to the sender, calls extend_duration as the operator, and asserts both the updated end_time and the increased contract token balance. The non_sender_non_operator_rejected_by_extend_duration rejection test was already present and is unchanged. closes #463 --- contracts/stream/src/tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/contracts/stream/src/tests.rs b/contracts/stream/src/tests.rs index f31834c5..9f3f36ab 100644 --- a/contracts/stream/src/tests.rs +++ b/contracts/stream/src/tests.rs @@ -1312,6 +1312,25 @@ fn operator_passes_auth_gate_for_top_up() { assert_eq!(result, Err(Ok(Error::StreamCancelled))); } +#[test] +fn operator_can_extend_duration() { + let s = Setup::new(100, 3_600, false); + let operator = Address::generate(&s.env); + s.client.set_operator(&s.sender, &operator); + + let before_end = s.client.info().end_time; + // Mint the required deposit (100s × rate 100 = 10_000) to the sender so + // the token transfer inside extend_duration succeeds. + let token_admin = token::StellarAssetClient::new(&s.env, &s.token.address); + token_admin.mint(&s.sender, &10_000); + + let contract_before = s.token.balance(&s.client.address); + s.client.extend_duration(&operator, &100); + + assert_eq!(s.client.info().end_time, before_end + 100); + assert_eq!(s.token.balance(&s.client.address), contract_before + 10_000); +} + #[test] fn operator_passes_auth_gate_for_extend_duration() { // extend_duration transfers tokens FROM the sender via tk.transfer.