Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
9d60b972
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,发现更多精彩内容 >>
提交
9d60b972
编写于
3月 15, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tests and bugfixes for producer voting
上级
19594632
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
17 deletion
+68
-17
contracts/eosio.system/delegate_bandwith.hpp
contracts/eosio.system/delegate_bandwith.hpp
+1
-1
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+12
-4
libraries/chain/include/eosio/chain/name.hpp
libraries/chain/include/eosio/chain/name.hpp
+2
-2
tests/wasm_tests/eosio.system_tests.cpp
tests/wasm_tests/eosio.system_tests.cpp
+53
-10
未找到文件。
contracts/eosio.system/delegate_bandwith.hpp
浏览文件 @
9d60b972
...
...
@@ -116,7 +116,7 @@ namespace eosiosystem {
if
(
0
<
del
.
stake_storage_quantity
.
amount
)
{
auto
parameters
=
global_state_singleton
::
exists
()
?
global_state_singleton
::
get
()
:
common
<
SystemAccount
>::
get_default_parameters
();
auto
token_supply
=
currency
::
get_total_supply
();
//.quantity;
auto
token_supply
=
currency
::
get_total_supply
();
//make sure that there is no posibility of overflow here
uint64_t
storage_bytes_estimated
=
(
parameters
.
max_storage_size
-
parameters
.
total_storage_bytes_reserved
)
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
9d60b972
...
...
@@ -284,14 +284,19 @@ namespace eosiosystem {
eosio
::
producer_schedule
schedule
;
schedule
.
producers
.
reserve
(
21
);
/*
for (auto it = idx.begin(); it != idx.end(); ++it) {
print( it->total_votes, ", " );
}
print ("\n");
*/
auto
it
=
idx
.
end
();
if
(
it
==
idx
.
begin
())
{
return
;
return
;
}
--
it
;
size_t
n
=
0
;
while
(
n
<
21
)
{
while
(
n
<
21
&&
0
<
it
->
total_votes
)
{
if
(
it
->
active
()
)
{
schedule
.
producers
.
emplace_back
();
schedule
.
producers
.
back
().
producer_name
=
it
->
owner
;
...
...
@@ -325,6 +330,9 @@ namespace eosiosystem {
}
--
it
;
}
if
(
n
==
0
)
{
//no active producers with votes > 0
return
;
}
// should use producer_schedule_type from libraries/chain/include/eosio/chain/producer_schedule.hpp
bytes
packed_schedule
=
pack
(
schedule
);
set_active_producers
(
packed_schedule
.
data
(),
packed_schedule
.
size
()
);
...
...
@@ -465,7 +473,7 @@ namespace eosiosystem {
votes
+=
voter
->
proxied_votes
;
}
if
(
old_producers
)
{
//old_producers == 0 if proxy has stoped being a proxy and votes were taken back from producers at that moment
if
(
old_producers
)
{
//old_producers == 0 if proxy has stoped being a proxy and votes were taken back from
the
producers at that moment
//revoke votes only from no longer elected
std
::
vector
<
account_name
>
revoked
(
old_producers
->
size
()
);
auto
end_it
=
std
::
set_difference
(
old_producers
->
begin
(),
old_producers
->
end
(),
new_producers
->
begin
(),
new_producers
->
end
(),
revoked
.
begin
()
);
...
...
libraries/chain/include/eosio/chain/name.hpp
浏览文件 @
9d60b972
#pragma once
#include <string>
#include <fc/reflect/reflect.hpp>
#include <iosfwd>
namespace
eosio
{
namespace
chain
{
using
std
::
string
;
...
...
@@ -72,8 +73,7 @@ namespace eosio { namespace chain {
return
*
this
;
}
template
<
typename
Stream
>
friend
Stream
&
operator
<<
(
Stream
&
out
,
const
name
&
n
)
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
name
&
n
)
{
return
out
<<
string
(
n
);
}
...
...
tests/wasm_tests/eosio.system_tests.cpp
浏览文件 @
9d60b972
...
...
@@ -399,7 +399,7 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake_separate, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL
(
bytes
,
total
[
"storage_bytes"
].
as_uint64
()
);
//storage
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"alice"
,
"0.0000 EOS"
,
"
20
0.0000 EOS"
,
"300.0000 EOS"
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"alice"
,
"0.0000 EOS"
,
"0.0000 EOS"
,
"300.0000 EOS"
)
);
total
=
get_total_stake
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"110.0000 EOS"
).
amount
,
total
[
"net_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"220.0000 EOS"
).
amount
,
total
[
"cpu_weight"
].
as_uint64
());
...
...
@@ -412,7 +412,7 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake_separate, eosio_system_tester ) try {
total
=
get_total_stake
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 EOS"
).
amount
,
total
[
"net_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"220.0000 EOS"
).
amount
,
total
[
"cpu_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"330
0
.0000 EOS"
).
amount
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"330.0000 EOS"
).
amount
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
bytes2
,
total
[
"storage_bytes"
].
as_uint64
());
//unstake net
...
...
@@ -420,15 +420,16 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake_separate, eosio_system_tester ) try {
total
=
get_total_stake
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 EOS"
).
amount
,
total
[
"net_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"20.0000 EOS"
).
amount
,
total
[
"cpu_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"330
0
.0000 EOS"
).
amount
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"330.0000 EOS"
).
amount
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
bytes2
,
total
[
"storage_bytes"
].
as_uint64
());
//unstake cpu
BOOST_REQUIRE_EQUAL
(
success
(),
unstake
(
"alice"
,
"0.0000 EOS"
,
"0.0000 EOS"
,
bytes2
/
2
)
);
total
=
get_total_stake
(
"alice"
);
auto
storage_left
=
M
(
"330.0000 EOS"
)
-
M
(
"330.0000 EOS"
)
*
(
bytes2
/
2
)
/
bytes2
;
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 EOS"
).
amount
,
total
[
"net_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"20.0000 EOS"
).
amount
,
total
[
"cpu_weight"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1650.0000 EOS"
).
amoun
t
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
storage_lef
t
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
bytes2
-
bytes2
/
2
,
total
[
"storage_bytes"
].
as_uint64
());
}
FC_LOG_AND_RETHROW
()
...
...
@@ -481,7 +482,7 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
);
auto
info
=
get_producer_info
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
info
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
info
[
"owner"
].
as_string
()
);
BOOST_REQUIRE_EQUAL
(
0
,
info
[
"total_votes"
].
as_uint64
()
);
REQUIRE_MATCHING_OBJECT
(
params
,
info
[
"prefs"
]
);
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
info
[
"packed_key"
])
);
...
...
@@ -499,7 +500,7 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
);
info
=
get_producer_info
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
info
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
info
[
"owner"
].
as_string
()
);
BOOST_REQUIRE_EQUAL
(
0
,
info
[
"total_votes"
].
as_uint64
()
);
REQUIRE_MATCHING_OBJECT
(
params2
,
info
[
"prefs"
]
);
BOOST_REQUIRE_EQUAL
(
string
(
key2
.
begin
(),
key2
.
end
()),
to_string
(
info
[
"packed_key"
])
);
...
...
@@ -513,7 +514,7 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
//key should be empty
BOOST_REQUIRE_EQUAL
(
true
,
to_string
(
info
[
"packed_key"
]).
empty
()
);
//everything else should stay the same
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
info
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
info
[
"owner"
].
as_string
()
);
BOOST_REQUIRE_EQUAL
(
0
,
info
[
"total_votes"
].
as_uint64
()
);
REQUIRE_MATCHING_OBJECT
(
params2
,
info
[
"prefs"
]
);
...
...
@@ -538,7 +539,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester ) try {
)
);
auto
prod
=
get_producer_info
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
prod
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
prod
[
"owner"
].
as_string
()
);
BOOST_REQUIRE_EQUAL
(
0
,
prod
[
"total_votes"
].
as_uint64
()
);
REQUIRE_MATCHING_OBJECT
(
params
,
prod
[
"prefs"
]);
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
prod
[
"packed_key"
])
);
...
...
@@ -562,7 +563,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester ) try {
//check that producer parameters stay the same after voting
prod
=
get_producer_info
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
111111
,
prod
[
"total_votes"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
prod
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
prod
[
"owner"
].
as_string
()
);
REQUIRE_MATCHING_OBJECT
(
params
,
prod
[
"prefs"
]);
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
prod
[
"packed_key"
])
);
...
...
@@ -613,7 +614,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL
(
0
,
prod
[
"total_votes"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"3000.0000 EOS"
),
get_balance
(
"carol"
)
);
//check that the producer parameters stay the same after all
BOOST_REQUIRE_EQUAL
(
N
(
alice
),
prod
[
"owner"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
"alice"
,
prod
[
"owner"
].
as_string
()
);
REQUIRE_MATCHING_OBJECT
(
params
,
prod
[
"prefs"
]);
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
prod
[
"packed_key"
])
);
...
...
@@ -1258,4 +1259,46 @@ BOOST_FIXTURE_TEST_CASE( proxy_cannot_use_another_proxy, eosio_system_tester ) t
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
elect_poducers_and_parameters
,
eosio_system_tester
)
try
{
create_accounts
(
{
N
(
producer1
),
N
(
producer2
),
N
(
producer3
)
}
);
BOOST_REQUIRE_EQUAL
(
success
(),
regproducer
(
"producer1"
,
1
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
regproducer
(
"producer2"
,
3
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
regproducer
(
"producer3"
,
5
)
);
/*
issue( "alice", "1000.0000 EOS", config::system_account_name );
BOOST_REQUIRE_EQUAL( success(), stake( "alice", "100.0000 EOS", "50.0000 EOS", "50.0000 EOS" ) );
//vote for producers
BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo()
("voter", "alice")
("proxy", name(0).to_string() )
("producers", vector<account_name>{ N(producer1) } )
)
);
produce_blocks(100);
auto producer_keys = control->get_global_properties().active_producers.producers;
BOOST_REQUIRE_EQUAL( 1, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("producer1"), producer_keys[0].producer_name );
*/
issue
(
"bob"
,
"1000.0000 EOS"
,
config
::
system_account_name
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"bob"
,
"200.0000 EOS"
,
"100.0000 EOS"
,
"50.0000 EOS"
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
bob
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"bob"
)
(
"proxy"
,
name
(
0
).
to_string
()
)
(
"producers"
,
vector
<
account_name
>
{
N
(
producer1
),
N
(
producer2
)
}
)
)
);
std
::
cout
<<
"after push block"
<<
std
::
endl
;
produce_blocks
(
200
);
auto
producer_keys
=
control
->
get_global_properties
().
active_producers
.
producers
;
std
::
cout
<<
"producers: "
<<
std
::
endl
;
for
(
auto
&
x
:
producer_keys
)
{
std
::
cout
<<
x
.
producer_name
<<
std
::
endl
;
}
BOOST_REQUIRE_EQUAL
(
2
,
producer_keys
.
size
()
);
BOOST_REQUIRE_EQUAL
(
name
(
"producer2"
),
producer_keys
[
0
].
producer_name
);
BOOST_REQUIRE_EQUAL
(
name
(
"producer1"
),
producer_keys
[
1
].
producer_name
);
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录