Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
881ec275
提交
881ec275
authored
2月 04, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2297 from ipfs/t0240-improvements
t0240 improvements
上级
9300af5c
91322346
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
57 行增加
和
68 行删除
+57
-68
iptb-lib.sh
test/sharness/lib/iptb-lib.sh
+2
-2
t0240-republisher.sh
test/sharness/t0240-republisher.sh
+55
-66
没有找到文件。
test/sharness/lib/iptb-lib.sh
浏览文件 @
881ec275
...
...
@@ -19,7 +19,7 @@ check_has_connection() {
startup_cluster
()
{
num_nodes
=
"
$1
"
bound
=
$(
expr
$num_nodes
- 1
)
bound
=
$(
expr
"
$num_nodes
"
- 1
)
test_expect_success
"start up nodes"
'
iptb start
...
...
@@ -29,7 +29,7 @@ startup_cluster() {
iptb connect [1-$bound] 0
'
for
i
in
$(
test_seq
1
$bound
)
for
i
in
$(
test_seq
0
"
$bound
"
)
do
test_expect_success
"node
$i
is connected"
'
check_has_connection "$i" ||
...
...
test/sharness/t0240-republisher.sh
浏览文件 @
881ec275
...
...
@@ -11,34 +11,22 @@ test_description="Test ipfs repo operations"
export
DEBUG
=
true
setup_iptb
()
{
num_nodes
=
"
$1
"
bound
=
$(
expr
"
$num_nodes
"
- 1
)
test_expect_success
"iptb init"
'
iptb init -n
4
--bootstrap none --port 0
iptb init -n
$num_nodes
--bootstrap none --port 0
'
test_expect_success
"set configs up"
'
for i in $(test_seq 0 3)
do
ipfsi
$i config Ipns.RepublishPeriod 20s
ipfsi
$i
config --json Ipns.ResolveCacheSize 0
done
'
for
i
in
$(
test_seq 0
"
$bound
"
)
do
test_expect_success
"set configs up for node
$i
"
'
ipfsi
"$i" config Ipns.RepublishPeriod 20s &&
ipfsi
"$i"
config --json Ipns.ResolveCacheSize 0
'
done
test_expect_success
"start up nodes"
'
iptb start
'
test_expect_success
"connect nodes"
'
iptb connect 0 1 &&
iptb connect 0 2 &&
iptb connect 0 3
'
test_expect_success
"nodes have connections"
'
ipfsi 0 swarm peers | grep ipfs &&
ipfsi 1 swarm peers | grep ipfs &&
ipfsi 2 swarm peers | grep ipfs &&
ipfsi 3 swarm peers | grep ipfs
'
startup_cluster
"
$num_nodes
"
}
teardown_iptb
()
{
...
...
@@ -48,62 +36,63 @@ teardown_iptb() {
}
verify_can_resolve
()
{
node
=
$1
name
=
$2
expected
=
$3
test_expect_success
"node can resolve entry"
'
ipfsi $node name resolve $name > resolve
'
test_expect_success
"output looks right"
'
printf "/ipfs/$expected\n" > expected &&
test_cmp expected resolve
'
num_nodes
=
"
$1
"
bound
=
$(
expr
"
$num_nodes
"
- 1
)
name
=
"
$2
"
expected
=
"
$3
"
msg
=
"
$4
"
for
node
in
$(
test_seq 0
"
$bound
"
)
do
test_expect_success
"
$msg
: node
$node
can resolve entry"
'
ipfsi "$node" name resolve "$name" > resolve
'
test_expect_success
"
$msg
: output for node
$node
looks right"
'
printf "/ipfs/$expected\n" > expected &&
test_cmp expected resolve
'
done
}
verify_cannot_resolve
()
{
node
=
$1
name
=
$2
echo
"verifying resolution fails on node
$node
"
test_expect_success
"node cannot resolve entry"
'
# TODO: this should work without the timeout option
# but it currently hangs for some reason every so often
test_expect_code 1 ipfsi $node name resolve --timeout=300ms $name
'
num_nodes
=
"
$1
"
bound
=
$(
expr
"
$num_nodes
"
- 1
)
name
=
"
$2
"
msg
=
"
$3
"
for
node
in
$(
test_seq 0
"
$bound
"
)
do
test_expect_success
"
$msg
: resolution fails on node
$node
"
'
# TODO: this should work without the timeout option
# but it currently hangs for some reason every so often
test_expect_code 1 ipfsi "$node" name resolve --timeout=300ms "$name"
'
done
}
setup_iptb
num_test_nodes
=
4
setup_iptb
"
$num_test_nodes
"
test_expect_success
"publish succeeds"
'
HASH=$(echo "foobar" | ipfsi 1 add -q) &&
ipfsi 1 name publish -t 5s $HASH
'
test_expect_success
"other nodes can resolve"
'
id=$(ipfsi 1 id -f "<id>") &&
verify_can_resolve 0 $id $HASH &&
verify_can_resolve 1 $id $HASH &&
verify_can_resolve 2 $id $HASH &&
verify_can_resolve 3 $id $HASH
test_expect_success
"get id succeeds"
'
id=$(ipfsi 1 id -f "<id>")
'
test_expect_success
"after five seconds, records are invalid"
'
go-sleep 5s &&
verify_cannot_resolve 0 $id &&
verify_cannot_resolve 1 $id &&
verify_cannot_resolve 2 $id &&
verify_cannot_resolve 3 $id
'
verify_can_resolve
"
$num_test_nodes
"
"
$id
"
"
$HASH
"
"just after publishing"
test_expect_success
"republisher fires after twenty seconds"
'
go-sleep 15s &&
verify_can_resolve 0 $id $HASH &&
verify_can_resolve 1 $id $HASH &&
verify_can_resolve 2 $id $HASH &&
verify_can_resolve 3 $id $HASH
'
go-sleep 5s
verify_cannot_resolve
"
$num_test_nodes
"
"
$id
"
"after five seconds, records are invalid"
go-sleep 15s
verify_can_resolve
"
$num_test_nodes
"
"
$id
"
"
$HASH
"
"republisher fires after twenty seconds"
teardown_iptb
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论