Skip to content

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

Merged
mudigal merged 23 commits into
devfrom
test/provider-node-http-tests
Jun 10, 2026
Merged

test(provider-node): add HTTP and storage integration tests#147
mudigal merged 23 commits into
devfrom
test/provider-node-http-tests

Conversation

@mudigal

@mudigal mudigal commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

#144

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

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

  • API integration: All HTTP endpoints (upload, download, commit, checkpoint, proof, delete, 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

PR stack

# PR Base Description
1 #145 dev Refactor + CI
2 #146 dev Pallet tests (independent)
3 This PR #145 HTTP integration tests
4 test/coordinator-and-fs-pallet-tests This PR Coordinator + FS tests

Test plan

  • SKIP_WASM_BUILD=1 cargo clippy -p storage-provider-node --all-targets passes
  • cargo test -p storage-provider-node — HTTP/storage tests pass
  • Pure test additions — no production code changes

mudigal added 2 commits June 8, 2026 21:09
…den 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
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
mudigal and others added 9 commits June 9, 2026 13:06
…emove 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).
…struction

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.
…paritytech/web3-storage into refactor/provider-node-trait-extraction

@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.

Once again, just ergonomics here.

Comment thread provider-node/tests/disk_integration.rs Outdated
Comment thread provider-node/tests/auth_integration.rs Outdated
Comment thread provider-node/Cargo.toml
mudigal added 4 commits June 10, 2026 11:18
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.
…paritytech/web3-storage into refactor/provider-node-trait-extraction
- 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
mudigal and others added 4 commits June 10, 2026 14:06
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.
Base automatically changed from refactor/provider-node-trait-extraction to dev June 10, 2026 13:02
mudigal added 2 commits June 10, 2026 15:12
* 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
@mudigal mudigal enabled auto-merge (squash) June 10, 2026 13:35
@mudigal mudigal merged commit dec6bc6 into dev Jun 10, 2026
26 checks passed
@mudigal mudigal deleted the test/provider-node-http-tests branch June 10, 2026 17:12
Comment thread provider-node/src/auth.rs
use subxt::dynamic::At;
use subxt::{dynamic::Value, OnlineClient, PolkadotConfig};

let api = OnlineClient::<PolkadotConfig>::from_url(&self.chain_rpc)

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.

@franciscoaguirre is this the reason why you started #159?

From what I reading about subxt:

  - new() / from_url() are the expensive parts (network handshake + metadata fetch). Call them once at startup, not per request.
  - Don't reconnect on every operation. A common anti-pattern is calling from_url inside a loop or per request — that opens a fresh WS connection and re-downloads metadata each time.

  A quick rule of thumb: treat OnlineClient<PolkadotConfig> like an Arc-backed handle (similar to a reqwest::Client or a DB pool) — construct once, clone everywhere.

@franciscoaguirre will you please check and refactor all this OnlineClient::<PolkadotConfig> also as a part of your #159 (or separate PR)?

@bkontur

bkontur commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Looks like some flaky test was introduced here, all the PRs on the top of this fails Basic tests. Potential fix introduced here: #161

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.

4 participants