Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-pinner
Commits
1b4817ea
Commit
1b4817ea
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for pinning semantics
parent
ae27f8ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
pin_test.go
pin_test.go
+38
-0
No files found.
pin_test.go
View file @
1b4817ea
...
...
@@ -152,3 +152,41 @@ func TestPinnerBasic(t *testing.T) {
t
.
Fatal
(
"could not find recursively pinned node"
)
}
}
func
TestDuplicateSemantics
(
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
)
// TODO does pinner need to share datastore with blockservice?
p
:=
NewPinner
(
dstore
,
dserv
)
a
,
_
:=
randNode
()
_
,
err
=
dserv
.
Add
(
a
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// pin is recursively
err
=
p
.
Pin
(
a
,
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// pinning directly should fail
err
=
p
.
Pin
(
a
,
false
)
if
err
==
nil
{
t
.
Fatal
(
"expected direct pin to fail"
)
}
// pinning recursively again should succeed
err
=
p
.
Pin
(
a
,
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment