Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
14eceee3
提交
14eceee3
authored
1月 28, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
epictest: fix three-legged-cat
http://gateway.ipfs.io/ipfs/QmfUFkQuqjfQzLNhMLwiibiAxnAaZEJAbYkey9orXJ4aQe/3lcat.jpg
上级
958cc616
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
6 行删除
+46
-6
bootstrap.go
core/bootstrap.go
+7
-0
three_legged_cat_test.go
test/epictest/three_legged_cat_test.go
+39
-6
没有找到文件。
core/bootstrap.go
浏览文件 @
14eceee3
...
...
@@ -85,6 +85,9 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
return
ioutil
.
NopCloser
(
nil
),
nil
}
// make a signal to wait for one bootstrap round to complete.
doneWithRound
:=
make
(
chan
struct
{})
// the periodic bootstrap function -- the connection supervisor
periodic
:=
func
(
worker
goprocess
.
Process
)
{
ctx
:=
procctx
.
WithProcessClosing
(
context
.
Background
(),
worker
)
...
...
@@ -94,6 +97,8 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
log
.
Event
(
ctx
,
"bootstrapError"
,
n
.
Identity
,
lgbl
.
Error
(
err
))
log
.
Debugf
(
"%s bootstrap error: %s"
,
n
.
Identity
,
err
)
}
<-
doneWithRound
}
// kick off the node's periodic bootstrapping
...
...
@@ -109,6 +114,8 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
// add dht bootstrap proc as a child, so it is closed automatically when we are.
proc
.
AddChild
(
dbproc
)
doneWithRound
<-
struct
{}{}
close
(
doneWithRound
)
// it no longer blocks periodic
return
proc
,
nil
}
...
...
test/epictest/three_legged_cat_test.go
浏览文件 @
14eceee3
...
...
@@ -5,6 +5,7 @@ import (
"io"
"math"
"testing"
"time"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
core
"github.com/jbenet/go-ipfs/core"
...
...
@@ -16,7 +17,7 @@ import (
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
TestThreeLeggedCat
(
t
*
testing
.
T
)
{
func
TestThreeLeggedCat
1KBInstantaneous
(
t
*
testing
.
T
)
{
conf
:=
testutil
.
LatencyConfig
{
NetworkLatency
:
0
,
RoutingLatency
:
0
,
...
...
@@ -27,6 +28,38 @@ func TestThreeLeggedCat(t *testing.T) {
}
}
func
TestThreeLeggedCatDegenerateSlowBlockstore
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
testutil
.
LatencyConfig
{
BlockstoreLatency
:
50
*
time
.
Millisecond
}
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestThreeLeggedCatDegenerateSlowNetwork
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
testutil
.
LatencyConfig
{
NetworkLatency
:
400
*
time
.
Millisecond
}
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestThreeLeggedCatDegenerateSlowRouting
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
testutil
.
LatencyConfig
{
RoutingLatency
:
400
*
time
.
Millisecond
}
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestThreeLeggedCat100MBMacbookCoastToCoast
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
testutil
.
LatencyConfig
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
RunThreeLeggedCat
(
data
[]
byte
,
conf
testutil
.
LatencyConfig
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
...
...
@@ -47,6 +80,11 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
if
len
(
peers
)
<
numPeers
{
return
errors
.
New
(
"test initialization error"
)
}
bootstrap
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
2
],
mn
.
Host
(
peers
[
2
]),
conf
)))
if
err
!=
nil
{
return
err
}
defer
bootstrap
.
Close
()
adder
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
0
],
mn
.
Host
(
peers
[
0
]),
conf
)))
if
err
!=
nil
{
return
err
...
...
@@ -57,11 +95,6 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
return
err
}
defer
catter
.
Close
()
bootstrap
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
ConfigOption
(
MocknetTestRepo
(
peers
[
2
],
mn
.
Host
(
peers
[
2
]),
conf
)))
if
err
!=
nil
{
return
err
}
defer
bootstrap
.
Close
()
bis
:=
bootstrap
.
Peerstore
.
PeerInfo
(
bootstrap
.
PeerHost
.
ID
())
bcfg
:=
core
.
BootstrapConfigWithPeers
([]
peer
.
PeerInfo
{
bis
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论