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
4 changes: 2 additions & 2 deletions contracts/stream/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use soroban_sdk::Env;

use crate::{load_stream, load_delegated_nonce, ContractError};
use crate::{load_delegated_nonce, load_stream, ContractError};

/// Validate the delegation parameters for a delegated-withdraw call.
///
Expand Down Expand Up @@ -64,12 +64,12 @@ mod tests {
extern crate std;

use super::*;
use crate::{FluxoraStream, FluxoraStreamClient, StreamKind};
use soroban_sdk::{
testutils::{Address as _, Ledger},
token::Client as TokenClient,
Address, Env,
};
use crate::{FluxoraStream, FluxoraStreamClient, StreamKind};

/// Set up a minimal contract environment and return (env, client, stream_id, recipient).
fn setup() -> (Env, FluxoraStreamClient<'static>, u64, Address) {
Expand Down
1 change: 1 addition & 0 deletions contracts/stream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod token_check;
pub mod types;
#[cfg(test)]
mod delegation;
mod token_check;

use events::*;
use soroban_sdk::{contract, contractimpl, symbol_short, token, Address, Env, Map};
Expand Down
24 changes: 14 additions & 10 deletions contracts/stream/tests/balance_conservation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ impl TestContext {

let contract_id = env.register_contract(None, FluxoraStream);
let token_admin = Address::generate(&env);
let token_id = env.register_stellar_asset_contract_v2(token_admin).address();
let token_id = env
.register_stellar_asset_contract_v2(token_admin)
.address();

let admin = Address::generate(&env);
let sender = Address::generate(&env);
Expand All @@ -88,12 +90,7 @@ impl TestContext {
StellarAssetClient::new(&env, &token_id).mint(&recipient, &1_000_000_000_000);

// Approve the contract to pull arbitrary top-up amounts from the sender.
TokenClient::new(&env, &token_id).approve(
&sender,
&contract_id,
&i128::MAX,
&1_000_000u32,
);
TokenClient::new(&env, &token_id).approve(&sender, &contract_id, &i128::MAX, &1_000_000u32);

env.ledger().set_timestamp(0);

Expand Down Expand Up @@ -292,7 +289,8 @@ fn assert_invariants(
.saturating_add(ctx.recipient_balance())
.saturating_add(ctx.contract_balance());
assert_eq!(
total_outside, INITIAL_MINT,
total_outside,
INITIAL_MINT,
"{label}: global token conservation violated: sender={} recipient={} contract={}",
ctx.sender_balance(),
ctx.recipient_balance(),
Expand Down Expand Up @@ -579,7 +577,10 @@ fn regression_cliff_only_unsupported_mutations() {
assert_eq!(ctx.client().get_withdrawable(&id), 1000);
let withdrawn = ctx.client().withdraw(&id);
assert_eq!(withdrawn, 1000);
assert_eq!(ctx.client().get_stream_state(&id).status, StreamStatus::Completed);
assert_eq!(
ctx.client().get_stream_state(&id).status,
StreamStatus::Completed
);
}

/// Completed streams must report a deterministic `deposit_amount` accrual
Expand All @@ -592,7 +593,10 @@ fn regression_completed_stream_accrual_is_deterministic() {
ctx.env.ledger().set_timestamp(1000);
ctx.env.ledger().set_sequence_number(1000);
ctx.client().withdraw(&id);
assert_eq!(ctx.client().get_stream_state(&id).status, StreamStatus::Completed);
assert_eq!(
ctx.client().get_stream_state(&id).status,
StreamStatus::Completed
);

for t in [0u64, 500, 1000, 10_000, u64::MAX] {
ctx.env.ledger().set_timestamp(t);
Expand Down
Loading