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
Commits
38177b48
Commit
38177b48
authored
Oct 08, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add another test to try and reproduce data loss issue
parent
4d7b87df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
unixfs/io/dagmodifier_test.go
unixfs/io/dagmodifier_test.go
+41
-0
No files found.
unixfs/io/dagmodifier_test.go
View file @
38177b48
...
...
@@ -146,6 +146,47 @@ func TestDagModifierBasic(t *testing.T) {
}
}
func
TestMultiWrite
(
t
*
testing
.
T
)
{
dserv
:=
getMockDagServ
(
t
)
_
,
n
:=
getNode
(
t
,
dserv
,
0
)
dagmod
,
err
:=
NewDagModifier
(
n
,
dserv
,
&
chunk
.
SizeSplitter
{
512
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
data
:=
make
([]
byte
,
4000
)
u
.
NewFastRand
()
.
Read
(
data
)
for
i
:=
0
;
i
<
len
(
data
);
i
++
{
n
,
err
:=
dagmod
.
WriteAt
(
data
[
i
:
i
+
1
],
uint64
(
i
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
1
{
t
.
Fatal
(
"Somehow wrote the wrong number of bytes! (n != 1)"
)
}
}
nd
,
err
:=
dagmod
.
GetNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
read
,
err
:=
NewDagReader
(
nd
,
dserv
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
rbuf
,
err
:=
ioutil
.
ReadAll
(
read
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
rbuf
,
data
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
arrComp
(
a
,
b
[]
byte
)
error
{
if
len
(
a
)
!=
len
(
b
)
{
return
fmt
.
Errorf
(
"Arrays differ in length. %d != %d"
,
len
(
a
),
len
(
b
))
...
...
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