Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
0688238c
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,发现更多精彩内容 >>
提交
0688238c
编写于
6月 21, 2017
作者:
N
Nathan Hourt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ref #19: Update round in generate_block
Now we calculate the round changes and store them in generate_block.
上级
019a2dcc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
6 deletion
+22
-6
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+6
-0
tests/common/database_fixture.cpp
tests/common/database_fixture.cpp
+10
-2
tests/common/database_fixture.hpp
tests/common/database_fixture.hpp
+4
-0
tests/tests/database_tests.cpp
tests/tests/database_tests.cpp
+2
-4
未找到文件。
libraries/chain/chain_controller.cpp
浏览文件 @
0688238c
...
@@ -395,6 +395,12 @@ signed_block chain_controller::_generate_block(
...
@@ -395,6 +395,12 @@ signed_block chain_controller::_generate_block(
pending_block
.
producer
=
producer_obj
.
owner
;
pending_block
.
producer
=
producer_obj
.
owner
;
// If this block is last in a round, calculate the schedule for the new round
if
(
pending_block
.
block_num
()
%
config
::
BlocksPerRound
==
0
)
{
auto
new_schedule
=
_admin
->
get_next_round
(
_db
);
pending_block
.
producer_changes
=
get_global_properties
().
active_producers
-
new_schedule
;
}
if
(
!
(
skip
&
skip_producer_signature
)
)
if
(
!
(
skip
&
skip_producer_signature
)
)
pending_block
.
sign
(
block_signing_private_key
);
pending_block
.
sign
(
block_signing_private_key
);
...
...
tests/common/database_fixture.cpp
浏览文件 @
0688238c
...
@@ -54,12 +54,12 @@ testing_fixture::testing_fixture() {
...
@@ -54,12 +54,12 @@ testing_fixture::testing_fixture() {
auto
private_key
=
fc
::
ecc
::
private_key
::
regenerate
(
fc
::
sha256
::
hash
(
name
));
auto
private_key
=
fc
::
ecc
::
private_key
::
regenerate
(
fc
::
sha256
::
hash
(
name
));
public_key_type
public_key
=
private_key
.
get_public_key
();
public_key_type
public_key
=
private_key
.
get_public_key
();
default_genesis_state
.
initial_accounts
.
emplace_back
(
name
,
0
,
100000
,
public_key
,
public_key
);
default_genesis_state
.
initial_accounts
.
emplace_back
(
name
,
0
,
100000
,
public_key
,
public_key
);
key_ring
[
public_key
]
=
private_key
;
store_private_key
(
private_key
)
;
private_key
=
fc
::
ecc
::
private_key
::
regenerate
(
fc
::
sha256
::
hash
(
name
+
".producer"
));
private_key
=
fc
::
ecc
::
private_key
::
regenerate
(
fc
::
sha256
::
hash
(
name
+
".producer"
));
public_key
=
private_key
.
get_public_key
();
public_key
=
private_key
.
get_public_key
();
default_genesis_state
.
initial_producers
.
emplace_back
(
name
,
public_key
);
default_genesis_state
.
initial_producers
.
emplace_back
(
name
,
public_key
);
key_ring
[
public_key
]
=
private_key
;
store_private_key
(
private_key
)
;
}
}
}
}
...
@@ -81,6 +81,10 @@ native_contract::genesis_state_type& testing_fixture::genesis_state() {
...
@@ -81,6 +81,10 @@ native_contract::genesis_state_type& testing_fixture::genesis_state() {
return
default_genesis_state
;
return
default_genesis_state
;
}
}
void
testing_fixture
::
store_private_key
(
const
private_key_type
&
key
)
{
key_ring
[
key
.
get_public_key
()]
=
key
;
}
private_key_type
testing_fixture
::
get_private_key
(
const
public_key_type
&
public_key
)
const
{
private_key_type
testing_fixture
::
get_private_key
(
const
public_key_type
&
public_key
)
const
{
auto
itr
=
key_ring
.
find
(
public_key
);
auto
itr
=
key_ring
.
find
(
public_key
);
EOS_ASSERT
(
itr
!=
key_ring
.
end
(),
missing_key_exception
,
EOS_ASSERT
(
itr
!=
key_ring
.
end
(),
missing_key_exception
,
...
@@ -143,6 +147,10 @@ std::set<types::AccountName> testing_database::get_approved_producers(const type
...
@@ -143,6 +147,10 @@ std::set<types::AccountName> testing_database::get_approved_producers(const type
return
{
set
.
begin
(),
set
.
end
()};
return
{
set
.
begin
(),
set
.
end
()};
}
}
types
::
PublicKey
testing_database
::
get_block_signing_key
(
const
types
::
AccountName
&
producerName
)
{
return
get_database
().
get
<
producer_object
,
by_owner
>
(
producerName
).
signing_key
;
}
void
testing_network
::
connect_database
(
testing_database
&
new_database
)
{
void
testing_network
::
connect_database
(
testing_database
&
new_database
)
{
if
(
databases
.
count
(
&
new_database
))
if
(
databases
.
count
(
&
new_database
))
return
;
return
;
...
...
tests/common/database_fixture.hpp
浏览文件 @
0688238c
...
@@ -114,6 +114,7 @@ public:
...
@@ -114,6 +114,7 @@ public:
const
native_contract
::
genesis_state_type
&
genesis_state
()
const
;
const
native_contract
::
genesis_state_type
&
genesis_state
()
const
;
native_contract
::
genesis_state_type
&
genesis_state
();
native_contract
::
genesis_state_type
&
genesis_state
();
void
store_private_key
(
const
private_key_type
&
key
);
private_key_type
get_private_key
(
const
public_key_type
&
public_key
)
const
;
private_key_type
get_private_key
(
const
public_key_type
&
public_key
)
const
;
protected:
protected:
...
@@ -170,6 +171,8 @@ public:
...
@@ -170,6 +171,8 @@ public:
/// @brief Get the set of producers approved by the named account
/// @brief Get the set of producers approved by the named account
std
::
set
<
AccountName
>
get_approved_producers
(
const
AccountName
&
account
);
std
::
set
<
AccountName
>
get_approved_producers
(
const
AccountName
&
account
);
/// @brief Get the specified block producer's signing key
PublicKey
get_block_signing_key
(
const
AccountName
&
producerName
);
protected:
protected:
testing_fixture
&
fixture
;
testing_fixture
&
fixture
;
...
@@ -284,6 +287,7 @@ protected:
...
@@ -284,6 +287,7 @@ protected:
* @endcode
* @endcode
*/
*/
#define Make_Key(name) auto name ## _private_key = private_key_type::regenerate(fc::digest(#name "_private_key")); \
#define Make_Key(name) auto name ## _private_key = private_key_type::regenerate(fc::digest(#name "_private_key")); \
store_private_key(name ## _private_key); \
PublicKey name ## _public_key = name ## _private_key.get_public_key();
PublicKey name ## _public_key = name ## _private_key.get_public_key();
/**
/**
...
...
tests/tests/database_tests.cpp
浏览文件 @
0688238c
...
@@ -185,7 +185,7 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_parameters_2, testing_fixture)
...
@@ -185,7 +185,7 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_parameters_2, testing_fixture)
}
FC_LOG_AND_RETHROW
()
}
}
FC_LOG_AND_RETHROW
()
}
// Test that if I create a producer and vote for him, he gets in on the next round (but not before)
// Test that if I create a producer and vote for him, he gets in on the next round (but not before)
BOOST_FIXTURE_TEST_CASE
(
producer_voting_1
,
testing_fixture
,
*
boost
::
unit_test
::
expected_failures
(
1
)
)
{
BOOST_FIXTURE_TEST_CASE
(
producer_voting_1
,
testing_fixture
)
{
try
{
try
{
Make_Database
(
db
)
Make_Database
(
db
)
db
.
produce_blocks
();
db
.
produce_blocks
();
...
@@ -210,7 +210,6 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_1, testing_fixture, *boost::unit_test::e
...
@@ -210,7 +210,6 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_1, testing_fixture, *boost::unit_test::e
db
.
produce_blocks
();
db
.
produce_blocks
();
const
auto
&
gpo
=
db
.
get_global_properties
();
const
auto
&
gpo
=
db
.
get_global_properties
();
#warning TODO: expected failure because chain_controller::generate_block does not update round
BOOST_REQUIRE
(
boost
::
find
(
gpo
.
active_producers
,
"joe"
)
!=
gpo
.
active_producers
.
end
());
BOOST_REQUIRE
(
boost
::
find
(
gpo
.
active_producers
,
"joe"
)
!=
gpo
.
active_producers
.
end
());
Approve_Producer
(
db
,
bob
,
joe
,
false
);
Approve_Producer
(
db
,
bob
,
joe
,
false
);
...
@@ -226,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_1, testing_fixture, *boost::unit_test::e
...
@@ -226,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_1, testing_fixture, *boost::unit_test::e
}
}
// Same as producer_voting_1, except we first cast the vote for the producer, _then_ get a stake
// Same as producer_voting_1, except we first cast the vote for the producer, _then_ get a stake
BOOST_FIXTURE_TEST_CASE
(
producer_voting_2
,
testing_fixture
,
*
boost
::
unit_test
::
expected_failures
(
1
)
)
{
BOOST_FIXTURE_TEST_CASE
(
producer_voting_2
,
testing_fixture
)
{
try
{
try
{
Make_Database
(
db
)
Make_Database
(
db
)
db
.
produce_blocks
();
db
.
produce_blocks
();
...
@@ -261,7 +260,6 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_2, testing_fixture, *boost::unit_test::e
...
@@ -261,7 +260,6 @@ BOOST_FIXTURE_TEST_CASE(producer_voting_2, testing_fixture, *boost::unit_test::e
db
.
produce_blocks
();
db
.
produce_blocks
();
const
auto
&
gpo
=
db
.
get_global_properties
();
const
auto
&
gpo
=
db
.
get_global_properties
();
#warning TODO: expected failure because chain_controller::generate_block does not update round
BOOST_REQUIRE
(
boost
::
find
(
gpo
.
active_producers
,
"joe"
)
!=
gpo
.
active_producers
.
end
());
BOOST_REQUIRE
(
boost
::
find
(
gpo
.
active_producers
,
"joe"
)
!=
gpo
.
active_producers
.
end
());
Approve_Producer
(
db
,
bob
,
joe
,
false
);
Approve_Producer
(
db
,
bob
,
joe
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录