kubo/test/cli/dht_opt_prov_test.go
guillaumemichel 10263645ef
bump kad-dht
2025-10-24 09:35:18 +02:00

32 lines
777 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)
waitUntilProvidesComplete(t, nodes[0])
res := nodes[1].IPFS("routing", "findprovs", "--num-providers=1", hash)
assert.Equal(t, nodes[0].PeerID().String(), res.Stdout.Trimmed())
})
}