Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
19de3041
提交
19de3041
authored
11月 23, 2014
作者:
Brian Tiger Chow
提交者:
Jeromy
12月 05, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(bitswap) build-breaking compilation errors
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
上级
aac3c6ab
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
30 行增加
和
30 行删除
+30
-30
bitswap_test.go
exchange/bitswap/bitswap_test.go
+30
-30
没有找到文件。
exchange/bitswap/bitswap_test.go
浏览文件 @
19de3041
...
...
@@ -25,8 +25,8 @@ func TestClose(t *testing.T) {
block
:=
bgen
.
Next
()
bitswap
:=
sesgen
.
Next
()
bitswap
.
e
xchange
.
Close
()
bitswap
.
e
xchange
.
GetBlock
(
context
.
Background
(),
block
.
Key
())
bitswap
.
E
xchange
.
Close
()
bitswap
.
E
xchange
.
GetBlock
(
context
.
Background
(),
block
.
Key
())
}
func
TestGetBlockTimeout
(
t
*
testing
.
T
)
{
...
...
@@ -39,7 +39,7 @@ func TestGetBlockTimeout(t *testing.T) {
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Nanosecond
)
block
:=
blocks
.
NewBlock
([]
byte
(
"block"
))
_
,
err
:=
self
.
e
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
_
,
err
:=
self
.
E
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
if
err
!=
context
.
DeadlineExceeded
{
t
.
Fatal
(
"Expected DeadlineExceeded error"
)
...
...
@@ -58,7 +58,7 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) {
solo
:=
g
.
Next
()
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Nanosecond
)
_
,
err
:=
solo
.
e
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
_
,
err
:=
solo
.
E
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
if
err
!=
context
.
DeadlineExceeded
{
t
.
Fatal
(
"Expected DeadlineExceeded error"
)
...
...
@@ -76,17 +76,17 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
hasBlock
:=
g
.
Next
()
if
err
:=
hasBlock
.
b
lockstore
.
Put
(
block
);
err
!=
nil
{
if
err
:=
hasBlock
.
B
lockstore
.
Put
(
block
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
hasBlock
.
e
xchange
.
HasBlock
(
context
.
Background
(),
block
);
err
!=
nil
{
if
err
:=
hasBlock
.
E
xchange
.
HasBlock
(
context
.
Background
(),
block
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
wantsBlock
:=
g
.
Next
()
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
received
,
err
:=
wantsBlock
.
e
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
received
,
err
:=
wantsBlock
.
E
xchange
.
GetBlock
(
ctx
,
block
.
Key
())
if
err
!=
nil
{
t
.
Log
(
err
)
t
.
Fatal
(
"Expected to succeed"
)
...
...
@@ -135,9 +135,9 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
first
:=
instances
[
0
]
for
_
,
b
:=
range
blocks
{
first
.
b
lockstore
.
Put
(
b
)
first
.
e
xchange
.
HasBlock
(
context
.
Background
(),
b
)
rs
.
Announce
(
first
.
p
eer
,
b
.
Key
())
first
.
B
lockstore
.
Put
(
b
)
first
.
E
xchange
.
HasBlock
(
context
.
Background
(),
b
)
rs
.
Announce
(
first
.
P
eer
,
b
.
Key
())
}
t
.
Log
(
"Distribute!"
)
...
...
@@ -158,7 +158,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
for
_
,
inst
:=
range
instances
{
for
_
,
b
:=
range
blocks
{
if
_
,
err
:=
inst
.
b
lockstore
.
Get
(
b
.
Key
());
err
!=
nil
{
if
_
,
err
:=
inst
.
B
lockstore
.
Get
(
b
.
Key
());
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
...
...
@@ -166,8 +166,8 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
}
func
getOrFail
(
bitswap
Instance
,
b
*
blocks
.
Block
,
t
*
testing
.
T
,
wg
*
sync
.
WaitGroup
)
{
if
_
,
err
:=
bitswap
.
b
lockstore
.
Get
(
b
.
Key
());
err
!=
nil
{
_
,
err
:=
bitswap
.
e
xchange
.
GetBlock
(
context
.
Background
(),
b
.
Key
())
if
_
,
err
:=
bitswap
.
B
lockstore
.
Get
(
b
.
Key
());
err
!=
nil
{
_
,
err
:=
bitswap
.
E
xchange
.
GetBlock
(
context
.
Background
(),
b
.
Key
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -190,50 +190,50 @@ func TestSendToWantingPeer(t *testing.T) {
w
:=
sg
.
Next
()
o
:=
sg
.
Next
()
t
.
Logf
(
"Session %v
\n
"
,
me
.
p
eer
)
t
.
Logf
(
"Session %v
\n
"
,
w
.
p
eer
)
t
.
Logf
(
"Session %v
\n
"
,
o
.
p
eer
)
t
.
Logf
(
"Session %v
\n
"
,
me
.
P
eer
)
t
.
Logf
(
"Session %v
\n
"
,
w
.
P
eer
)
t
.
Logf
(
"Session %v
\n
"
,
o
.
P
eer
)
alpha
:=
bg
.
Next
()
const
timeout
=
100
*
time
.
Millisecond
// FIXME don't depend on time
t
.
Logf
(
"Peer %v attempts to get %v. NB: not available
\n
"
,
w
.
p
eer
,
alpha
.
Key
())
t
.
Logf
(
"Peer %v attempts to get %v. NB: not available
\n
"
,
w
.
P
eer
,
alpha
.
Key
())
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
_
,
err
:=
w
.
e
xchange
.
GetBlock
(
ctx
,
alpha
.
Key
())
_
,
err
:=
w
.
E
xchange
.
GetBlock
(
ctx
,
alpha
.
Key
())
if
err
==
nil
{
t
.
Fatalf
(
"Expected %v to NOT be available"
,
alpha
.
Key
())
}
beta
:=
bg
.
Next
()
t
.
Logf
(
"Peer %v announes availability of %v
\n
"
,
w
.
p
eer
,
beta
.
Key
())
t
.
Logf
(
"Peer %v announes availability of %v
\n
"
,
w
.
P
eer
,
beta
.
Key
())
ctx
,
_
=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
if
err
:=
w
.
b
lockstore
.
Put
(
beta
);
err
!=
nil
{
if
err
:=
w
.
B
lockstore
.
Put
(
beta
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
w
.
e
xchange
.
HasBlock
(
ctx
,
beta
)
w
.
E
xchange
.
HasBlock
(
ctx
,
beta
)
t
.
Logf
(
"%v gets %v from %v and discovers it wants %v
\n
"
,
me
.
peer
,
beta
.
Key
(),
w
.
p
eer
,
alpha
.
Key
())
t
.
Logf
(
"%v gets %v from %v and discovers it wants %v
\n
"
,
me
.
Peer
,
beta
.
Key
(),
w
.
P
eer
,
alpha
.
Key
())
ctx
,
_
=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
if
_
,
err
:=
me
.
e
xchange
.
GetBlock
(
ctx
,
beta
.
Key
());
err
!=
nil
{
if
_
,
err
:=
me
.
E
xchange
.
GetBlock
(
ctx
,
beta
.
Key
());
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Logf
(
"%v announces availability of %v
\n
"
,
o
.
p
eer
,
alpha
.
Key
())
t
.
Logf
(
"%v announces availability of %v
\n
"
,
o
.
P
eer
,
alpha
.
Key
())
ctx
,
_
=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
if
err
:=
o
.
b
lockstore
.
Put
(
alpha
);
err
!=
nil
{
if
err
:=
o
.
B
lockstore
.
Put
(
alpha
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
o
.
e
xchange
.
HasBlock
(
ctx
,
alpha
)
o
.
E
xchange
.
HasBlock
(
ctx
,
alpha
)
t
.
Logf
(
"%v requests %v
\n
"
,
me
.
p
eer
,
alpha
.
Key
())
t
.
Logf
(
"%v requests %v
\n
"
,
me
.
P
eer
,
alpha
.
Key
())
ctx
,
_
=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
if
_
,
err
:=
me
.
e
xchange
.
GetBlock
(
ctx
,
alpha
.
Key
());
err
!=
nil
{
if
_
,
err
:=
me
.
E
xchange
.
GetBlock
(
ctx
,
alpha
.
Key
());
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Logf
(
"%v should now have %v
\n
"
,
w
.
p
eer
,
alpha
.
Key
())
block
,
err
:=
w
.
b
lockstore
.
Get
(
alpha
.
Key
())
t
.
Logf
(
"%v should now have %v
\n
"
,
w
.
P
eer
,
alpha
.
Key
())
block
,
err
:=
w
.
B
lockstore
.
Get
(
alpha
.
Key
())
if
err
!=
nil
{
t
.
Fatal
(
"Should not have received an error"
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论