Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
49197217
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,发现更多精彩内容 >>
提交
49197217
编写于
5月 09, 2018
作者:
K
Khaled Al-Hassanieh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename eos_bucket to pervote_bucket
上级
53b5dc0c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
77 deletion
+79
-77
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+1
-1
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+3
-3
contracts/eosio.system/producer_pay.cpp
contracts/eosio.system/producer_pay.cpp
+9
-9
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+66
-64
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
49197217
...
...
@@ -126,7 +126,7 @@
{"name":"total_ram_stake", "type":"asset"},
{"name":"last_producer_schedule_update", "type":"time"},
{"name":"last_pervote_bucket_fill", "type":"uint64"},
{"name":"
eos_bucket",
"type":"asset"},
{"name":"
pervote_bucket",
"type":"asset"},
{"name":"savings", "type":"asset"},
{"name":"last_producer_schedule_id", "type":"checksum160"},
{"name":"total_activatied_stake", "type":"int64"}
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
49197217
...
...
@@ -33,7 +33,7 @@ namespace eosiosystem {
block_timestamp
last_producer_schedule_update
=
0
;
uint64_t
last_pervote_bucket_fill
=
0
;
eosio
::
asset
eos
_bucket
;
eosio
::
asset
pervote
_bucket
;
eosio
::
asset
savings
;
checksum160
last_producer_schedule_id
;
...
...
@@ -43,7 +43,7 @@ namespace eosiosystem {
EOSLIB_SERIALIZE_DERIVED
(
eosio_global_state
,
eosio_parameters
,
(
total_ram_bytes_reserved
)(
total_ram_stake
)
(
last_producer_schedule_update
)
(
last_pervote_bucket_fill
)
(
eos
_bucket
)(
savings
)(
last_producer_schedule_id
)(
total_activated_stake
)
)
(
pervote
_bucket
)(
savings
)(
last_producer_schedule_id
)(
total_activated_stake
)
)
};
struct
producer_info
{
...
...
@@ -191,7 +191,7 @@ namespace eosiosystem {
private:
eosio
::
asset
payment_per_block
(
double
rate
,
const
eosio
::
asset
&
token_supply
,
uint32_t
num_blocks
);
eosio
::
asset
payment_per_vote
(
const
account_name
&
owner
,
double
owners_votes
,
const
eosio
::
asset
&
eos
_bucket
);
eosio
::
asset
payment_per_vote
(
const
account_name
&
owner
,
double
owners_votes
,
const
eosio
::
asset
&
pervote
_bucket
);
eosio
::
asset
supply_growth
(
double
rate
,
const
eosio
::
asset
&
token_supply
,
time
seconds
);
...
...
contracts/eosio.system/producer_pay.cpp
浏览文件 @
49197217
...
...
@@ -29,7 +29,7 @@ namespace eosiosystem {
using
namespace
eosio
;
/** until activated stake crosses this threshold no new rewards are paid */
if
(
_gstate
.
total_activated_stake
<
150
0000000000
/* 150'000'000'0000 */
)
if
(
_gstate
.
total_activated_stake
<
150
'000'000'0000
)
return
;
if
(
_gstate
.
last_pervote_bucket_fill
==
0
)
/// start the presses
...
...
@@ -50,10 +50,10 @@ namespace eosiosystem {
}
eosio
::
asset
system_contract
::
payment_per_vote
(
const
account_name
&
owner
,
double
owners_votes
,
const
eosio
::
asset
&
eos
_bucket
)
{
eosio
::
asset
system_contract
::
payment_per_vote
(
const
account_name
&
owner
,
double
owners_votes
,
const
eosio
::
asset
&
pervote
_bucket
)
{
eosio
::
asset
payment
(
0
,
S
(
4
,
EOS
));
const
int64_t
min_daily_amount
=
100
*
10000
;
if
(
eos
_bucket
.
amount
<
min_daily_tokens
)
{
if
(
pervote
_bucket
.
amount
<
min_daily_tokens
)
{
return
payment
;
}
...
...
@@ -75,7 +75,7 @@ namespace eosiosystem {
}
total_producer_votes
+=
itr
->
total_votes
;
running_payment_amount
=
(
itr
->
total_votes
)
*
double
(
eos
_bucket
.
amount
)
/
total_producer_votes
;
running_payment_amount
=
(
itr
->
total_votes
)
*
double
(
pervote
_bucket
.
amount
)
/
total_producer_votes
;
if
(
running_payment_amount
<
min_daily_amount
)
{
if
(
itr
->
owner
==
owner
)
{
to_be_payed
=
false
;
...
...
@@ -86,7 +86,7 @@ namespace eosiosystem {
}
if
(
to_be_payed
)
{
payment
.
amount
=
static_cast
<
int64_t
>
(
(
double
(
eos
_bucket
.
amount
)
*
owners_votes
)
/
total_producer_votes
);
payment
.
amount
=
static_cast
<
int64_t
>
(
(
double
(
pervote
_bucket
.
amount
)
*
owners_votes
)
/
total_producer_votes
);
}
return
payment
;
...
...
@@ -106,12 +106,12 @@ namespace eosiosystem {
const
asset
token_supply
=
token
(
N
(
eosio
.
token
)).
get_supply
(
symbol_type
(
system_token_symbol
).
name
()
);
const
uint32_t
secs_since_last_fill
=
static_cast
<
uint32_t
>
(
(
current_time
()
-
_gstate
.
last_pervote_bucket_fill
)
/
1000000
);
const
asset
to_
eos
_bucket
=
supply_growth
(
standby_rate
,
token_supply
,
secs_since_last_fill
);
const
asset
to_
pervote
_bucket
=
supply_growth
(
standby_rate
,
token_supply
,
secs_since_last_fill
);
const
asset
to_savings
=
supply_growth
(
continuous_rate
-
(
perblock_rate
+
standby_rate
),
token_supply
,
secs_since_last_fill
);
const
asset
perblock_pay
=
payment_per_block
(
perblock_rate
,
token_supply
,
prod
->
produced_blocks
);
const
asset
issue_amount
=
to_
eos
_bucket
+
to_savings
+
perblock_pay
;
const
asset
issue_amount
=
to_
pervote
_bucket
+
to_savings
+
perblock_pay
;
const
asset
pervote_pay
=
payment_per_vote
(
owner
,
prod
->
total_votes
,
to_
eos_bucket
+
_gstate
.
eos
_bucket
);
const
asset
pervote_pay
=
payment_per_vote
(
owner
,
prod
->
total_votes
,
to_
pervote_bucket
+
_gstate
.
pervote
_bucket
);
if
(
perblock_pay
.
amount
+
pervote_pay
.
amount
==
0
)
{
_producers
.
modify
(
prod
,
0
,
[
&
](
auto
&
p
)
{
...
...
@@ -123,7 +123,7 @@ namespace eosiosystem {
INLINE_ACTION_SENDER
(
eosio
::
token
,
issue
)(
N
(
eosio
.
token
),
{{
N
(
eosio
),
N
(
active
)}},
{
N
(
eosio
),
issue_amount
,
std
::
string
(
"issue tokens for producer pay and savings"
)}
);
_gstate
.
eos_bucket
+=
(
to_eos
_bucket
-
pervote_pay
);
_gstate
.
pervote_bucket
+=
(
to_pervote
_bucket
-
pervote_pay
);
_gstate
.
last_pervote_bucket_fill
=
current_time
();
_gstate
.
savings
+=
to_savings
;
...
...
unittests/eosio.system_tests.cpp
浏览文件 @
49197217
...
...
@@ -1261,10 +1261,11 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
{
produce_blocks
(
50
);
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_eos_bucket
=
initial_global_state
[
"eos_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_pervote_bucket
=
initial_global_state
[
"pervote_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
prod
=
get_producer_info
(
"inita"
);
const
uint32_t
produced_blocks
=
prod
[
"produced_blocks"
].
as
<
uint32_t
>
();
BOOST_REQUIRE
(
1
<
produced_blocks
);
...
...
@@ -1274,10 +1275,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
inita
),
N
(
claimrewards
),
mvo
()(
"owner"
,
"inita"
)));
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
eos_bucket
=
global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
pervote_bucket
=
global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
prod
=
get_producer_info
(
"inita"
);
BOOST_REQUIRE_EQUAL
(
1
,
prod
[
"produced_blocks"
].
as
<
uint32_t
>
());
const
asset
supply
=
get_token_supply
();
...
...
@@ -1286,20 +1287,20 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL
(
claim_time
,
prod
[
"last_claim_time"
].
as
<
uint64_t
>
());
const
int32_t
secs_between_fills
=
static_cast
<
int32_t
>
((
claim_time
-
initial_claim_time
)
/
1000000
);
BOOST_REQUIRE_EQUAL
(
0
,
initial_
eos
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
0
,
initial_
pervote
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
((
4.879
-
1.0
)
/
100.0
))
/
(
52
*
7
*
24
*
3600
)
),
savings
.
amount
-
initial_savings
.
amount
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
(
0.25
/
100.0
)
/
(
52
*
7
*
24
*
3600
*
2
)
);
int64_t
from_
eos
_bucket
=
int64_t
(
initial_supply
.
amount
*
secs_between_fills
*
(
0.75
/
100.0
)
/
(
52
*
7
*
24
*
3600
)
);
int64_t
from_
pervote
_bucket
=
int64_t
(
initial_supply
.
amount
*
secs_between_fills
*
(
0.75
/
100.0
)
/
(
52
*
7
*
24
*
3600
)
);
if
(
from_
eos
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
eos
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
0
,
eos
_bucket
.
amount
);
if
(
from_
pervote
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
pervote
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
0
,
pervote
_bucket
.
amount
);
}
else
{
BOOST_REQUIRE_EQUAL
(
block_payments
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
from_
eos_bucket
,
eos
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
from_
pervote_bucket
,
pervote
_bucket
.
amount
);
}
const
int64_t
max_supply_growth
=
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
(
4.879
/
100.0
))
/
(
52
*
7
*
24
*
3600
)
);
...
...
@@ -1321,10 +1322,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
// wait 5 more minutes, inita can now claim rewards again
{
produce_block
(
fc
::
seconds
(
5
*
60
));
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
eos_bucket
=
initial_global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
pervote_bucket
=
initial_global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
prod
=
get_producer_info
(
"inita"
);
const
uint32_t
produced_blocks
=
prod
[
"produced_blocks"
].
as
<
uint32_t
>
();
...
...
@@ -1336,10 +1337,11 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
inita
),
N
(
claimrewards
),
mvo
()(
"owner"
,
"inita"
)));
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
eos_bucket
=
global_state
[
"eos_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
pervote_bucket
=
global_state
[
"pervote_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
prod
=
get_producer_info
(
"inita"
);
BOOST_REQUIRE_EQUAL
(
1
,
prod
[
"produced_blocks"
].
as
<
uint32_t
>
());
const
asset
supply
=
get_token_supply
();
...
...
@@ -1351,15 +1353,15 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
((
4.879
-
1.0
)
/
100.0
))
/
(
52
*
7
*
24
*
3600
)
),
savings
.
amount
-
initial_savings
.
amount
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
(
0.25
/
100.0
)
/
(
52
*
7
*
24
*
3600
*
2
)
);
int64_t
from_
eos_bucket
=
int64_t
(
initial_eos
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
(
0.75
/
100.0
)
/
(
52
*
7
*
24
*
3600
)
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
(
0.25
/
100.0
)
/
(
52
*
7
*
24
*
3600
*
2
)
);
int64_t
from_
pervote_bucket
=
int64_t
(
initial_pervote
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
(
0.75
/
100.0
)
/
(
52
*
7
*
24
*
3600
)
);
if
(
from_
eos
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
eos
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
0
,
eos
_bucket
.
amount
);
if
(
from_
pervote
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
pervote
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
0
,
pervote
_bucket
.
amount
);
}
else
{
BOOST_REQUIRE_EQUAL
(
block_payments
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
from_
eos_bucket
,
eos
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
from_
pervote_bucket
,
pervote
_bucket
.
amount
);
}
const
int64_t
max_supply_growth
=
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
(
4.879
/
100.0
))
/
(
52
*
7
*
24
*
3600
)
);
...
...
@@ -1490,37 +1492,37 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester) try {
const
auto
prod_name
=
producer_names
[
prod_index
];
const
auto
produced_blocks
=
get_producer_info
(
prod_name
)[
"produced_blocks"
].
as
<
uint32_t
>
();
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
eos_bucket
=
initial_global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
asset
initial_supply
=
get_token_supply
();
const
asset
initial_balance
=
get_balance
(
prod_name
);
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
pervote_bucket
=
initial_global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
asset
initial_supply
=
get_token_supply
();
const
asset
initial_balance
=
get_balance
(
prod_name
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
prod_name
,
N
(
claimrewards
),
mvo
()(
"owner"
,
prod_name
)));
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
eos_bucket
=
global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
asset
supply
=
get_token_supply
();
const
asset
balance
=
get_balance
(
prod_name
);
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
pervote_bucket
=
global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
asset
supply
=
get_token_supply
();
const
asset
balance
=
get_balance
(
prod_name
);
const
int32_t
secs_between_fills
=
static_cast
<
int32_t
>
((
claim_time
-
initial_claim_time
)
/
1000000
);
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
(
cont_rate
-
standby_rate
-
block_rate
))
/
secs_per_year
),
savings
.
amount
-
initial_savings
.
amount
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
block_rate
/
blocks_per_year
);
int64_t
expected_
eos_bucket
=
int64_t
(
initial_eos
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
standby_rate
/
secs_per_year
);
int64_t
from_
eos_bucket
=
int64_t
(
vote_shares
[
prod_index
]
*
expected_eos
_bucket
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
block_rate
/
blocks_per_year
);
int64_t
expected_
pervote_bucket
=
int64_t
(
initial_pervote
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
standby_rate
/
secs_per_year
);
int64_t
from_
pervote_bucket
=
int64_t
(
vote_shares
[
prod_index
]
*
expected_pervote
_bucket
);
if
(
from_
eos
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
eos
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
eos_bucket
-
from_eos_bucket
,
eos
_bucket
.
amount
);
if
(
from_
pervote
_bucket
>=
100
*
10000
)
{
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
pervote
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
pervote_bucket
-
from_pervote_bucket
,
pervote
_bucket
.
amount
);
}
else
{
BOOST_REQUIRE_EQUAL
(
block_payments
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
eos_bucket
,
eos
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
pervote_bucket
,
pervote
_bucket
.
amount
);
}
produce_blocks
(
5
);
...
...
@@ -1550,33 +1552,33 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester) try {
const
auto
prod_name
=
producer_names
[
prod_index
];
const
auto
produced_blocks
=
get_producer_info
(
prod_name
)[
"produced_blocks"
].
as
<
uint32_t
>
();
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
eos_bucket
=
initial_global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
asset
initial_supply
=
get_token_supply
();
const
asset
initial_balance
=
get_balance
(
prod_name
);
const
auto
initial_global_state
=
get_global_state
();
const
uint64_t
initial_claim_time
=
initial_global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
initial_
pervote_bucket
=
initial_global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
initial_savings
=
initial_global_state
[
"savings"
].
as
<
asset
>
();
const
asset
initial_supply
=
get_token_supply
();
const
asset
initial_balance
=
get_balance
(
prod_name
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
prod_name
,
N
(
claimrewards
),
mvo
()(
"owner"
,
prod_name
)));
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
eos_bucket
=
global_state
[
"eos
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
asset
supply
=
get_token_supply
();
const
asset
balance
=
get_balance
(
prod_name
);
const
auto
global_state
=
get_global_state
();
const
uint64_t
claim_time
=
global_state
[
"last_pervote_bucket_fill"
].
as_uint64
();
const
asset
pervote_bucket
=
global_state
[
"pervote
_bucket"
].
as
<
asset
>
();
const
asset
savings
=
global_state
[
"savings"
].
as
<
asset
>
();
const
asset
supply
=
get_token_supply
();
const
asset
balance
=
get_balance
(
prod_name
);
const
int32_t
secs_between_fills
=
static_cast
<
int32_t
>
((
claim_time
-
initial_claim_time
)
/
1000000
);
BOOST_REQUIRE_EQUAL
(
int64_t
(
(
initial_supply
.
amount
*
secs_between_fills
*
(
cont_rate
-
standby_rate
-
block_rate
))
/
secs_per_year
),
savings
.
amount
-
initial_savings
.
amount
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
block_rate
/
blocks_per_year
);
int64_t
expected_
eos_bucket
=
int64_t
(
initial_eos
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
standby_rate
/
secs_per_year
);
int64_t
from_
eos_bucket
=
int64_t
(
vote_shares
[
prod_index
]
*
expected_eos
_bucket
);
int64_t
block_payments
=
int64_t
(
initial_supply
.
amount
*
produced_blocks
*
block_rate
/
blocks_per_year
);
int64_t
expected_
pervote_bucket
=
int64_t
(
initial_pervote
_bucket
.
amount
+
initial_supply
.
amount
*
secs_between_fills
*
standby_rate
/
secs_per_year
);
int64_t
from_
pervote_bucket
=
int64_t
(
vote_shares
[
prod_index
]
*
expected_pervote
_bucket
);
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
eos
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
eos_bucket
-
from_eos_bucket
,
eos
_bucket
.
amount
);
BOOST_REQUIRE_EQUAL
(
block_payments
+
from_
pervote
_bucket
,
balance
.
amount
-
initial_balance
.
amount
);
BOOST_REQUIRE_EQUAL
(
expected_
pervote_bucket
-
from_pervote_bucket
,
pervote
_bucket
.
amount
);
produce_blocks
(
5
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录