Skip to content

test: Add multi-copy upload testing scenario with filecion-pin#103

Open
galargh wants to merge 20 commits intogalargh/latest-synapse-sdk-localnetfrom
galargh/pin
Open

test: Add multi-copy upload testing scenario with filecion-pin#103
galargh wants to merge 20 commits intogalargh/latest-synapse-sdk-localnetfrom
galargh/pin

Conversation

@galargh
Copy link
Copy Markdown
Contributor

@galargh galargh commented Apr 12, 2026

Resolves #94

Description

Adds test_multi_copy_upload to the scenario suite. The test exercises filecoin-pin against the devnet by uploading a deterministic 20 MiB random file, requiring multiple retrieval URLs, downloading each retrieval URL, and verifying each downloaded file against the expected root CID.

This PR is based on galargh/latest-synapse-sdk-localnet from PR #107, which moves the devnet to the newer Synapse-compatible localnet setup.

Current Test Flow

  1. Creates a temporary npm project.
  2. Installs:
    • filecoin-pin=0.20.1
    • multiformats=13.4.2
  3. Patches the temporary installed @filoz/synapse-core package to remove Content-Length from the streaming upload request headers in dist/src/sp/upload-streaming.js.
    • This is still needed because filecoin-pin=0.20.1 resolves to @filoz/synapse-core=0.4.1, and that published package still sends Content-Length on the transformed streaming body.
    • Without this patch, CI fails with StorageContext store failed: Failed to store piece on service provider - Network request failed.
  4. Creates a deterministic 20 MiB random file.
  5. Runs a single default multi-copy upload:
    • filecoin-pin add --network devnet <upload_dir>
  6. Strips ANSI escape codes from filecoin-pin output before parsing.
  7. Parses:
    • root CID,
    • piece CID,
    • retrieval URLs.
  8. Requires:
    • exactly one root CID in the output,
    • a piece CID,
    • at least two retrieval URLs.
  9. Converts piece retrieval URLs into root IPFS retrieval URLs.
  10. Downloads each retrieval URL with ?format=raw.
  11. Verifies each downloaded file by running inline Node from the temp npm project and comparing the file SHA-256 digest against the root CID multihash.

Other Changes

Validation

Local:

python3 -m py_compile scenarios/run.py scenarios/test_multi_copy_upload.py
FIX=0 ./scripts/lint.sh

CI:

@FilOzzy FilOzzy added this to FOC Apr 12, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 12, 2026
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC Apr 12, 2026
@BigLep BigLep added this to the M4.2: mainnet GA milestone Apr 12, 2026
@galargh galargh changed the base branch from main to galargh/last-known-good-ref May 3, 2026 10:15
@galargh galargh closed this May 3, 2026
@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to 🎉 Done in FOC May 3, 2026
@galargh galargh reopened this May 3, 2026
@github-project-automation github-project-automation Bot moved this from 🎉 Done to ⌨️ In Progress in FOC May 3, 2026
@galargh galargh changed the title [WIP] test: filecoin-pin in CI as a testing scenario for multi-copy upload test: filecoin-pin in CI as a testing scenario for multi-copy upload May 4, 2026
@galargh galargh changed the base branch from galargh/last-known-good-ref to galargh/latest-synapse-sdk-localnet May 4, 2026 18:50
@galargh galargh closed this May 4, 2026
@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to 🎉 Done in FOC May 4, 2026
@galargh galargh reopened this May 4, 2026
@github-project-automation github-project-automation Bot moved this from 🎉 Done to ⌨️ In Progress in FOC May 4, 2026
@galargh galargh marked this pull request as ready for review May 4, 2026 22:36
return value or ""


def patch_synapse_core_streaming_upload(npm_dir: Path) -> bool:
Copy link
Copy Markdown
Contributor Author

@galargh galargh May 4, 2026

Choose a reason for hiding this comment

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

This patch is needed because @filoz/synapse-core 0.4.1 sets Content-Length on a transformed streaming upload body. Node/Undici rejects that as invalid content-length header, and filecoin-pin surfaces it as StorageContext store failed: Failed to store piece on service provider - Network request failed.

@galargh galargh requested review from BigLep and rvagg May 4, 2026 22:38
@galargh galargh changed the title test: filecoin-pin in CI as a testing scenario for multi-copy upload test: Add multi-copy upload testing scenario with filecion-pin May 4, 2026
@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC May 5, 2026
@BigLep BigLep requested a review from Copilot May 5, 2026 02:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new end-to-end scenario test that validates multi-copy uploads against the devnet using filecoin-pin, then retrieves from multiple URLs and verifies the downloaded bytes against the expected root CID.

Changes:

  • Introduces scenarios/test_multi_copy_upload.py to run a deterministic 20 MiB upload via filecoin-pin, parse output (root CID / piece CID / retrieval URLs), download each retrieval URL, and verify content.
  • Updates scenarios/run.py to include the new scenario and adjusts the test_storage_e2e timeout.
  • Updates PR CI workflow trigger behavior by removing the pull_request.branches: ['main'] filter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scenarios/test_multi_copy_upload.py New multi-copy upload + retrieval verification scenario using filecoin-pin with a temporary npm project and runtime patching.
scenarios/run.py Registers the new scenario in the ordered runner and updates timeouts.
.github/workflows/ci_pull_request.yml Allows PR CI to run without restricting pull_request triggers to main.


def run():
assert_ok("command -v node", "node is installed")
assert_ok("command -v pnpm", "pnpm is installed")
Comment on lines +70 to +81
def patch_synapse_core_streaming_upload(npm_dir: Path) -> bool:
"""Patch the temporary dependency tree for Node's streaming fetch behavior."""
patched = False
replacements = {
"""const headers = {
'Content-Type': 'application/octet-stream',
...(size == null ? {} : { 'Content-Length': size.toString() }),
};""": """const headers = {
'Content-Type': 'application/octet-stream',
};""",
}

Comment on lines +340 to +345
ipfs_dir = Path("ipfs").resolve()
ipfs_dir.mkdir(parents=True, exist_ok=True)

for i, url in enumerate(root_retrieval_urls, start=1):
file = ipfs_dir / f"{root_cid}_{i}.bin"
error = download_and_verify(url, file, root_cid, npm_dir)
Comment on lines +214 to +224
def run():
assert_ok("command -v node", "node is installed")
assert_ok("command -v pnpm", "pnpm is installed")

with tempfile.TemporaryDirectory(
prefix="filecoin-pin-upload-"
) as upload_tmp, tempfile.TemporaryDirectory(prefix="filecoin-pin-npm-") as npm_tmp:
upload_dir = Path(upload_tmp)
npm_dir = Path(npm_tmp)

if not run_cmd(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting review

Development

Successfully merging this pull request may close these issues.

filecoin-pin in CI as a testing scenario for multi-copy upload + Synapse testing

4 participants