Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
861cd06c
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,发现更多精彩内容 >>
提交
861cd06c
编写于
4月 19, 2017
作者:
N
Nathan Hourt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve #10: Tests Fixed
All tests now pass again. :)
上级
1209d326
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
21 deletion
+35
-21
libraries/chain/database.cpp
libraries/chain/database.cpp
+1
-1
libraries/chain/include/eos/chain/config.hpp
libraries/chain/include/eos/chain/config.hpp
+8
-1
libraries/chain/include/eos/chain/global_property_object.hpp
libraries/chain/include/eos/chain/global_property_object.hpp
+1
-1
libraries/chain/include/eos/chain/immutable_chain_parameters.hpp
...es/chain/include/eos/chain/immutable_chain_parameters.hpp
+1
-1
tests/common/database_fixture.cpp
tests/common/database_fixture.cpp
+1
-1
tests/tests/block_tests.cpp
tests/tests/block_tests.cpp
+23
-16
未找到文件。
libraries/chain/database.cpp
浏览文件 @
861cd06c
...
...
@@ -894,7 +894,7 @@ void database::update_last_irreversible_block()
// 1 1 1 1 1 1 1 2 2 2 -> 1
// 3 3 3 3 3 3 3 3 3 3 -> 3
size_t
offset
=
((
EOS_100_PERCENT
-
EOS_IRREVERSIBLE_THRESHOLD
)
*
producer_objs
.
size
()
/
EOS_100_PERCENT
);
size_t
offset
=
EOS_PERCENT
(
producer_objs
.
size
(),
EOS_100_PERCENT
-
EOS_IRREVERSIBLE_THRESHOLD
);
std
::
nth_element
(
producer_objs
.
begin
(),
producer_objs
.
begin
()
+
offset
,
producer_objs
.
end
(),
[](
const
producer_object
*
a
,
const
producer_object
*
b
)
...
...
libraries/chain/include/eos/chain/config.hpp
浏览文件 @
861cd06c
...
...
@@ -29,6 +29,7 @@
/** percentage fields are fixed point with a denominator of 10,000 */
#define EOS_100_PERCENT 10000
#define EOS_1_PERCENT (EOS_100_PERCENT/100)
#define EOS_DEFAULT_MAX_BLOCK_SIZE (256*1024)
#define EOS_DEFAULT_PRODUCER_PAY_PER_BLOCK (EOS_BLOCKCHAIN_PRECISION * int64_t(10))
...
...
@@ -36,6 +37,12 @@
#define EOS_IRREVERSIBLE_THRESHOLD (70 * EOS_1_PERCENT)
template
<
typename
Number
>
Number
EOS_PERCENT
(
Number
value
,
int
percentage
)
{
return
value
*
percentage
/
EOS_100_PERCENT
;
}
namespace
eos
{
namespace
config
{
const
static
int
EOS_PRODUCER_COUNT
=
21
;
const
static
int
ProducerCount
=
21
;
const
static
int
IrreversibleThreshold
=
70
*
EOS_1_PERCENT
;
}
}
// namespace eos::config
libraries/chain/include/eos/chain/global_property_object.hpp
浏览文件 @
861cd06c
...
...
@@ -50,7 +50,7 @@ namespace eos { namespace chain {
id_type
id
;
chain_parameters
parameters
;
std
::
array
<
producer_id_type
,
config
::
EOS_PRODUCER_COUNT
>
active_producers
;
std
::
array
<
producer_id_type
,
config
::
ProducerCount
>
active_producers
;
};
...
...
libraries/chain/include/eos/chain/immutable_chain_parameters.hpp
浏览文件 @
861cd06c
...
...
@@ -33,7 +33,7 @@ namespace eos { namespace chain {
struct
immutable_chain_parameters
{
uint16_t
min_producer_count
=
config
::
EOS_PRODUCER_COUNT
;
uint16_t
min_producer_count
=
config
::
ProducerCount
;
};
}
}
// eos::chain
...
...
tests/common/database_fixture.cpp
浏览文件 @
861cd06c
...
...
@@ -44,7 +44,7 @@ namespace eos { namespace chain {
testing_fixture
::
testing_fixture
()
{
default_genesis_state
.
initial_timestamp
=
fc
::
time_point_sec
(
EOS_TESTING_GENESIS_TIMESTAMP
);
default_genesis_state
.
immutable_parameters
.
min_producer_count
=
11
;
default_genesis_state
.
immutable_parameters
.
min_producer_count
=
config
::
ProducerCount
;
for
(
int
i
=
0
;
i
<
default_genesis_state
.
immutable_parameters
.
min_producer_count
;
++
i
)
{
auto
name
=
std
::
string
(
"init"
)
+
fc
::
to_string
(
i
);
auto
private_key
=
fc
::
ecc
::
private_key
::
regenerate
(
fc
::
sha256
::
hash
(
name
));
...
...
tests/tests/block_tests.cpp
浏览文件 @
861cd06c
...
...
@@ -34,7 +34,8 @@
#include "../common/database_fixture.hpp"
using
namespace
eos
::
chain
;
using
namespace
eos
;
using
namespace
chain
;
BOOST_AUTO_TEST_SUITE
(
block_tests
)
...
...
@@ -266,18 +267,20 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, testing_fixture )
BOOST_FIXTURE_TEST_CASE
(
restart_db
,
testing_fixture
)
{
try
{
MKDB
(
db
)
db
.
produce_blocks
(
10
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
10
);
BOOST_CHECK_EQUAL
(
db
.
last_irreversible_block_num
(),
3
);
auto
lag
=
EOS_PERCENT
(
config
::
ProducerCount
,
config
::
IrreversibleThreshold
);
db
.
produce_blocks
(
20
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
20
);
BOOST_CHECK_EQUAL
(
db
.
last_irreversible_block_num
(),
20
-
lag
);
db
.
close
();
db
.
open
();
// After restarting, we should have rewound to the last irreversible block.
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
3
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
20
-
lag
);
db
.
produce_blocks
(
5
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
8
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
25
-
lag
);
}
FC_LOG_AND_RETHROW
()
}
// Check that a db which is closed and reopened successfully syncs back with the network, including retrieving blocks
...
...
@@ -286,15 +289,16 @@ BOOST_FIXTURE_TEST_CASE(sleepy_db, testing_fixture)
{
try
{
MKDB
(
producer
)
MKNET
(
net
,
(
producer
))
// Produce 10 blocks on the chain
producer
.
produce_blocks
(
10
);
auto
lag
=
EOS_PERCENT
(
config
::
ProducerCount
,
config
::
IrreversibleThreshold
);
producer
.
produce_blocks
(
20
);
{
// The new node, sleepy, joins, syncs, disconnects
MKDB
(
sleepy
,
sleepy
)
net
.
connect_database
(
sleepy
);
BOOST_CHECK_EQUAL
(
producer
.
head_block_num
(),
1
0
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
1
0
);
BOOST_CHECK_EQUAL
(
producer
.
head_block_num
(),
2
0
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
2
0
);
net
.
disconnect_database
(
sleepy
);
sleepy
.
close
();
...
...
@@ -302,15 +306,15 @@ BOOST_FIXTURE_TEST_CASE(sleepy_db, testing_fixture)
// 5 new blocks are produced
producer
.
produce_blocks
(
5
);
BOOST_CHECK_EQUAL
(
producer
.
head_block_num
(),
1
5
);
BOOST_CHECK_EQUAL
(
producer
.
head_block_num
(),
2
5
);
// Sleepy is reborn! Check that it is now rewound to the LIB...
MKDB
(
sleepy
,
sleepy
)
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
3
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
20
-
lag
);
// Reconnect sleepy to the network and check that it syncs up to the present
net
.
connect_database
(
sleepy
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
1
5
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_num
(),
2
5
);
BOOST_CHECK_EQUAL
(
sleepy
.
head_block_id
().
str
(),
producer
.
head_block_id
().
str
());
}
FC_LOG_AND_RETHROW
()
}
...
...
@@ -318,13 +322,16 @@ BOOST_FIXTURE_TEST_CASE(sleepy_db, testing_fixture)
BOOST_FIXTURE_TEST_CASE
(
reindex
,
testing_fixture
)
{
try
{
MKDB
(
db
)
auto
lag
=
EOS_PERCENT
(
config
::
ProducerCount
,
config
::
IrreversibleThreshold
);
db
.
produce_blocks
(
100
);
BOOST_CHECK_EQUAL
(
db
.
last_irreversible_block_num
(),
93
);
BOOST_CHECK_EQUAL
(
db
.
last_irreversible_block_num
(),
100
-
lag
);
db
.
close
();
db
.
reindex
();
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
93
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
100
-
lag
);
db
.
produce_blocks
(
20
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
1
13
);
BOOST_CHECK_EQUAL
(
db
.
head_block_num
(),
1
20
-
lag
);
}
FC_LOG_AND_RETHROW
()
}
// Test wiping a database and resyncing with an ongoing network
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录