Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
e028e524
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e028e524
编写于
5月 08, 2018
作者:
D
Daniel Larimer
提交者:
GitHub
5月 08, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2839 from taokayan/slim_forkdb
create unitest to reproduce issue 2835
上级
2acec365
e85e6ae2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
0 deletion
+63
-0
unittests/forked_tests.cpp
unittests/forked_tests.cpp
+63
-0
未找到文件。
unittests/forked_tests.cpp
浏览文件 @
e028e524
...
...
@@ -194,4 +194,67 @@ BOOST_AUTO_TEST_CASE( forking ) try {
});
}
FC_LOG_AND_RETHROW
()
BOOST_AUTO_TEST_CASE
(
prune_remove_branch
)
try
{
tester
c
;
c
.
produce_blocks
(
10
);
auto
r
=
c
.
create_accounts
(
{
N
(
dan
),
N
(
sam
),
N
(
pam
),
N
(
scott
)}
);
auto
res
=
c
.
set_producers
(
{
N
(
dan
),
N
(
sam
),
N
(
pam
),
N
(
scott
)}
);
wlog
(
"set producer schedule to [dan,sam,pam,scott]"
);
c
.
produce_blocks
(
50
);
tester
c2
;
wlog
(
"push c1 blocks to c2"
);
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
c2
.
push_block
(
fb
);
}
// fork happen after block 61
BOOST_REQUIRE_EQUAL
(
61
,
c
.
control
->
head_block_num
());
BOOST_REQUIRE_EQUAL
(
61
,
c2
.
control
->
head_block_num
());
int
fork_num
=
c
.
control
->
head_block_num
();
auto
nextproducer
=
[](
tester
&
c
,
int
skip_interval
)
->
account_name
{
auto
head_time
=
c
.
control
->
head_block_time
();
auto
next_time
=
head_time
+
fc
::
milliseconds
(
config
::
block_interval_ms
*
skip_interval
);
return
c
.
control
->
head_block_state
()
->
get_scheduled_producer
(
next_time
).
producer_name
;
};
// fork c: 2 producers: dan, sam
// fork c2: 1 producer: scott
int
skip1
=
1
,
skip2
=
1
;
for
(
int
i
=
0
;
i
<
50
;
++
i
)
{
account_name
next1
=
nextproducer
(
c
,
skip1
);
if
(
next1
==
N
(
dan
)
||
next1
==
N
(
sam
))
{
c
.
produce_block
(
fc
::
milliseconds
(
config
::
block_interval_ms
*
skip1
));
skip1
=
1
;
}
else
++
skip1
;
account_name
next2
=
nextproducer
(
c2
,
skip2
);
if
(
next2
==
N
(
scott
))
{
c2
.
produce_block
(
fc
::
milliseconds
(
config
::
block_interval_ms
*
skip2
));
skip2
=
1
;
}
else
++
skip2
;
}
BOOST_REQUIRE_EQUAL
(
87
,
c
.
control
->
head_block_num
());
BOOST_REQUIRE_EQUAL
(
73
,
c2
.
control
->
head_block_num
());
// push fork from c2 => c
int
p
=
fork_num
;
while
(
p
<
c2
.
control
->
head_block_num
())
{
auto
fb
=
c2
.
control
->
fetch_block_by_number
(
++
p
);
c
.
push_block
(
fb
);
}
// c's main chain should not be changed
// FIXME: uncomment it to reproduce the issue in #2835
//BOOST_REQUIRE_EQUAL(87, c.control->head_block_num());
}
FC_LOG_AND_RETHROW
()
BOOST_AUTO_TEST_CASE
(
confirmation
)
try
{
}
FC_LOG_AND_RETHROW
()
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录