@cryptotaxi247 / kubo / commits / c1d5a60b6

namesys: add test for publish with cache size 0

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Dec 15, 2016 at 22:05 UTC c1d5a60b6665ca4dc2cee623b0bd5955e76e5ae6
1 file changed +21
namesys/namesys_test.go
+21
@@ -7,6 +7,11 @@ import (
7 context "context"
8
9 path "github.com/ipfs/go-ipfs/path"
10 + offroute "github.com/ipfs/go-ipfs/routing/offline"
11 + "github.com/ipfs/go-ipfs/unixfs"
12 +
13 + ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
14 + ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
15 )
16
17 type mockResolver struct {
@@ -69,3 +74,19 @@ func TestNamesysResolution(t *testing.T) {
74 testResolution(t, r, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", 2, "/ipns/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", ErrResolveRecursion)
75 testResolution(t, r, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", 3, "/ipns/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy", ErrResolveRecursion)
76 }
77 +
78 +func TestPublishWithCache0(t *testing.T) {
79 + dst := ds.NewMapDatastore()
80 + priv, _, err := ci.GenerateKeyPair(ci.RSA, 1024)
81 + if err != nil {
82 + t.Fatal(err)
83 + }
84 + routing := offroute.NewOfflineRouter(dst, priv)
85 +
86 + nsys := NewNameSystem(routing, dst, 0)
87 + p, err := path.ParsePath(unixfs.EmptyDirNode().Cid().String())
88 + if err != nil {
89 + t.Fatal(err)
90 + }
91 + nsys.Publish(context.Background(), priv, p)
92 +}