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
ce1f8da0
Commit
ce1f8da0
authored
Oct 18, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add another ipns test to simulate coalesced writes
parent
a7bca102
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 @
ce1f8da0
...
@@ -187,6 +187,47 @@ func TestMultiWrite(t *testing.T) {
...
@@ -187,6 +187,47 @@ func TestMultiWrite(t *testing.T) {
}
}
}
}
func
TestMultiWriteCoal
(
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
+
1
],
0
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
i
+
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
{
func
arrComp
(
a
,
b
[]
byte
)
error
{
if
len
(
a
)
!=
len
(
b
)
{
if
len
(
a
)
!=
len
(
b
)
{
return
fmt
.
Errorf
(
"Arrays differ in length. %d != %d"
,
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