tests/cli: fix flapping tests (#10600)

The issue is that for dht providing to work correctly, at least two nodes must
have dht routing.

Before, dht providing in the test always failed, but the test succeeded when
the tested-CID was the one that the failure happened with (the first in the
list for ProvideMany).
This commit is contained in:
Hector Sanjuan 2024-11-26 19:19:07 +01:00 committed by GitHub
parent 37c5060742
commit fb58b0ae85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,9 +15,11 @@ func TestRoutingV1Proxy(t *testing.T) {
t.Parallel()
setupNodes := func(t *testing.T) harness.Nodes {
nodes := harness.NewT(t).NewNodes(2).Init()
nodes := harness.NewT(t).NewNodes(3).Init()
// Node 0 uses DHT and exposes the Routing API.
// Node 0 uses DHT and exposes the Routing API. For the DHT
// to actually work there will need to be another DHT-enabled
// node.
nodes[0].UpdateConfig(func(cfg *config.Config) {
cfg.Gateway.ExposeRoutingAPI = config.True
cfg.Discovery.MDNS.Enabled = false
@ -49,6 +51,15 @@ func TestRoutingV1Proxy(t *testing.T) {
})
nodes[1].StartDaemon()
// This is the second DHT node. Only used so that the DHT is
// operative.
nodes[2].UpdateConfig(func(cfg *config.Config) {
cfg.Gateway.ExposeRoutingAPI = config.True
cfg.Discovery.MDNS.Enabled = false
cfg.Routing.Type = config.NewOptionalString("dht")
})
nodes[2].StartDaemon()
// Connect them.
nodes.Connect()