kubo/test/sharness
Marcin Rataj 67c89bbd7e
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / unit-tests (push) Waiting to run
Go Test / cli-tests (push) Waiting to run
Go Test / example-tests (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
feat(config): add Import.* for CID Profiles from IPIP-499 (#11148)
* feat(config): Import.* and unixfs-v1-2025 profile

implements IPIP-499: add config options for controlling UnixFS DAG
determinism and introduces `unixfs-v1-2025` and `unixfs-v0-2015`
profiles for cross-implementation CID reproducibility.

changes:
- add Import.* fields: HAMTDirectorySizeEstimation, SymlinkMode,
  DAGLayout, IncludeEmptyDirectories, IncludeHidden
- add validation for all Import.* config values
- add unixfs-v1-2025 profile (recommended for new data)
- add unixfs-v0-2015 profile (alias: legacy-cid-v0)
- remove deprecated test-cid-v1 and test-cid-v1-wide profiles
- wire Import.HAMTSizeEstimationMode() to boxo globals
- update go.mod to use boxo with SizeEstimationMode support

ref: https://specs.ipfs.tech/ipips/ipip-0499/

* feat(add): add --dereference-symlinks, --empty-dirs, --hidden CLI flags

add CLI flags for controlling file collection behavior during ipfs add:

- `--dereference-symlinks`: recursively resolve symlinks to their target
  content (replaces deprecated --dereference-args which only worked on
  CLI arguments). wired through go-ipfs-cmds to boxo's SerialFileOptions.
- `--empty-dirs` / `-E`: include empty directories (default: true)
- `--hidden` / `-H`: include hidden files (default: false)

these flags are CLI-only and not wired to Import.* config options because
go-ipfs-cmds library handles input file filtering before the directory
tree is passed to kubo. removed unused Import.UnixFSSymlinkMode config
option that was defined but never actually read by the CLI.

also:
- wire --trickle to Import.UnixFSDAGLayout config default
- update go-ipfs-cmds to v0.15.1-0.20260117043932-17687e216294
- add SYMLINK HANDLING section to ipfs add help text
- add CLI tests for all three flags

ref: https://github.com/ipfs/specs/pull/499

* test(add): add CID profile tests and wire SizeEstimationMode

add comprehensive test suite for UnixFS CID determinism per IPIP-499:
- verify exact HAMT threshold boundary for both estimation modes:
  - v0-2015 (links): sum(name_len + cid_len) == 262144
  - v1-2025 (block): serialized block size == 262144
- verify HAMT triggers at threshold + 1 byte for both profiles
- add all deterministic CIDs for cross-implementation testing

also wires SizeEstimationMode through CLI/API, allowing
Import.UnixFSHAMTSizeEstimation config to take effect.

bumps boxo to ipfs/boxo@6707376 which aligns HAMT threshold with
JS implementation (uses > instead of >=), fixing CID determinism
at the exact 256 KiB boundary.

* feat(add): --dereference-symlinks now resolves all symlinks

Previously, resolving symlinks required two flags:
- --dereference-args: resolved symlinks passed as CLI arguments
- --dereference-symlinks: resolved symlinks inside directories

Now --dereference-symlinks handles both cases. Users only need one flag
to fully dereference symlinks when adding files to IPFS.

The deprecated --dereference-args still works for backwards compatibility
but is no longer necessary.

* chore: update boxo and improve changelog

- update boxo to ebdaf07c (nil filter fix, thread-safety docs)
- simplify changelog for IPIP-499 section
- shorten test names, move context to comments

* chore: update boxo to 5cf22196

* chore: apply suggestions from code review

Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>

* test(add): verify balanced DAG layout produces uniform leaf depth

add test that confirms kubo uses balanced layout (all leaves at same
depth) rather than balanced-packed (varying depths). creates 45MiB file
to trigger multi-level DAG and walks it to verify leaf depth uniformity.

includes trickle subtest to validate test logic can detect varying depths.

supports CAR export via DAG_LAYOUT_CAR_OUTPUT env var for test vectors.

* chore(deps): update boxo to 6141039ad8ef

switches to 6141039ad8

changes since 5cf22196ad0b:
- refactor(unixfs): use arithmetic for exact block size calculation
- refactor(unixfs): unify size tracking and make SizeEstimationMode immutable
- feat(unixfs): optimize SizeEstimationBlock and add mode/mtime tests

also clarifies that directory sharding globals affect both `ipfs add` and MFS.

* test(cli): improve HAMT threshold tests with exact +1 byte verification

- add UnixFSDataType() helper to directly check UnixFS type via protobuf
- refactor threshold tests to use exact +1 byte calculations instead of +1 file
- verify directory type directly (ft.TDirectory vs ft.THAMTShard) instead of
  inferring from link count
- clean up helper function signatures by removing unused cidLength parameter

* test(cli): consolidate profile tests into cid_profiles_test.go

remove duplicate profile threshold tests from add_test.go since they
are fully covered by the data-driven tests in cid_profiles_test.go.

changes:
- improve test names to describe what threshold is being tested
- add inline documentation explaining each test's purpose
- add byte-precise helper IPFSAddDeterministicBytes for threshold tests
- remove ~200 lines of duplicated test code from add_test.go
- keep non-profile tests (pinning, symlinks, hidden files) in add_test.go

* chore: update to rebased boxo and go-ipfs-cmds PRs

* docs: add HAMT threshold fix details to changelog

* feat(mfs): use Import config for CID version and hash function

make MFS commands (files cp, files write, files mkdir, files chcid)
respect Import.CidVersion and Import.HashFunction config settings
when CLI options are not explicitly provided.

also add tests for:
- files write respects Import.UnixFSRawLeaves=true
- single-block file: files write produces same CID as ipfs add
- updated comments clarifying CID parity with ipfs add

* feat(files): wire Import.UnixFSChunker and UnixFSDirectoryMaxLinks to MFS

`ipfs files` commands now respect these Import.* config options:
- UnixFSChunker: configures chunk size for `files write`
- UnixFSDirectoryMaxLinks: triggers HAMT sharding in `files mkdir`
- UnixFSHAMTDirectorySizeEstimation: controls size estimation mode

previously, MFS used hardcoded defaults ignoring user config.

changes:
- config/import.go: add UnixFSSplitterFunc() returning chunk.SplitterGen
- core/node/core.go: pass chunker, maxLinks, sizeEstimationMode to
  mfs.NewRoot() via new boxo RootOption API
- core/commands/files.go: pass maxLinks and sizeEstimationMode to
  mfs.Mkdir() and ensureContainingDirectoryExists(); document that
  UnixFSFileMaxLinks doesn't apply to files write (trickle DAG limitation)
- test/cli/files_test.go: add tests for UnixFSDirectoryMaxLinks and
  UnixFSChunker, including CID parity test with `ipfs add --trickle`

related: boxo@54e044f1b265

* feat(files): wire Import.UnixFSHAMTDirectoryMaxFanout and UnixFSHAMTDirectorySizeThreshold

wire remaining HAMT config options to MFS root:
- Import.UnixFSHAMTDirectoryMaxFanout via mfs.WithMaxHAMTFanout
- Import.UnixFSHAMTDirectorySizeThreshold via mfs.WithHAMTShardingSize

add CLI tests:
- files mkdir respects Import.UnixFSHAMTDirectoryMaxFanout
- files mkdir respects Import.UnixFSHAMTDirectorySizeThreshold
- config change takes effect after daemon restart

add UnixFSHAMTFanout() helper to test harness

update boxo to ac97424d99ab90e097fc7c36f285988b596b6f05

* fix(mfs): single-block files in CIDv1 dirs now produce raw CIDs

problem: `ipfs files write` in CIDv1 directories wrapped single-block
files in dag-pb even when raw-leaves was enabled, producing different
CIDs than `ipfs add --raw-leaves` for the same content.

fix: boxo now collapses single-block ProtoNode wrappers (with no
metadata) to RawNode in DagModifier.GetNode(). files with mtime/mode
stay as dag-pb since raw blocks cannot store UnixFS metadata.

also fixes sparse file writes where writing past EOF would lose data
because expandSparse didn't update the internal node pointer.

updates boxo to v0.36.1-0.20260203003133-7884ae23aaff
updates t0250-files-api.sh test hashes to match new behavior

* chore(test): use Go 1.22+ range-over-int syntax

* chore: update boxo to c6829fe26860

- fix typo in files write help text
- update boxo with CI fixes (gofumpt, race condition in test)

* chore: update go-ipfs-cmds to 192ec9d15c1f

includes binary content types fix: gzip, zip, vnd.ipld.car, vnd.ipld.raw,
vnd.ipfs.ipns-record

* chore: update boxo to 0a22cde9225c

includes refactor of maxLinks check in addLinkChild (review feedback).

* ci: fix helia-interop and improve caching

skip '@helia/mfs - should have the same CID after creating a file' test
until helia implements IPIP-499 (tracking: https://github.com/ipfs/helia/issues/941)

the test fails because kubo now collapses single-block files to raw CIDs
while helia explicitly uses reduceSingleLeafToSelf: false

changes:
- run aegir directly instead of helia-interop binary (binary ignores --grep flags)
- cache node_modules keyed by @helia/interop version from npm registry
- skip npm install on cache hit (matches ipfs-webui caching pattern)

* chore: update boxo to 1e30b954

includes latest upstream changes from boxo main

* chore: update go-ipfs-cmds to 1b2a641ed6f6

* chore: update boxo to f188f79fd412

switches to boxo@main after merging https://github.com/ipfs/boxo/pull/1088

* chore: update go-ipfs-cmds to af9bcbaf5709

switches to go-ipfs-cmds@master after merging https://github.com/ipfs/go-ipfs-cmds/pull/315

---------

Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
2026-02-04 22:03:15 +01:00
..
lib fix: disable telemetry in test profile (#10931) 2025-08-24 14:30:35 +02:00
t0024-files fix t0024 on osx 2017-09-03 18:43:18 -07:00
t0050-block-data core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0053-dag-data fix printing out of binary escaped data for test 2017-02-09 10:31:18 -08:00
t0054-dag-car-import-export-data feat!: dag import - don't pin roots by default (#9926) 2023-06-14 20:45:34 +00:00
t0060-data feat: relay v2 discovery (go-libp2p v0.19.0) (#8868) 2022-04-28 17:13:15 +02:00
t0109-gateway-web-_redirects-data feat(gateway): _redirects file support (#8890) 2022-09-23 18:44:19 +02:00
t0114-gateway-subdomains test: deterministic ipns fixtures during sharness gateway tests (#9667) 2023-05-03 15:01:13 +02:00
t0115-gateway-dir-listing Revert "chore: add hamt directory sharding test" 2023-03-14 13:53:17 +01:00
t0116-gateway-cache chore: restore exec perms for t0116-gateway-cache.sh and fixtures (#10085) 2023-08-18 09:34:42 +02:00
t0119-prometheus-data Upgrade to Boxo v0.36.0 (#11175) 2026-01-27 15:51:01 -08:00
t0165-keystore-data chore: update url 2025-04-08 15:17:34 +02:00
t0275-cid-security-data Fix t0275-cid-security.sh: rename bad block file 2021-12-02 09:46:23 -05:00
t0280-plugin-dag-jose-data Integrate go-dag-jose plugin (#8569) 2021-11-30 10:58:15 -08:00
t0280-plugin-data refactor: rename to kubo 2022-07-06 18:40:37 +02:00
t0280-plugin-git-data git: add git plugin tests 2017-07-12 23:38:32 +02:00
t0400-api-no-gateway fix: add versions 2023-02-27 12:16:33 +01:00
t0701-delegated-routing-reframe feat(routing): Delegated Routing (#8997) 2022-07-07 17:10:25 -04:00
t0702-delegated-routing-http chore: upgrade libipfs for routing HTTP API schema changes (#9477) 2022-12-07 17:34:00 -05:00
.gitignore test: port CircleCI to GH Actions and improve sharness reporting (#9355) 2023-01-14 00:49:52 +01:00
GNUmakefile fix: require gmake 2019-08-01 12:18:56 -07:00
README.md fix: switch away from IPFS_LOG_LEVEL (#10694) 2025-02-14 18:25:31 +00:00
Rules.mk feat(ci): reusable spellcheck from unified CI (#10873) 2025-08-14 00:35:35 +00:00
t0001-tests-work.sh Simplify grep in test to pass on MacOS 2020-03-12 04:42:53 +01:00
t0002-docker-image.sh feat: Provider.WorkerCount and stats reprovide (#10779) 2025-04-30 15:32:03 +02:00
t0003-docker-migrate.sh repo/fsrepo/migrations: verified HTTP migrations (#10324) 2024-02-19 14:20:58 +01:00
t0012-completion-fish.sh feat: Add command line completion for fish 2022-10-30 21:13:53 +00:00
t0015-basic-sh-functions.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0018-indent.sh fix(cmd): exit 1 on error (#10903) 2025-08-08 17:25:05 -07:00
t0021-config.sh fix: Issue #9364 JSON config validation (#10679) 2025-02-04 17:26:36 +01:00
t0022-init-default.sh switch ipfs init default key 2020-08-19 08:31:44 -07:00
t0023-shutdown.sh propagate test_launch_ipfs_daemon_without_network name 2021-07-08 16:53:58 -03:00
t0024-datastore-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0025-datastores.sh feat: pebbleds profile and plugin (#10530) 2024-10-03 13:58:14 -07:00
t0026-id.sh feat: periodic version check and json config (#10438) 2024-07-24 23:42:19 +02:00
t0027-rotate.sh Revert "feat: adds secp256k1 keypair type to key gen command, adds test cases" 2023-06-12 15:44:12 +02:00
t0030-mount.sh feat(fuse): Expose MFS as FUSE mount point (#10781) 2025-05-06 21:55:53 +02:00
t0031-mount-publish.sh test(sharness): fix fuse tests 2020-05-14 13:14:38 -07:00
t0032-mount-sharded.sh feat(config): ipfs add and Import options for controling UnixFS DAG Width (#10774) 2025-04-15 22:56:38 +02:00
t0040-add-and-cat.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0042-add-skip.sh feat: enable DHT Provide Sweep by default (#10955) 2025-11-12 23:55:17 +01:00
t0043-add-w.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0044-add-symlink.sh fix(sharness): use -Q option instead of pipe to tail cmd 2021-11-11 10:22:20 -05:00
t0045-ls.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0046-id-hash.sh test: fix "invert" commands in sharness tests (#9652) 2025-06-09 15:50:59 +02:00
t0047-add-mode-mtime.sh feat: Support storing UnixFS 1.5 Mode and ModTime (#10478) 2024-08-21 02:02:46 +02:00
t0050-block.sh core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0051-object.sh core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0052-object-diff.sh fix(sharness): use -Q option instead of pipe to tail cmd 2021-11-11 10:22:20 -05:00
t0053-dag.sh feat: add deduplication ratio to 'ipfs dag stat' (#9787) 2023-06-06 15:17:45 +02:00
t0054-dag-car-import-export.sh feat: built-in content blocking based on IPIP-383 (#10161) 2023-10-28 05:34:14 +02:00
t0055-dag-put-json-new-line.sh remove dag put option shortcuts 2021-09-27 14:39:03 -04:00
t0060-daemon.sh test: fix "invert" commands in sharness tests (#9652) 2025-06-09 15:50:59 +02:00
t0061-daemon-opts.sh test: fix the socat tests after the ubuntu 24.04 upgrade (#10683) 2025-01-29 21:11:41 +01:00
t0062-daemon-api.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0063-daemon-init.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0063-external.sh add test for sharness locking 2018-07-05 14:33:01 -07:00
t0064-api-file.sh chore: fix undiallable api and gateway files 2022-08-30 11:03:17 +02:00
t0065-active-requests.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0066-migration.sh feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
t0067-unix-api.sh daemon: support unix domain sockets for the API/gateway 2019-09-30 17:21:28 -07:00
t0070-user-config.sh feat: Provider.WorkerCount and stats reprovide (#10779) 2025-04-30 15:32:03 +02:00
t0080-repo.sh test: fix "invert" commands in sharness tests (#9652) 2025-06-09 15:50:59 +02:00
t0081-repo-pinning.sh core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0082-repo-gc-auto.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0084-repo-read-rehash.sh Sharness: fix t0084-repo-read-rehash for raw multihashes 2021-12-02 09:46:23 -05:00
t0086-repo-verify.sh test: verifyWorkerRun and helptext (#11063) 2025-11-17 18:51:33 +01:00
t0087-repo-robust-gc.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0088-repo-stat-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0090-get.sh core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0095-refs.sh propagate test_launch_ipfs_daemon_without_network name 2021-07-08 16:53:58 -03:00
t0101-iptb-name.sh Fix typos (#8548) 2021-11-17 21:16:06 +01:00
t0109-gateway-web-_redirects.sh feat!: dag import - don't pin roots by default (#9926) 2023-06-14 20:45:34 +00:00
t0112-gateway-cors.sh core/corehttp!: remove /api/v0 from gateway port 2024-03-05 08:21:13 +00:00
t0114-gateway-subdomains.sh feat(ci): reusable spellcheck from unified CI (#10873) 2025-08-14 00:35:35 +00:00
t0115-gateway-dir-listing.sh fix/gateway: escape directory redirect url (#10649) 2025-01-03 16:37:18 -08:00
t0116-gateway-cache.sh chore: restore exec perms for t0116-gateway-cache.sh and fixtures (#10085) 2023-08-18 09:34:42 +02:00
t0119-prometheus.sh refactor: make datastore metrics opt-in (#10788) 2025-04-30 22:01:24 +02:00
t0120-bootstrap.sh feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
t0121-bootstrap-iptb.sh feat: Add CI for Spell Checking (#10637) 2025-01-30 17:50:51 +01:00
t0131-multinode-client-routing.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0140-swarm.sh test: fix "invert" commands in sharness tests (#9652) 2025-06-09 15:50:59 +02:00
t0141-addfilter.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0142-testfilter.sh chore: upgrade go-libp2p-kad-dht (#10378) 2024-04-04 12:56:19 +00:00
t0150-clisuggest.sh chore: bump to go-ipfs-cmds @ v0.11 2024-04-17 07:47:39 +02:00
t0151-sysdiag.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0152-profile.sh feat: port collect-profiles.sh to 'ipfs diag profile' (#8786) 2022-04-12 11:58:03 -04:00
t0160-resolve.sh refactor: namesys cleanup, gateway /ipns/ ttl (#10115) 2023-10-18 10:23:50 +02:00
t0165-keystore.sh Revert "feat: adds secp256k1 keypair type to key gen command, adds test cases" 2023-06-12 15:44:12 +02:00
t0180-p2p.sh sharness: switch p2p dnsaddr that was supposed to have only a single address in it to use a specific example 2020-08-24 19:11:01 -04:00
t0181-private-network.sh feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
t0182-circuit-relay.sh feat: Add CI for Spell Checking (#10637) 2025-01-30 17:50:51 +01:00
t0183-namesys-pubsub.sh feat: enabling pubsub and ipns-pubsub via config flags (#8510) 2021-11-30 11:00:11 -08:00
t0184-http-proxy-over-p2p.sh chore: upgrade go-libp2p-kad-dht (#10378) 2024-04-04 12:56:19 +00:00
t0185-autonat.sh feat: add autonat config options 2020-04-14 20:54:58 -07:00
t0190-quic-ping.sh chore: update boxo, go-libp2p, and internalize mplex (#10095) 2023-08-24 06:11:02 +00:00
t0191-webtransport-ping.sh fix: replace quic to quic-v1 for webtransport sharness 2022-12-12 03:47:17 +01:00
t0195-noise.sh chore: update go-libp2p to v0.24.1 2022-12-12 03:47:17 +01:00
t0220-bitswap.sh Update to boxo with refactored providerQueryManager. (#10595) 2024-11-26 03:34:06 -08:00
t0230-channel-streaming-http-content-type.sh chore: upgrade OpenTelemetry dependencies (#9736) 2023-04-05 11:44:14 +00:00
t0231-channel-streaming.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0235-cli-request.sh fix(cli): preserve hostname specified with --api in http request headers (#10497) 2024-08-28 10:03:26 -07:00
t0236-cli-api-dns-resolve.sh fix: use %-encoded headers in most compatible way 2023-08-22 15:43:01 +02:00
t0240-republisher.sh fix(test): stabilize flaky provider tests 2023-01-02 16:59:05 +01:00
t0250-files-api.sh feat(config): add Import.* for CID Profiles from IPIP-499 (#11148) 2026-02-04 22:03:15 +01:00
t0251-files-flushing.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0252-files-gc.sh core/commands!: remove deprecated object APIs (#10375) 2024-03-22 09:32:30 +01:00
t0260-sharding.sh feat(config): ipfs add and Import options for controling UnixFS DAG Width (#10774) 2025-04-15 22:56:38 +02:00
t0270-filestore.sh feat(fuse): Expose MFS as FUSE mount point (#10781) 2025-05-06 21:55:53 +02:00
t0271-filestore-utils.sh Ivan386/filestore fix (#7474) 2025-06-04 14:04:20 -07:00
t0272-urlstore.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0275-cid-security.sh fix: enforce identity CID size limits (#10949) 2025-09-09 20:22:21 +02:00
t0276-cidv0v1.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0280-plugin-dag-jose.sh feat: relay v2 discovery (go-libp2p v0.19.0) (#8868) 2022-04-28 17:13:15 +02:00
t0280-plugin-fx.sh feat: add fx options plugin 2022-08-12 17:04:29 -04:00
t0280-plugin-git.sh change names of ipfs dag put flags to make changes clearer 2021-09-27 14:39:03 -04:00
t0280-plugin-peerlog.sh ci: preload peerlog plugin, disable by default 2021-08-25 19:02:51 +00:00
t0280-plugin.sh feat: nice errors when failing to load plugins 2020-08-08 22:53:18 -04:00
t0290-cid.sh fix(cmd): exit 1 on error (#10903) 2025-08-08 17:25:05 -07:00
t0295-multibase.sh chore: update go-multibase 🚀 2022-07-07 23:29:47 +02:00
t0320-pubsub.sh ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
t0321-pubsub-gossipsub.sh fix: multibase in pubsub http rpc (#8183) 2021-11-29 23:06:54 +01:00
t0322-pubsub-http-rpc.sh fix: multibase in pubsub http rpc (#8183) 2021-11-29 23:06:54 +01:00
t0400-api-no-gateway.sh cmds/dag/import: pin roots by default (#9966) 2023-06-15 16:41:59 +02:00
t0401-api-browser-security.sh fix: allow ipfs-companion browser extension to access RPC API (#8690) 2022-03-17 00:07:52 +01:00
t0410-api-add.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0500-issues-and-regressions-offline.sh Replace go-random with random-data from go-test package (#10731) 2025-02-24 13:42:39 -08:00
t0600-issues-and-regressions-online.sh chore: bump to boxo master 2023-06-29 13:05:08 +02:00
t0800-blake3.sh feat: add blake3 support 2022-08-12 16:45:42 +00:00
x0601-pin-fail-test.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00

ipfs whole tests using the sharness framework

Running all the tests

Just use make in this directory to run all the tests. Run with TEST_VERBOSE=1 to get helpful verbose output.

TEST_VERBOSE=1 make

The usual ipfs env flags also apply:

# the output will make your eyes bleed
GOLOG_LOG_LEVEL=debug TEST_VERBOSE=1 make

To make the tests abort as soon as an error occurs, use the TEST_IMMEDIATE env variable:

# this will abort as soon the first error occurs
TEST_IMMEDIATE=1 make

Running just one test

You can run only one test script by launching it like a regular shell script:

$ ./t0010-basic-commands.sh

Debugging one test

You can use the -v option to make it verbose and the -i option to make it stop as soon as one test fails. For example:

$ ./t0010-basic-commands.sh -v -i

Sharness

When running sharness tests from main Makefile or when test_sharness_deps target is run dependencies for sharness will be downloaded from its GitHub repo and installed in a "lib/sharness" directory.

Please do not change anything in the "lib/sharness" directory.

If you really need some changes in sharness, please fork it from its canonical repo and send pull requests there.

Writing Tests

Please have a look at existing tests and try to follow their example.

When possible and not too inefficient, that means most of the time, an ipfs command should not be on the left side of a pipe, because if the ipfs command fails (exit non zero), the pipe will mask this failure. For example after false | true, echo $? prints 0 (despite false failing).

It should be possible to put most of the code inside test_expect_success, or sometimes test_expect_failure, blocks, and to chain all the commands inside those blocks with &&, or || for diagnostic commands.

Diagnostics

Make your test case output helpful for when running sharness verbosely. This means cating certain files, or running diagnostic commands. For example:

test_expect_success ".ipfs/ has been created" '
  test -d ".ipfs" &&
  test -f ".ipfs/config" &&
  test -d ".ipfs/datastore" &&
  test -d ".ipfs/blocks" ||
  test_fsh ls -al .ipfs
'

The || ... is a diagnostic run when the preceding command fails. test_fsh is a shell function that echoes the args, runs the cmd, and then also fails, making sure the test case fails. (wouldn't want the diagnostic accidentally returning true and making it seem like the test case succeeded!).

Testing commands on daemon or mounted

Use the provided functions in lib/test-lib.sh to run the daemon or mount:

To init, run daemon, and mount in one go:

test_launch_ipfs_daemon_and_mount

test_expect_success "'ipfs add --help' succeeds" '
  ipfs add --help >actual
'

# other tests here...

# don't forget to kill the daemon!!
test_kill_ipfs_daemon

To init, run daemon, and then mount separately:

test_init_ipfs

# tests inited but not running here

test_launch_ipfs_daemon

# tests running but not mounted here

test_mount_ipfs

# tests mounted here

# don't forget to kill the daemon!!
test_kill_ipfs_daemon