Skip to content

test: add coordinator mock tests and file-system pallet tests#148

Merged
mudigal merged 10 commits into
test/provider-node-http-testsfrom
test/coordinator-and-fs-pallet-tests
Jun 10, 2026
Merged

test: add coordinator mock tests and file-system pallet tests#148
mudigal merged 10 commits into
test/provider-node-http-testsfrom
test/coordinator-and-fs-pallet-tests

Conversation

@mudigal

@mudigal mudigal commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

#144

Split from #139 (PR 4 of 4). Stacked on #147.

Add coordinator integration tests using mock chain clients (enabled by the trait extraction in #145) and file-system drive-registry success-path tests:

  • Agreement coordinator: Mock chain client lifecycle tests
  • Challenge responder: Mock chain client response tests
  • Checkpoint coordinator: Mock chain client scheduling tests
  • Replica sync coordinator: Mock chain client sync tests
  • Drive registry pallet: Success-path tests for drive lifecycle

PR stack

# PR Base Description
1 #145 dev Refactor + CI
2 #146 dev Pallet tests (independent)
3 #147 #145 HTTP integration tests
4 This PR #147 Coordinator + FS tests

Test plan

  • SKIP_WASM_BUILD=1 cargo clippy -p storage-provider-node --all-targets passes
  • cargo test -p storage-provider-node — all tests pass (HTTP + coordinator)
  • cargo test -p pallet-drive-registry — drive registry tests pass
  • Pure test additions — no production code changes

Add coordinator integration tests using mock chain clients (enabled by
the trait extraction in PR 1) and file-system drive-registry success-path tests:

- Agreement coordinator: mock chain client lifecycle tests
- Challenge responder: mock chain client response tests
- Checkpoint coordinator: mock chain client scheduling tests
- Replica sync coordinator: mock chain client sync tests
- Drive registry pallet: success-path tests for drive lifecycle

@ilchu ilchu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this one there's quite a few improvements that could be had to make it snappier, but otherwise hooray for the extended coverage.

Comment thread provider-node/tests/coordinators/agreement.rs
Comment thread provider-node/tests/challenge_responder_integration.rs Outdated
Comment thread provider-node/tests/replica_sync_coordinator_integration.rs Outdated
Comment thread provider-node/tests/challenge_responder_integration.rs Outdated
Comment thread provider-node/tests/replica_sync_coordinator_integration.rs Outdated
Comment thread provider-node/tests/challenge_responder_integration.rs Outdated
Comment thread provider-node/tests/coordinators/replica_sync.rs
Comment thread provider-node/tests/replica_sync_coordinator_integration.rs Outdated
Comment thread provider-node/tests/agreement_coordinator_integration.rs Outdated
Comment thread provider-node/tests/challenge_responder_integration.rs Outdated
mudigal added 2 commits June 10, 2026 11:19
Address PR #148 review feedback:
- Merge 4 test binaries into tests/coordinators/ module for faster compile
- Remove SharedMock wrappers (use Arc<T> directly via blanket impls)
- Switch tokio::sync::Mutex to std::sync::Mutex in mocks
- Add start_paused = true on tests that use tokio::time::sleep
- Use full ALICE_SS58 constant instead of abridged addresses
- Add shared wait_for() helper to replace inline timeout loops
- Remove tautological variant-matching tests
- Add test-util feature to tokio dev-dependency
@mudigal mudigal requested a review from ilchu June 10, 2026 09:31
@mudigal mudigal merged commit 03f3968 into test/provider-node-http-tests Jun 10, 2026
3 checks passed
@mudigal mudigal deleted the test/coordinator-and-fs-pallet-tests branch June 10, 2026 13:12
mudigal added a commit that referenced this pull request Jun 10, 2026
* refactor(provider-node): extract chain traits for testability and harden CI

Extract chain interaction traits from 4 coordinators (agreement, challenge,
checkpoint, replica-sync) so each can be tested with mock chain clients.
Move Subxt implementations to dedicated `_subxt.rs` files.

- Add unified `ProviderError` type in `error.rs`
- Wire `Box<dyn Trait>` in `command.rs` startup
- Make `sign()` fallible across API handlers
- Add testability helpers to `fs_index.rs` and `s3_index.rs`
- CI: combine 3 pallet coverage jobs, glob discovery, validation guards
- CI: fix integration test flakiness
- Fix `//Bob` nonce issue in S3 CI integration test

* test(provider-node): add HTTP and storage integration tests

Add integration tests for the provider node's HTTP API layer:

- API integration: all HTTP endpoints (upload, download, commit, checkpoint, etc.)
- Auth integration: authentication middleware and signature verification
- Disk integration: on-disk storage backend operations
- FS integration: file-system API endpoint tests
- S3 integration: S3-compatible API endpoint tests

* refactor(provider-node): use #[async_trait] for coordinator traits, remove tempfile from PR 1

Replace manual `Pin<Box<dyn Future>>` return types with `#[async_trait]`
across all 4 coordinator chain-client traits and their subxt impls:
- AgreementChainClient
- ChallengeChainClient
- CheckpointChainClient
- ReplicaSyncChainClient

This preserves object safety (still `Box<dyn Trait>`) while making the
code cleaner and easier to implement mock versions in tests.

Also removes `tempfile` dev-dependency (unused in this PR; belongs in PR 3).

* fix(provider-node): add tempfile dev-dependency for disk integration tests

* refactor(provider-node): use subxt value! macro for dynamic value construction

Replace verbose Value::named_composite/unnamed_variant calls with the
scale_value::value! macro across all _subxt.rs files. Also shorten
fully-qualified subxt::dynamic::Value:: paths with a use import.

* refactor(provider-node): add blanket Arc<T> impls for coordinator traits

Each coordinator trait now has an `impl<T: Trait> Trait for Arc<T>` that
delegates to the inner value, eliminating the need for SharedMock newtype
wrappers in tests.

* refactor(provider-node): address PR #147 review feedback

- Remove unnecessary sleep after tokio::spawn in disk test server
- Convert MembershipResolver trait to use #[async_trait] for compact
  return signature instead of manual Pin<Box<dyn Future>>
- Update ChainMembershipResolver and MockResolver impls accordingly

* fix(ci): restore chain-spec-script resolution for SC integration tests

The merge from dev incorrectly removed the "Resolve chain-spec script"
step and left a reference to matrix.runtime.chain_spec_script which
doesn't exist in this job (no matrix strategy). Restore the env var
approach that reads from runtimes-matrix.json.

* test: add coordinator mock tests and file-system pallet tests (#148)

* test: add coordinator mock tests and file-system pallet tests

Add coordinator integration tests using mock chain clients (enabled by
the trait extraction in PR 1) and file-system drive-registry success-path tests:

- Agreement coordinator: mock chain client lifecycle tests
- Challenge responder: mock chain client response tests
- Checkpoint coordinator: mock chain client scheduling tests
- Replica sync coordinator: mock chain client sync tests
- Drive registry pallet: success-path tests for drive lifecycle

* refactor(tests): update mock trait impls to use #[async_trait]

Align test mocks with the async_trait conversion in the coordinator
trait definitions from the base branch.

* test(provider-node): consolidate coordinator tests into single binary

Address PR #148 review feedback:
- Merge 4 test binaries into tests/coordinators/ module for faster compile
- Remove SharedMock wrappers (use Arc<T> directly via blanket impls)
- Switch tokio::sync::Mutex to std::sync::Mutex in mocks
- Add start_paused = true on tests that use tokio::time::sleep
- Use full ALICE_SS58 constant instead of abridged addresses
- Add shared wait_for() helper to replace inline timeout loops
- Remove tautological variant-matching tests
- Add test-util feature to tokio dev-dependency

---------

Co-authored-by: Ilia Churin <ilia@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants