mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Build / docker-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 / go-test (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
Replace test functionality that is dublicated in go-test/random
31 lines
736 B
Go
31 lines
736 B
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ipfs/go-test/random"
|
|
"github.com/ipfs/kubo/config"
|
|
"github.com/ipfs/kubo/test/cli/harness"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDHTOptimisticProvide(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("optimistic provide smoke test", func(t *testing.T) {
|
|
nodes := harness.NewT(t).NewNodes(2).Init()
|
|
|
|
nodes[0].UpdateConfig(func(cfg *config.Config) {
|
|
cfg.Experimental.OptimisticProvide = true
|
|
})
|
|
|
|
nodes.StartDaemons().Connect()
|
|
|
|
hash := nodes[0].IPFSAddStr(string(random.Bytes(100)))
|
|
nodes[0].IPFS("routing", "provide", hash)
|
|
|
|
res := nodes[1].IPFS("routing", "findprovs", "--num-providers=1", hash)
|
|
assert.Equal(t, nodes[0].PeerID().String(), res.Stdout.Trimmed())
|
|
})
|
|
}
|