Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
498bdc13
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,发现更多精彩内容 >>
提交
498bdc13
编写于
3月 08, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tests and bugfix in variant comparison
上级
4a79aead
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
81 addition
and
48 deletion
+81
-48
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+9
-0
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+2
-1
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+6
-6
libraries/fc/src/variant.cpp
libraries/fc/src/variant.cpp
+2
-5
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+2
-2
tests/wasm_tests/eosio.system_tests.cpp
tests/wasm_tests/eosio.system_tests.cpp
+60
-34
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
498bdc13
...
...
@@ -119,6 +119,12 @@
{"name":"producer_key", "type":"bytes"},
{"name":"prefs", "type":"eosio_parameters"}
]
},{
"name": "unregprod",
"base": "",
"fields": [
{"name":"producer", "type":"account_name"}
]
},{
"name": "stakevote",
"base": "",
...
...
@@ -166,6 +172,9 @@
},{
"name": "regproducer",
"type": "regproducer"
},{
"name": "unregprod",
"type": "unregprod"
},{
"name": "stakevote",
"type": "stakevote"
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
498bdc13
...
...
@@ -72,7 +72,8 @@ namespace eosiosystem {
typename
voting
<
SystemAccount
>::
register_proxy
,
typename
voting
<
SystemAccount
>::
unregister_proxy
,
typename
voting
<
SystemAccount
>::
regproducer
,
typename
voting
<
SystemAccount
>::
vote_producer
,
typename
voting
<
SystemAccount
>::
unregprod
,
typename
voting
<
SystemAccount
>::
voteproducer
,
typename
voting
<
SystemAccount
>::
stakevote
,
typename
voting
<
SystemAccount
>::
unstakevote
,
typename
voting
<
SystemAccount
>::
unstake_vote_deferred
,
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
498bdc13
...
...
@@ -118,13 +118,13 @@ namespace eosiosystem {
}
}
ACTION
(
SystemAccount
,
unregprod
ucer
)
{
ACTION
(
SystemAccount
,
unregprod
)
{
account_name
producer
;
EOSLIB_SERIALIZE
(
unregprod
ucer
,
(
producer
)
)
EOSLIB_SERIALIZE
(
unregprod
,
(
producer
)
)
};
static
void
on
(
const
unregprod
ucer
&
unreg
)
{
static
void
on
(
const
unregprod
&
unreg
)
{
require_auth
(
unreg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
...
...
@@ -388,12 +388,12 @@ namespace eosiosystem {
});
}
ACTION
(
SystemAccount
,
vote
_
producer
)
{
ACTION
(
SystemAccount
,
voteproducer
)
{
account_name
voter
;
account_name
proxy
;
std
::
vector
<
account_name
>
producers
;
EOSLIB_SERIALIZE
(
vote
_
producer
,
(
voter
)(
proxy
)(
producers
)
)
EOSLIB_SERIALIZE
(
voteproducer
,
(
voter
)(
proxy
)(
producers
)
)
};
/**
...
...
@@ -403,7 +403,7 @@ namespace eosiosystem {
* @pre vp.voter must authorize this action
* @pre voter must have previously staked some EOS for voting
*/
static
void
on
(
const
vote
_
producer
&
vp
)
{
static
void
on
(
const
voteproducer
&
vp
)
{
require_auth
(
vp
.
voter
);
//validate input
...
...
libraries/fc/src/variant.cpp
浏览文件 @
498bdc13
...
...
@@ -754,16 +754,13 @@ string format_string( const string& format, const variant_object& args )
if
(
a
.
is_double
()
||
b
.
is_double
()
)
return
a
.
as_double
()
==
b
.
as_double
();
if
(
a
.
is_int64
()
||
b
.
is_int64
()
)
return
a
.
as_int64
()
==
b
.
as_int64
();
if
(
a
.
is_uint64
()
||
b
.
is_uint64
()
)
return
a
.
as_uint64
()
==
b
.
as_uint64
();
if
(
a
.
is_array
()
||
b
.
is_array
()
)
return
a
.
get_array
()
==
b
.
get_array
();
return
false
;
}
bool
operator
!=
(
const
variant
&
a
,
const
variant
&
b
)
{
if
(
a
.
is_string
()
||
b
.
is_string
()
)
return
a
.
as_string
()
!=
b
.
as_string
();
if
(
a
.
is_double
()
||
b
.
is_double
()
)
return
a
.
as_double
()
!=
b
.
as_double
();
if
(
a
.
is_int64
()
||
b
.
is_int64
()
)
return
a
.
as_int64
()
!=
b
.
as_int64
();
if
(
a
.
is_uint64
()
||
b
.
is_uint64
()
)
return
a
.
as_uint64
()
!=
b
.
as_uint64
();
return
false
;
return
!
(
a
==
b
);
}
bool
operator
!
(
const
variant
&
a
)
...
...
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
498bdc13
...
...
@@ -7,9 +7,9 @@
#include <iosfwd>
#define REQUIRE_EQUAL_OBJECTS(
a, b)
BOOST_REQUIRE_EQUAL( true, a.is_object() ); \
#define REQUIRE_EQUAL_OBJECTS(
left, right) { auto a = left; auto b = right;
BOOST_REQUIRE_EQUAL( true, a.is_object() ); \
BOOST_REQUIRE_EQUAL( true, b.is_object() ); \
BOOST_REQUIRE_EQUAL_COLLECTIONS( a.get_object().begin(), a.get_object().end(), b.get_object().begin(), b.get_object().end() );
BOOST_REQUIRE_EQUAL_COLLECTIONS( a.get_object().begin(), a.get_object().end(), b.get_object().begin(), b.get_object().end() );
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
osm
,
const
fc
::
variant
&
v
);
...
...
tests/wasm_tests/eosio.system_tests.cpp
浏览文件 @
498bdc13
...
...
@@ -58,6 +58,10 @@ public:
return
base_tester
::
push_action
(
std
::
move
(
act
),
auth
?
uint64_t
(
signer
)
:
0
);
}
uint32_t
last_block_time
()
const
{
return
time_point_sec
(
control
->
head_block_time
()
).
sec_since_epoch
();
}
asset
get_balance
(
const
account_name
&
act
)
{
return
get_currency_balance
(
config
::
system_account_name
,
symbol
(
SY
(
4
,
EOS
)),
act
);
}
...
...
@@ -457,6 +461,25 @@ void require_simple_voter(const fc::variant& vi) {
BOOST_REQUIRE_EQUAL
(
0
,
vi
[
"last_unstake"
].
as_uint64
()
);
}
fc
::
variant
simple_voter
(
account_name
acct
,
uint64_t
vote_stake
,
uint64_t
ts
)
{
return
mutable_variant_object
()
(
"owner"
,
acct
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"last_update"
,
ts
)
(
"is_proxy"
,
0
)
(
"staked"
,
vote_stake
)
(
"unstaking"
,
0
)
(
"unstake_per_week"
,
0
)
(
"proxied_votes"
,
0
)
(
"producers"
,
variants
()
)
(
"deferred_trx_id"
,
0
)
(
"last_unstake"
,
0
);
}
fc
::
variant
simple_voter
(
account_name
acct
,
const
string
&
vote_stake
,
uint64_t
ts
)
{
return
simple_voter
(
acct
,
asset
::
from_string
(
vote_stake
).
amount
,
ts
);
}
BOOST_FIXTURE_TEST_CASE
(
stake_add_more_partial_unstake
,
eosio_system_tester
)
try
{
issue
(
"alice"
,
"1000.0000 EOS"
,
config
::
system_account_name
);
...
...
@@ -519,32 +542,37 @@ BOOST_FIXTURE_TEST_CASE( stake_add_more_partial_unstake, eosio_system_tester ) t
);
vi
=
get_voter_info
(
"alice"
);
require_simple_voter
(
vi
);
REQUIRE_EQUAL_OBJECTS
(
simple_voter
(
"alice"
,
"1000.0000 EOS"
,
last_block_time
()),
get_voter_info
(
"alice"
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 EOS"
).
amount
,
vi
[
"staked"
].
as_uint64
()
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000.0000 EOS"
),
get_balance
(
"alice"
)
);
}
FC_LOG_AND_RETHROW
()
static
fc
::
variant
producer_parameters_example
(
int
n
)
{
return
mutable_variant_object
()
(
"target_block_size"
,
1024
*
1024
+
n
)
(
"max_block_size"
,
10
*
1024
+
n
)
(
"target_block_acts_per_scope"
,
1000
+
n
)
(
"max_block_acts_per_scope"
,
10000
+
n
)
(
"target_block_acts"
,
1100
+
n
)
(
"max_block_acts"
,
11000
+
n
)
(
"max_storage_size"
,
2000
+
n
)
(
"max_transaction_lifetime"
,
3600
+
n
)
(
"max_transaction_exec_time"
,
9900
+
n
)
(
"max_authority_depth"
,
6
+
n
)
(
"max_inline_depth"
,
4
+
n
)
(
"max_inline_action_size"
,
4096
+
n
)
(
"max_generated_transaction_size"
,
64
*
1024
+
n
)
(
"inflation_rate"
,
1050
+
n
)
(
"storage_reserve_ratio"
,
100
+
n
);
}
BOOST_FIXTURE_TEST_CASE
(
producer_register_unregister
,
eosio_system_tester
)
try
{
issue
(
"alice"
,
"1000.0000 EOS"
,
config
::
system_account_name
);
fc
::
variant
params
=
mutable_variant_object
()
(
"target_block_size"
,
1024
*
1024
)
(
"max_block_size"
,
10
*
1024
)
(
"target_block_acts_per_scope"
,
1001
)
(
"max_block_acts_per_scope"
,
10001
)
(
"target_block_acts"
,
1101
)
(
"max_block_acts"
,
11001
)
(
"max_storage_size"
,
2001
)
(
"max_transaction_lifetime"
,
3601
)
(
"max_transaction_exec_time"
,
9999
)
(
"max_authority_depth"
,
6
)
(
"max_inline_depth"
,
4
)
(
"max_inline_action_size"
,
4096
)
(
"max_generated_transaction_size"
,
64
*
1024
)
(
"inflation_rate"
,
1051
)
(
"storage_reserve_ratio"
,
1005
);
fc
::
variant
params
=
producer_parameters_example
(
1
);
vector
<
char
>
key
=
fc
::
raw
::
pack
(
fc
::
crypto
::
public_key
(
std
::
string
(
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
)
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
alice
),
N
(
regproducer
),
mvo
()
(
"producer"
,
"alice"
)
...
...
@@ -560,23 +588,8 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
info
[
"packed_key"
])
);
//do regproducer again to change parameters
fc
::
variant
params2
=
mutable_variant_object
()
(
"target_block_size"
,
1024
*
1024
+
1
)
(
"max_block_size"
,
10
*
1024
+
1
)
(
"target_block_acts_per_scope"
,
1002
)
(
"max_block_acts_per_scope"
,
10002
)
(
"target_block_acts"
,
1102
)
(
"max_block_acts"
,
11002
)
(
"max_storage_size"
,
2002
)
(
"max_transaction_lifetime"
,
3602
)
(
"max_transaction_exec_time"
,
9997
)
(
"max_authority_depth"
,
7
)
(
"max_inline_depth"
,
5
)
(
"max_inline_action_size"
,
4095
)
(
"max_generated_transaction_size"
,
64
*
1025
)
(
"inflation_rate"
,
1052
)
(
"storage_reserve_ratio"
,
1006
);
//call regproducer again to change parameters
fc
::
variant
params2
=
producer_parameters_example
(
2
);
vector
<
char
>
key2
=
fc
::
raw
::
pack
(
fc
::
crypto
::
public_key
(
std
::
string
(
"EOSR16EPHFSKVYHBjQgxVGQPrwCxTg7BbZ69H9i4gztN9deKTEXYne4"
)
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
alice
),
N
(
regproducer
),
mvo
()
...
...
@@ -592,6 +605,19 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
REQUIRE_EQUAL_OBJECTS
(
params2
,
info
[
"prefs"
]
);
BOOST_REQUIRE_EQUAL
(
string
(
key2
.
begin
(),
key2
.
end
()),
to_string
(
info
[
"packed_key"
])
);
//unregister producer
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
alice
),
N
(
unregprod
),
mvo
()
(
"producer"
,
"alice"
)
)
);
info
=
get_producer_info
(
"alice"
);
//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
(
0
,
info
[
"total_votes"
].
as_uint64
()
);
REQUIRE_EQUAL_OBJECTS
(
params2
,
info
[
"prefs"
]
);
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录