1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 19:24:14 +08:00

namesys: add test for publish with cache size 0

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera
2016-12-15 22:05:23 +01:00
parent 0864c8e20e
commit c1d5a60b66

View File

@ -7,6 +7,11 @@ import (
context "context"
path "github.com/ipfs/go-ipfs/path"
offroute "github.com/ipfs/go-ipfs/routing/offline"
"github.com/ipfs/go-ipfs/unixfs"
ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
)
type mockResolver struct {
@ -69,3 +74,19 @@ func TestNamesysResolution(t *testing.T) {
testResolution(t, r, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", 2, "/ipns/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", ErrResolveRecursion)
testResolution(t, r, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", 3, "/ipns/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy", ErrResolveRecursion)
}
func TestPublishWithCache0(t *testing.T) {
dst := ds.NewMapDatastore()
priv, _, err := ci.GenerateKeyPair(ci.RSA, 1024)
if err != nil {
t.Fatal(err)
}
routing := offroute.NewOfflineRouter(dst, priv)
nsys := NewNameSystem(routing, dst, 0)
p, err := path.ParsePath(unixfs.EmptyDirNode().Cid().String())
if err != nil {
t.Fatal(err)
}
nsys.Publish(context.Background(), priv, p)
}