-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This routing type is the same as "auto" but it creates the DHT in "client" mode and hence does not start a DHT server.
- Loading branch information
Showing
6 changed files
with
82 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/ipfs/kubo/test/cli/harness" | ||
"github.com/ipfs/kubo/test/cli/testutils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDHTAutoclient(t *testing.T) { | ||
t.Parallel() | ||
nodes := harness.NewT(t).NewNodes(10).Init() | ||
harness.Nodes(nodes[8:]).ForEachPar(func(node *harness.Node) { | ||
node.IPFS("config", "Routing.Type", "autoclient") | ||
}) | ||
nodes.StartDaemons().Connect() | ||
|
||
t.Run("file added on node in client mode is retrievable from node in client mode", func(t *testing.T) { | ||
t.Parallel() | ||
randomBytes := testutils.RandomBytes(1000) | ||
hash := nodes[8].IPFSAdd(bytes.NewReader(randomBytes)) | ||
|
||
res := nodes[9].IPFS("cat", hash) | ||
assert.Equal(t, randomBytes, []byte(res.Stdout.Trimmed())) | ||
}) | ||
|
||
t.Run("file added on node in server mode is retrievable from all nodes", func(t *testing.T) { | ||
t.Parallel() | ||
randomBytes := testutils.RandomBytes(1000) | ||
hash := nodes[0].IPFSAdd(bytes.NewReader(randomBytes)) | ||
|
||
for i := 0; i < 10; i++ { | ||
res := nodes[i].IPFS("cat", hash) | ||
assert.Equal(t, randomBytes, []byte(res.Stdout.Trimmed())) | ||
} | ||
}) | ||
} |