mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 19:32:24 +08:00
pin: Do not accidentally delete indirect pins on Flush
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -192,6 +192,27 @@ func TestDuplicateSemantics(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlush(t *testing.T) {
|
||||
dstore := dssync.MutexWrap(ds.NewMapDatastore())
|
||||
bstore := blockstore.NewBlockstore(dstore)
|
||||
bserv, err := bs.New(bstore, offline.Exchange(bstore))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dserv := mdag.NewDAGService(bserv)
|
||||
p := NewPinner(dstore, dserv)
|
||||
_, k := randNode()
|
||||
|
||||
p.PinWithMode(k, Indirect)
|
||||
if err := p.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !p.IsPinned(k) {
|
||||
t.Fatal("expected key to still be pinned")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPinRecursiveFail(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dstore := dssync.MutexWrap(ds.NewMapDatastore())
|
||||
|
Reference in New Issue
Block a user