From a48c41b4d03d187bde6385a68055db23aa17f728 Mon Sep 17 00:00:00 2001 From: Ify Justin Date: Mon, 24 Aug 2026 05:10:03 +0000 Subject: [PATCH 1/2] fix: consolidate MockDripsContract into tests/common/mod.rs Closes #199 MockDripsContract was independently defined in both tests/purge_reward_stream.rs and tests/test.rs with identical start_stream stubs. Any future change to the mocked Drips interface would have required updating two separate definitions with no guarantee they stayed in sync. - Add tests/common/mod.rs with the single canonical MockDripsContract - Update tests/purge_reward_stream.rs to import from common - Update tests/test.rs to import from common --- tests/common/mod.rs | 18 ++++++++++++++++++ tests/purge_reward_stream.rs | 13 ++++--------- tests/test.rs | 10 +++------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 tests/common/mod.rs diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 00000000..90cfdd08 --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,18 @@ +use soroban_sdk::{contract, contractimpl, Address, Env}; + +/// Shared mock for the Drips protocol contract. +/// Used by both `purge_reward_stream` and `test` integration test suites +/// so the stub only needs to be maintained in one place (issue #199). +#[contract] +pub struct MockDripsContract; + +#[contractimpl] +impl MockDripsContract { + pub fn start_stream( + _env: Env, + _contributor: Address, + _task_id: u64, + _resolution_status: u32, + ) { + } +} diff --git a/tests/purge_reward_stream.rs b/tests/purge_reward_stream.rs index cd035a11..71c72937 100644 --- a/tests/purge_reward_stream.rs +++ b/tests/purge_reward_stream.rs @@ -4,18 +4,13 @@ // RewardStream(task_id) / AllRewardStreams entries once the task // referenced by that stream has been purged. +mod common; + +use common::MockDripsContract; use soroban_sdk::token::StellarAssetClient; -use soroban_sdk::{contract, contractimpl, testutils::Address as _, Address, Env}; +use soroban_sdk::{testutils::Address as _, Address, Env}; use vero_core_contracts::{Role, VeroContractClient}; -#[contract] -pub struct MockDripsContract; - -#[contractimpl] -impl MockDripsContract { - pub fn start_stream(_env: Env, _contributor: Address, _task_id: u64, _resolution_status: u32) {} -} - const LOCK_THRESHOLD: i128 = 100; fn setup() -> (Env, Address, Address, VeroContractClient<'static>) { diff --git a/tests/test.rs b/tests/test.rs index 870f868c..97b0747e 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,5 +1,8 @@ #![cfg(any())] // Disabled due to upstream breakages +mod common; +use common::MockDripsContract; + use soroban_sdk::token::{Client as TokenClient, StellarAssetClient as TestTokenClient}; use soroban_sdk::{ testutils::{Address as _, Ledger as _}, @@ -1248,13 +1251,6 @@ fn test_simulated_migration_failure_rolls_back() { assert_eq!(client.get_storage_version(), 0); } -#[contract] -pub struct MockDripsContract; - -#[contractimpl] -impl MockDripsContract { - pub fn start_stream(_env: Env, _contributor: Address, _task_id: u64, _resolution_status: u32) {} -} #[test] fn test_purge_done_task_removes_storage() { let (env, _contract_id, admin, token, client) = setup(); From 808984a22bd49914b1335e730a6424b8a37431ff Mon Sep 17 00:00:00 2001 From: Ify Justin Date: Sun, 30 Aug 2026 12:50:46 +0000 Subject: [PATCH 2/2] fix(fmt): collapse start_stream stub to single line per rustfmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The multi-line empty-body function signature in tests/common/mod.rs was rejected by `cargo fmt --check` (CI Format check step). rustfmt collapses empty-body functions with params that fit on one line into a single-line form. No logic change — stub body remains empty. --- tests/common/mod.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 90cfdd08..55a52f41 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -8,11 +8,5 @@ pub struct MockDripsContract; #[contractimpl] impl MockDripsContract { - pub fn start_stream( - _env: Env, - _contributor: Address, - _task_id: u64, - _resolution_status: u32, - ) { - } + pub fn start_stream(_env: Env, _contributor: Address, _task_id: u64, _resolution_status: u32) {} }