Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
38eb6298
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,发现更多精彩内容 >>
提交
38eb6298
编写于
5月 25, 2018
作者:
B
Bill Hamilton
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into eosio_build_fedora
Merging master into branch eosio_build_fedora
上级
6293147c
393546bd
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
261 addition
and
88 deletion
+261
-88
contracts/eosio.system/delegate_bandwidth.cpp
contracts/eosio.system/delegate_bandwidth.cpp
+2
-2
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+11
-1
libraries/chain/resource_limits.cpp
libraries/chain/resource_limits.cpp
+4
-8
plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp
plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp
+13
-13
tutorials/bios-boot-tutorial/bios-boot-tutorial.py
tutorials/bios-boot-tutorial/bios-boot-tutorial.py
+114
-54
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+115
-7
unittests/ram_tests.cpp
unittests/ram_tests.cpp
+2
-3
未找到文件。
contracts/eosio.system/delegate_bandwidth.cpp
浏览文件 @
38eb6298
...
@@ -117,7 +117,7 @@ namespace eosiosystem {
...
@@ -117,7 +117,7 @@ namespace eosiosystem {
{
payer
,
N
(
eosio
.
ram
),
quant_after_fee
,
std
::
string
(
"buy ram"
)
}
);
{
payer
,
N
(
eosio
.
ram
),
quant_after_fee
,
std
::
string
(
"buy ram"
)
}
);
}
}
if
(
fee
.
amount
>
0
)
{
if
(
payer
!=
N
(
eosio
)
&&
fee
.
amount
>
0
)
{
INLINE_ACTION_SENDER
(
eosio
::
token
,
transfer
)(
N
(
eosio
.
token
),
{
payer
,
N
(
active
)},
INLINE_ACTION_SENDER
(
eosio
::
token
,
transfer
)(
N
(
eosio
.
token
),
{
payer
,
N
(
active
)},
{
payer
,
N
(
eosio
.
ramfee
),
fee
,
std
::
string
(
"ram fee"
)
}
);
{
payer
,
N
(
eosio
.
ramfee
),
fee
,
std
::
string
(
"ram fee"
)
}
);
}
}
...
@@ -259,7 +259,7 @@ namespace eosiosystem {
...
@@ -259,7 +259,7 @@ namespace eosiosystem {
set_resource_limits
(
receiver
,
tot_itr
->
ram_bytes
,
tot_itr
->
net_weight
.
amount
,
tot_itr
->
cpu_weight
.
amount
);
set_resource_limits
(
receiver
,
tot_itr
->
ram_bytes
,
tot_itr
->
net_weight
.
amount
,
tot_itr
->
cpu_weight
.
amount
);
if
(
tot_itr
->
net_weight
==
asset
(
0
)
&&
tot_itr
->
cpu_weight
==
asset
(
0
)
)
{
if
(
tot_itr
->
net_weight
==
asset
(
0
)
&&
tot_itr
->
cpu_weight
==
asset
(
0
)
&&
tot_itr
->
ram_bytes
==
0
)
{
totals_tbl
.
erase
(
tot_itr
);
totals_tbl
.
erase
(
tot_itr
);
}
}
}
// tot_itr can be invalid, should go out of scope
}
// tot_itr can be invalid, should go out of scope
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
38eb6298
...
@@ -80,7 +80,13 @@ namespace eosiosystem {
...
@@ -80,7 +80,13 @@ namespace eosiosystem {
for
(
auto
it
=
idx
.
cbegin
();
it
!=
idx
.
cend
()
&&
top_producers
.
size
()
<
21
&&
0
<
it
->
total_votes
;
++
it
)
{
for
(
auto
it
=
idx
.
cbegin
();
it
!=
idx
.
cend
()
&&
top_producers
.
size
()
<
21
&&
0
<
it
->
total_votes
;
++
it
)
{
if
(
!
it
->
active
()
)
continue
;
if
(
!
it
->
active
()
)
continue
;
if
(
it
->
time_became_active
.
slot
==
0
)
{
/**
If it's the first time or it's been over a day since a producer was last voted in,
update his info. Otherwise, a producer gets a grace period of 7 hours after which
he gets deactivated if he hasn't produced in 24 hours.
*/
if
(
it
->
time_became_active
.
slot
==
0
||
block_time
.
slot
>
it
->
time_became_active
.
slot
+
blocks_per_day
)
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
p
.
time_became_active
=
block_time
;
p
.
time_became_active
=
block_time
;
});
});
...
@@ -92,6 +98,10 @@ namespace eosiosystem {
...
@@ -92,6 +98,10 @@ namespace eosiosystem {
});
});
continue
;
continue
;
}
else
{
_producers
.
modify
(
*
it
,
0
,
[
&
](
auto
&
p
)
{
p
.
time_became_active
=
block_time
;
});
}
}
top_producers
.
emplace_back
(
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
it
->
owner
,
it
->
producer_key
},
it
->
location
}));
top_producers
.
emplace_back
(
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
it
->
owner
,
it
->
producer_key
},
it
->
location
}));
...
...
libraries/chain/resource_limits.cpp
浏览文件 @
38eb6298
...
@@ -396,9 +396,8 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const
...
@@ -396,9 +396,8 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const
const
auto
&
state
=
_db
.
get
<
resource_limits_state_object
>
();
const
auto
&
state
=
_db
.
get
<
resource_limits_state_object
>
();
const
auto
&
usage
=
_db
.
get
<
resource_usage_object
,
by_owner
>
(
name
);
const
auto
&
usage
=
_db
.
get
<
resource_usage_object
,
by_owner
>
(
name
);
int64_t
x
;
int64_t
cpu_weight
,
x
,
y
;
int64_t
cpu_weight
;
get_account_limits
(
name
,
x
,
y
,
cpu_weight
);
get_account_limits
(
name
,
x
,
x
,
cpu_weight
);
if
(
cpu_weight
<
0
||
state
.
total_cpu_weight
==
0
)
{
if
(
cpu_weight
<
0
||
state
.
total_cpu_weight
==
0
)
{
return
{
-
1
,
-
1
,
-
1
};
return
{
-
1
,
-
1
,
-
1
};
...
@@ -412,8 +411,6 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const
...
@@ -412,8 +411,6 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const
uint128_t
user_weight
=
cpu_weight
;
uint128_t
user_weight
=
cpu_weight
;
uint128_t
all_user_weight
=
state
.
total_cpu_weight
;
uint128_t
all_user_weight
=
state
.
total_cpu_weight
;
wdump
((
cpu_weight
));
auto
max_user_use_in_window
=
(
uint128_t
(
virtual_cpu_capacity_in_window
)
*
user_weight
)
/
all_user_weight
;
auto
max_user_use_in_window
=
(
uint128_t
(
virtual_cpu_capacity_in_window
)
*
user_weight
)
/
all_user_weight
;
auto
cpu_used_in_window
=
(
usage
.
cpu_usage
.
value_ex
*
window_size
)
/
config
::
rate_limiting_precision
;
auto
cpu_used_in_window
=
(
usage
.
cpu_usage
.
value_ex
*
window_size
)
/
config
::
rate_limiting_precision
;
...
@@ -460,9 +457,8 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const
...
@@ -460,9 +457,8 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const
const
auto
&
state
=
_db
.
get
<
resource_limits_state_object
>
();
const
auto
&
state
=
_db
.
get
<
resource_limits_state_object
>
();
const
auto
&
usage
=
_db
.
get
<
resource_usage_object
,
by_owner
>
(
name
);
const
auto
&
usage
=
_db
.
get
<
resource_usage_object
,
by_owner
>
(
name
);
int64_t
x
;
int64_t
net_weight
,
x
,
y
;
int64_t
net_weight
;
get_account_limits
(
name
,
x
,
net_weight
,
y
);
get_account_limits
(
name
,
x
,
net_weight
,
x
);
if
(
net_weight
<
0
||
state
.
total_net_weight
==
0
)
{
if
(
net_weight
<
0
||
state
.
total_net_weight
==
0
)
{
return
{
-
1
,
-
1
,
-
1
};
return
{
-
1
,
-
1
,
-
1
};
...
...
plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp
浏览文件 @
38eb6298
...
@@ -73,7 +73,7 @@ struct txn_test_gen_plugin_impl {
...
@@ -73,7 +73,7 @@ struct txn_test_gen_plugin_impl {
void
create_test_accounts
(
const
std
::
string
&
init_name
,
const
std
::
string
&
init_priv_key
)
{
void
create_test_accounts
(
const
std
::
string
&
init_name
,
const
std
::
string
&
init_priv_key
)
{
name
newaccountA
(
"txn.test.a"
);
name
newaccountA
(
"txn.test.a"
);
name
newaccountB
(
"txn.test.b"
);
name
newaccountB
(
"txn.test.b"
);
name
newaccountC
(
"
eosio.token
"
);
name
newaccountC
(
"
txn.test.t
"
);
name
creator
(
init_name
);
name
creator
(
init_name
);
abi_def
currency_abi_def
=
fc
::
json
::
from_string
(
eosio_token_abi
).
as
<
abi_def
>
();
abi_def
currency_abi_def
=
fc
::
json
::
from_string
(
eosio_token_abi
).
as
<
abi_def
>
();
...
@@ -109,7 +109,7 @@ struct txn_test_gen_plugin_impl {
...
@@ -109,7 +109,7 @@ struct txn_test_gen_plugin_impl {
trx
.
actions
.
emplace_back
(
vector
<
chain
::
permission_level
>
{{
creator
,
"active"
}},
newaccount
{
creator
,
newaccountB
,
owner_auth
,
active_auth
});
trx
.
actions
.
emplace_back
(
vector
<
chain
::
permission_level
>
{{
creator
,
"active"
}},
newaccount
{
creator
,
newaccountB
,
owner_auth
,
active_auth
});
}
}
//create "
eosio.token
" account
//create "
txn.test.t
" account
{
{
auto
owner_auth
=
eosio
::
chain
::
authority
{
1
,
{{
txn_text_receiver_C_pub_key
,
1
}},
{}};
auto
owner_auth
=
eosio
::
chain
::
authority
{
1
,
{{
txn_text_receiver_C_pub_key
,
1
}},
{}};
auto
active_auth
=
eosio
::
chain
::
authority
{
1
,
{{
txn_text_receiver_C_pub_key
,
1
}},
{}};
auto
active_auth
=
eosio
::
chain
::
authority
{
1
,
{{
txn_text_receiver_C_pub_key
,
1
}},
{}};
...
@@ -123,7 +123,7 @@ struct txn_test_gen_plugin_impl {
...
@@ -123,7 +123,7 @@ struct txn_test_gen_plugin_impl {
push_transaction
(
trx
);
push_transaction
(
trx
);
}
}
//set
eosio.token contract
& initialize it
//set
txn.test.t contract to eosio.token
& initialize it
{
{
signed_transaction
trx
;
signed_transaction
trx
;
...
@@ -144,34 +144,34 @@ struct txn_test_gen_plugin_impl {
...
@@ -144,34 +144,34 @@ struct txn_test_gen_plugin_impl {
{
{
action
act
;
action
act
;
act
.
account
=
N
(
eosio
.
token
);
act
.
account
=
N
(
txn
.
test
.
t
);
act
.
name
=
N
(
create
);
act
.
name
=
N
(
create
);
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"create"
,
fc
::
json
::
from_string
(
"{
\"
issuer
\"
:
\"
eosio.token
\"
,
\"
maximum_supply
\"
:
\"
1000000000.0000 CUR
\"
}}"
));
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"create"
,
fc
::
json
::
from_string
(
"{
\"
issuer
\"
:
\"
txn.test.t
\"
,
\"
maximum_supply
\"
:
\"
1000000000.0000 CUR
\"
}}"
));
trx
.
actions
.
push_back
(
act
);
trx
.
actions
.
push_back
(
act
);
}
}
{
{
action
act
;
action
act
;
act
.
account
=
N
(
eosio
.
token
);
act
.
account
=
N
(
txn
.
test
.
t
);
act
.
name
=
N
(
issue
);
act
.
name
=
N
(
issue
);
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"issue"
,
fc
::
json
::
from_string
(
"{
\"
to
\"
:
\"
eosio.token
\"
,
\"
quantity
\"
:
\"
600.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"issue"
,
fc
::
json
::
from_string
(
"{
\"
to
\"
:
\"
txn.test.t
\"
,
\"
quantity
\"
:
\"
600.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
trx
.
actions
.
push_back
(
act
);
trx
.
actions
.
push_back
(
act
);
}
}
{
{
action
act
;
action
act
;
act
.
account
=
N
(
eosio
.
token
);
act
.
account
=
N
(
txn
.
test
.
t
);
act
.
name
=
N
(
transfer
);
act
.
name
=
N
(
transfer
);
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
"{
\"
from
\"
:
\"
eosio.token
\"
,
\"
to
\"
:
\"
txn.test.a
\"
,
\"
quantity
\"
:
\"
200.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
"{
\"
from
\"
:
\"
txn.test.t
\"
,
\"
to
\"
:
\"
txn.test.a
\"
,
\"
quantity
\"
:
\"
200.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
trx
.
actions
.
push_back
(
act
);
trx
.
actions
.
push_back
(
act
);
}
}
{
{
action
act
;
action
act
;
act
.
account
=
N
(
eosio
.
token
);
act
.
account
=
N
(
txn
.
test
.
t
);
act
.
name
=
N
(
transfer
);
act
.
name
=
N
(
transfer
);
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
authorization
=
vector
<
permission_level
>
{{
newaccountC
,
config
::
active_name
}};
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
"{
\"
from
\"
:
\"
eosio.token
\"
,
\"
to
\"
:
\"
txn.test.b
\"
,
\"
quantity
\"
:
\"
200.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
act
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
"{
\"
from
\"
:
\"
txn.test.t
\"
,
\"
to
\"
:
\"
txn.test.b
\"
,
\"
quantity
\"
:
\"
200.0000 CUR
\"
,
\"
memo
\"
:
\"\"
}"
));
trx
.
actions
.
push_back
(
act
);
trx
.
actions
.
push_back
(
act
);
}
}
...
@@ -196,12 +196,12 @@ struct txn_test_gen_plugin_impl {
...
@@ -196,12 +196,12 @@ struct txn_test_gen_plugin_impl {
running
=
true
;
running
=
true
;
//create the actions here
//create the actions here
act_a_to_b
.
account
=
N
(
eosio
.
token
);
act_a_to_b
.
account
=
N
(
txn
.
test
.
t
);
act_a_to_b
.
name
=
N
(
transfer
);
act_a_to_b
.
name
=
N
(
transfer
);
act_a_to_b
.
authorization
=
vector
<
permission_level
>
{{
name
(
"txn.test.a"
),
config
::
active_name
}};
act_a_to_b
.
authorization
=
vector
<
permission_level
>
{{
name
(
"txn.test.a"
),
config
::
active_name
}};
act_a_to_b
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
fc
::
format_string
(
"{
\"
from
\"
:
\"
txn.test.a
\"
,
\"
to
\"
:
\"
txn.test.b
\"
,
\"
quantity
\"
:
\"
1.0000 CUR
\"
,
\"
memo
\"
:
\"
${l}
\"
}"
,
fc
::
mutable_variant_object
()(
"l"
,
salt
))));
act_a_to_b
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
fc
::
format_string
(
"{
\"
from
\"
:
\"
txn.test.a
\"
,
\"
to
\"
:
\"
txn.test.b
\"
,
\"
quantity
\"
:
\"
1.0000 CUR
\"
,
\"
memo
\"
:
\"
${l}
\"
}"
,
fc
::
mutable_variant_object
()(
"l"
,
salt
))));
act_b_to_a
.
account
=
N
(
eosio
.
token
);
act_b_to_a
.
account
=
N
(
txn
.
test
.
t
);
act_b_to_a
.
name
=
N
(
transfer
);
act_b_to_a
.
name
=
N
(
transfer
);
act_b_to_a
.
authorization
=
vector
<
permission_level
>
{{
name
(
"txn.test.b"
),
config
::
active_name
}};
act_b_to_a
.
authorization
=
vector
<
permission_level
>
{{
name
(
"txn.test.b"
),
config
::
active_name
}};
act_b_to_a
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
fc
::
format_string
(
"{
\"
from
\"
:
\"
txn.test.b
\"
,
\"
to
\"
:
\"
txn.test.a
\"
,
\"
quantity
\"
:
\"
1.0000 CUR
\"
,
\"
memo
\"
:
\"
${l}
\"
}"
,
fc
::
mutable_variant_object
()(
"l"
,
salt
))));
act_b_to_a
.
data
=
eosio_token_serializer
.
variant_to_binary
(
"transfer"
,
fc
::
json
::
from_string
(
fc
::
format_string
(
"{
\"
from
\"
:
\"
txn.test.b
\"
,
\"
to
\"
:
\"
txn.test.a
\"
,
\"
quantity
\"
:
\"
1.0000 CUR
\"
,
\"
memo
\"
:
\"
${l}
\"
}"
,
fc
::
mutable_variant_object
()(
"l"
,
salt
))));
...
...
tutorials/bios-boot-tutorial/bios-boot-tutorial.py
浏览文件 @
38eb6298
#!/usr/bin/env python3
#!/usr/bin/env python3
import
argparse
import
json
import
json
import
numpy
import
numpy
import
os
import
os
...
@@ -14,14 +15,14 @@ walletDir = os.path.abspath('./wallet/')
...
@@ -14,14 +15,14 @@ walletDir = os.path.abspath('./wallet/')
unlockTimeout
=
99999999999
unlockTimeout
=
99999999999
nodesDir
=
'./nodes/'
nodesDir
=
'./nodes/'
contractsDir
=
'../../build/contracts/'
contractsDir
=
'../../build/contracts/'
cleos
=
'cleos --wallet-url http://localhost:6666
--url http://localhost:8000
'
cleos
=
'cleos --wallet-url http://localhost:6666 '
nodeos
=
'nodeos'
nodeos
=
'nodeos'
fastUnstakeSystem
=
'./fast.refund/eosio.system/eosio.system.wasm'
fastUnstakeSystem
=
'./fast.refund/eosio.system/eosio.system.wasm'
logFile
=
open
(
'test.log'
,
'a'
)
logFile
=
open
(
'test.log'
,
'a'
)
symbol
=
'SYS'
symbol
=
'SYS'
maxUserKeys
=
10
# Maximum user keys to import into wallet
maxUserKeys
=
10
# Maximum user keys to import into wallet
minProducerStake
=
20
.0000
# Minimum producer CPU and BW stake
minProducerStake
=
20
0.0000
# Minimum producer CPU and BW stake
extraIssue
=
10.0000
# Extra amount to issue to cover buying ram
extraIssue
=
10.0000
# Extra amount to issue to cover buying ram
limitUsers
=
0
# Limit number of users if >0
limitUsers
=
0
# Limit number of users if >0
limitProducers
=
0
# Limit number of producers if >0
limitProducers
=
0
# Limit number of producers if >0
...
@@ -60,15 +61,15 @@ def jsonArg(a):
...
@@ -60,15 +61,15 @@ def jsonArg(a):
return
" '"
+
json
.
dumps
(
a
)
+
"' "
return
" '"
+
json
.
dumps
(
a
)
+
"' "
def
run
(
args
):
def
run
(
args
):
print
(
'
test
.py:'
,
args
)
print
(
'
bios-boot-tutorial
.py:'
,
args
)
logFile
.
write
(
args
+
'
\n
'
)
logFile
.
write
(
args
+
'
\n
'
)
if
subprocess
.
call
(
args
,
shell
=
True
):
if
subprocess
.
call
(
args
,
shell
=
True
):
print
(
'
test
.py: exiting because of error'
)
print
(
'
bios-boot-tutorial
.py: exiting because of error'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
retry
(
args
):
def
retry
(
args
):
while
True
:
while
True
:
print
(
'
test
.py:'
,
args
)
print
(
'
bios-boot-tutorial
.py:'
,
args
)
logFile
.
write
(
args
+
'
\n
'
)
logFile
.
write
(
args
+
'
\n
'
)
if
subprocess
.
call
(
args
,
shell
=
True
):
if
subprocess
.
call
(
args
,
shell
=
True
):
print
(
'*** Retry'
)
print
(
'*** Retry'
)
...
@@ -76,18 +77,18 @@ def retry(args):
...
@@ -76,18 +77,18 @@ def retry(args):
break
break
def
background
(
args
):
def
background
(
args
):
print
(
'
test
.py:'
,
args
)
print
(
'
bios-boot-tutorial
.py:'
,
args
)
logFile
.
write
(
args
+
'
\n
'
)
logFile
.
write
(
args
+
'
\n
'
)
return
subprocess
.
Popen
(
args
,
shell
=
True
)
return
subprocess
.
Popen
(
args
,
shell
=
True
)
def
getOutput
(
args
):
def
getOutput
(
args
):
print
(
'
test
.py:'
,
args
)
print
(
'
bios-boot-tutorial
.py:'
,
args
)
logFile
.
write
(
args
+
'
\n
'
)
logFile
.
write
(
args
+
'
\n
'
)
proc
=
subprocess
.
Popen
(
args
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
proc
=
subprocess
.
Popen
(
args
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
return
proc
.
communicate
()[
0
].
decode
(
'utf-8'
)
return
proc
.
communicate
()[
0
].
decode
(
'utf-8'
)
def
getJsonOutput
(
args
):
def
getJsonOutput
(
args
):
print
(
'
test
.py:'
,
args
)
print
(
'
bios-boot-tutorial
.py:'
,
args
)
logFile
.
write
(
args
+
'
\n
'
)
logFile
.
write
(
args
+
'
\n
'
)
proc
=
subprocess
.
Popen
(
args
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
proc
=
subprocess
.
Popen
(
args
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
return
json
.
loads
(
proc
.
communicate
()[
0
])
return
json
.
loads
(
proc
.
communicate
()[
0
])
...
@@ -201,9 +202,11 @@ def vote(b, e):
...
@@ -201,9 +202,11 @@ def vote(b, e):
def
claimRewards
():
def
claimRewards
():
table
=
getJsonOutput
(
cleos
+
'get table eosio eosio producers -l 100'
)
table
=
getJsonOutput
(
cleos
+
'get table eosio eosio producers -l 100'
)
times
=
[]
for
row
in
table
[
'rows'
]:
for
row
in
table
[
'rows'
]:
if
row
[
'unpaid_blocks'
]
and
not
row
[
'last_claim_time'
]:
if
row
[
'unpaid_blocks'
]
and
not
row
[
'last_claim_time'
]:
run
(
cleos
+
'system claimrewards '
+
row
[
'owner'
])
times
.
append
(
getJsonOutput
(
cleos
+
'system claimrewards -j '
+
row
[
'owner'
])[
'processed'
][
'elapsed'
])
print
(
'Elapsed time for claimrewards:'
,
times
)
def
vote
(
b
,
e
):
def
vote
(
b
,
e
):
for
i
in
range
(
b
,
e
):
for
i
in
range
(
b
,
e
):
...
@@ -246,15 +249,13 @@ def sendUnstakedFunds(b, e):
...
@@ -246,15 +249,13 @@ def sendUnstakedFunds(b, e):
a
=
accounts
[
i
]
a
=
accounts
[
i
]
run
(
cleos
+
'transfer eosio '
+
a
[
'name'
]
+
' "10.0000 '
+
symbol
+
'"'
)
run
(
cleos
+
'transfer eosio '
+
a
[
'name'
]
+
' "10.0000 '
+
symbol
+
'"'
)
def
randomTransfer
(
b
,
e
,
n
):
def
randomTransfer
(
b
,
e
):
for
i
in
range
(
n
):
for
j
in
range
(
20
):
for
j
in
range
(
20
):
src
=
accounts
[
random
.
randint
(
b
,
e
-
1
)][
'name'
]
src
=
accounts
[
random
.
randint
(
b
,
e
-
1
)][
'name'
]
dest
=
src
dest
=
src
while
dest
==
src
:
while
dest
==
src
:
dest
=
accounts
[
random
.
randint
(
b
,
e
-
1
)][
'name'
]
dest
=
accounts
[
random
.
randint
(
b
,
e
-
1
)][
'name'
]
run
(
cleos
+
'transfer -f '
+
src
+
' '
+
dest
+
' "0.0001 '
+
symbol
+
'"'
+
' || true'
)
run
(
cleos
+
'transfer -f '
+
src
+
' '
+
dest
+
' "0.0001 '
+
symbol
+
'"'
+
' || true'
)
sleep
(.
25
)
def
msigProposeReplaceSystem
(
proposer
,
proposalName
):
def
msigProposeReplaceSystem
(
proposer
,
proposalName
):
requestedPermissions
=
[]
requestedPermissions
=
[]
...
@@ -295,39 +296,98 @@ def produceNewAccounts():
...
@@ -295,39 +296,98 @@ def produceNewAccounts():
f
.
write
(
' {"name":"%s", "pvt":"%s", "pub":"%s"},
\n
'
%
(
name
,
r
[
1
],
r
[
2
]))
f
.
write
(
' {"name":"%s", "pvt":"%s", "pub":"%s"},
\n
'
%
(
name
,
r
[
1
],
r
[
2
]))
logFile
.
write
(
'
\n\n
'
+
'*'
*
80
+
'
\n\n\n
'
)
logFile
.
write
(
'
\n\n
'
+
'*'
*
80
+
'
\n\n\n
'
)
run
(
'killall keosd nodeos || true'
)
sleep
(
1.5
)
def
stepKillAll
():
startWallet
()
run
(
'killall keosd nodeos || true'
)
importKeys
()
sleep
(
1.5
)
startNode
(
0
,
{
'name'
:
'eosio'
,
'pvt'
:
eosioPvt
,
'pub'
:
eosioPub
})
def
stepStartWallet
():
sleep
(
1.5
)
startWallet
()
createSystemAccounts
()
importKeys
()
run
(
cleos
+
'set contract eosio.token '
+
contractsDir
+
'eosio.token/'
)
def
stepStartBoot
():
run
(
cleos
+
'set contract eosio.msig '
+
contractsDir
+
'eosio.msig/'
)
startNode
(
0
,
{
'name'
:
'eosio'
,
'pvt'
:
eosioPvt
,
'pub'
:
eosioPub
})
run
(
cleos
+
'push action eosio.token create
\'
["eosio", "10000000000.0000 %s"]
\'
-p eosio.token'
%
(
symbol
))
sleep
(
1.5
)
totalAllocation
=
fillStake
(
0
,
len
(
accounts
))
def
stepInstallSystemContracts
():
run
(
cleos
+
'push action eosio.token issue
\'
["eosio", "%s", "memo"]
\'
-p eosio'
%
intToCurrency
(
totalAllocation
))
run
(
cleos
+
'set contract eosio.token '
+
contractsDir
+
'eosio.token/'
)
sleep
(
1
)
run
(
cleos
+
'set contract eosio.msig '
+
contractsDir
+
'eosio.msig/'
)
retry
(
cleos
+
'set contract eosio '
+
contractsDir
+
'eosio.system/'
)
def
stepCreateTokens
():
sleep
(
1
)
run
(
cleos
+
'push action eosio.token create
\'
["eosio", "10000000000.0000 %s"]
\'
-p eosio.token'
%
(
symbol
))
run
(
cleos
+
'push action eosio setpriv'
+
jsonArg
([
'eosio.msig'
,
1
])
+
'-p eosio@active'
)
totalAllocation
=
fillStake
(
0
,
len
(
accounts
))
createStakedAccounts
(
0
,
len
(
accounts
))
run
(
cleos
+
'push action eosio.token issue
\'
["eosio", "%s", "memo"]
\'
-p eosio'
%
intToCurrency
(
totalAllocation
))
regProducers
(
firstProducer
,
firstProducer
+
numProducers
)
sleep
(
1
)
sleep
(
1
)
def
stepSetSystemContract
():
listProducers
()
retry
(
cleos
+
'set contract eosio '
+
contractsDir
+
'eosio.system/'
)
startProducers
(
firstProducer
,
firstProducer
+
numProducers
)
sleep
(
1
)
sleep
(
producerSyncDelay
)
run
(
cleos
+
'push action eosio setpriv'
+
jsonArg
([
'eosio.msig'
,
1
])
+
'-p eosio@active'
)
vote
(
0
,
0
+
numVoters
)
def
stepCreateStakedAccounts
():
sleep
(
1
)
createStakedAccounts
(
0
,
len
(
accounts
))
listProducers
()
def
stepRegProducers
():
sleep
(
5
)
regProducers
(
firstProducer
,
firstProducer
+
numProducers
)
claimRewards
()
sleep
(
1
)
proxyVotes
(
0
,
0
+
numVoters
)
listProducers
()
resign
(
'eosio'
,
'eosio.prods'
)
def
stepStartProducers
():
for
a
in
systemAccounts
:
startProducers
(
firstProducer
,
firstProducer
+
numProducers
)
sleep
(
producerSyncDelay
)
def
stepVote
():
vote
(
0
,
0
+
numVoters
)
sleep
(
1
)
listProducers
()
sleep
(
5
)
def
stepProxyVotes
():
proxyVotes
(
0
,
0
+
numVoters
)
def
stepResign
():
resign
(
'eosio'
,
'eosio.prods'
)
for
a
in
systemAccounts
:
resign
(
a
,
'eosio'
)
resign
(
a
,
'eosio'
)
# msigReplaceSystem()
def
stepIssueUnstaked
():
run
(
cleos
+
'push action eosio.token issue
\'
["eosio", "%d.0000 %s", "memo"]
\'
-p eosio'
%
((
len
(
accounts
))
*
10
,
symbol
))
run
(
cleos
+
'push action eosio.token issue
\'
["eosio", "%d.0000 %s", "memo"]
\'
-p eosio'
%
((
len
(
accounts
))
*
10
,
symbol
))
sendUnstakedFunds
(
0
,
numSenders
)
sendUnstakedFunds
(
0
,
numSenders
)
randomTransfer
(
0
,
numSenders
,
8
)
def
stepTransfer
():
run
(
'tail -n 60 '
+
nodesDir
+
'00-eosio/stderr'
)
while
True
:
randomTransfer
(
0
,
numSenders
)
def
stepLog
():
run
(
'tail -n 60 '
+
nodesDir
+
'00-eosio/stderr'
)
commands
=
[
(
'k'
,
'kill'
,
stepKillAll
,
True
,
"Kill all nodeos and keosd processes"
),
(
'w'
,
'wallet'
,
stepStartWallet
,
True
,
"Start keosd, create wallet, fill with keys"
),
(
'b'
,
'boot'
,
stepStartBoot
,
True
,
"Start boot node"
),
(
's'
,
'sys'
,
createSystemAccounts
,
True
,
"Create system accounts (eosio.*)"
),
(
'c'
,
'contracts'
,
stepInstallSystemContracts
,
True
,
"Install system contracts (token, msig)"
),
(
't'
,
'tokens'
,
stepCreateTokens
,
True
,
"Create tokens"
),
(
'S'
,
'sys-contract'
,
stepSetSystemContract
,
True
,
"Set system contract"
),
(
'T'
,
'stake'
,
stepCreateStakedAccounts
,
True
,
"Create staked accounts"
),
(
'p'
,
'reg-prod'
,
stepRegProducers
,
True
,
"Register producers"
),
(
'P'
,
'start-prod'
,
stepStartProducers
,
True
,
"Start producers"
),
(
'v'
,
'vote'
,
stepVote
,
True
,
"Vote for producers"
),
(
'R'
,
'claim'
,
claimRewards
,
True
,
"Claim rewards"
),
(
'x'
,
'proxy'
,
stepProxyVotes
,
True
,
"Proxy votes"
),
(
'q'
,
'resign'
,
stepResign
,
True
,
"Resign eosio"
),
(
'm'
,
'msg-replace'
,
msigReplaceSystem
,
False
,
"Replace system contract using msig"
),
(
'u'
,
'issue'
,
stepIssueUnstaked
,
True
,
"Issue unstaked tokens"
),
(
'X'
,
'xfer'
,
stepTransfer
,
False
,
"Random transfer tokens (infinite loop)"
),
(
'l'
,
'log'
,
stepLog
,
True
,
"Show tail of node's log"
),
]
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-a'
,
'--all'
,
action
=
'store_true'
,
help
=
"Do everything marked with (*)"
)
parser
.
add_argument
(
'-H'
,
'--http-port'
,
type
=
int
,
default
=
8000
,
help
=
'Http port for cleos'
)
for
(
flag
,
command
,
function
,
inAll
,
help
)
in
commands
:
prefix
=
''
if
inAll
:
prefix
+=
'*'
if
prefix
:
help
=
'('
+
prefix
+
') '
+
help
if
flag
:
parser
.
add_argument
(
'-'
+
flag
,
'--'
+
command
,
action
=
'store_true'
,
help
=
help
,
dest
=
command
)
else
:
parser
.
add_argument
(
'--'
+
command
,
action
=
'store_true'
,
help
=
help
,
dest
=
command
)
args
=
parser
.
parse_args
()
cleos
+=
'--url http://localhost:%d '
%
args
.
http_port
haveCommand
=
False
for
(
flag
,
command
,
function
,
inAll
,
help
)
in
commands
:
if
getattr
(
args
,
command
)
or
inAll
and
args
.
all
:
if
function
:
haveCommand
=
True
function
()
if
not
haveCommand
:
print
(
'bios-boot-tutorial.py: Tell me what to do. -a does almost everything. -h shows options.'
)
unittests/eosio.system_tests.cpp
浏览文件 @
38eb6298
...
@@ -46,8 +46,8 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {
...
@@ -46,8 +46,8 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {
transfer
(
"eosio"
,
"alice1111111"
,
core_from_string
(
"100000000.0000"
),
"eosio"
);
transfer
(
"eosio"
,
"alice1111111"
,
core_from_string
(
"100000000.0000"
),
"eosio"
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"100000998.0050"
),
get_balance
(
"alice1111111"
)
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"100000998.0050"
),
get_balance
(
"alice1111111"
)
);
// alice buys ram for 10000000.0000, 0.5% = 50000.0000 go
t
to ramfee
// alice buys ram for 10000000.0000, 0.5% = 50000.0000 go to ramfee
// after fee 9950000.0000 go
t
to bought bytes
// after fee 9950000.0000 go to bought bytes
// when selling back bought bytes, pay 0.5% fee and get back 99.5% of 9950000.0000 = 9900250.0000
// when selling back bought bytes, pay 0.5% fee and get back 99.5% of 9950000.0000 = 9900250.0000
// expected account after that is 90000998.0050 + 9900250.0000 = 99901248.0050 with a difference
// expected account after that is 90000998.0050 + 9900250.0000 = 99901248.0050 with a difference
// of order 0.0001 due to rounding errors
// of order 0.0001 due to rounding errors
...
@@ -1298,7 +1298,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
...
@@ -1298,7 +1298,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const
double
usecs_per_year
=
secs_per_year
*
1000000
;
const
double
usecs_per_year
=
secs_per_year
*
1000000
;
const
double
cont_rate
=
4.879
/
100.
;
const
double
cont_rate
=
4.879
/
100.
;
const
asset
net
=
core_from_string
(
"80.0000"
);
const
asset
net
=
core_from_string
(
"80.0000"
);
const
asset
cpu
=
core_from_string
(
"80.0000"
);
const
asset
cpu
=
core_from_string
(
"80.0000"
);
create_account_with_resources
(
N
(
producvotera
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
net
,
cpu
);
create_account_with_resources
(
N
(
producvotera
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
net
,
cpu
);
...
@@ -1549,7 +1548,14 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
...
@@ -1549,7 +1548,14 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
// wait two more hours, now most producers haven't produced in a day and will
// wait two more hours, now most producers haven't produced in a day and will
// be deactivated
// be deactivated
produce_block
(
fc
::
seconds
(
2
*
3600
));
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvotera
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvotera"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
(
producer_names
.
begin
(),
producer_names
.
begin
()
+
21
))
)
);
produce_block
(
fc
::
hours
(
9
));
produce_blocks
(
8
*
21
*
12
);
produce_blocks
(
8
*
21
*
12
);
{
{
...
@@ -1706,8 +1712,6 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try {
...
@@ -1706,8 +1712,6 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try {
create_account_with_resources
(
N
(
producvoterb
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
large_asset
,
large_asset
);
create_account_with_resources
(
N
(
producvoterb
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
large_asset
,
large_asset
);
create_account_with_resources
(
N
(
producvoterc
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
large_asset
,
large_asset
);
create_account_with_resources
(
N
(
producvoterc
),
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
large_asset
,
large_asset
);
// create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers
// create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers
std
::
vector
<
account_name
>
producer_names
;
std
::
vector
<
account_name
>
producer_names
;
producer_names
.
reserve
(
'z'
-
'a'
+
1
);
producer_names
.
reserve
(
'z'
-
'a'
+
1
);
...
@@ -2284,7 +2288,7 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
...
@@ -2284,7 +2288,7 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
produce_block
(
fc
::
days
(
14
)
);
produce_block
(
fc
::
days
(
14
)
);
produce_block
();
produce_block
();
// highest bid is from david for prefd but no
t
bids can be closed yet
// highest bid is from david for prefd but no bids can be closed yet
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
prefd
),
N
(
david
)
),
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
prefd
),
N
(
david
)
),
fc
::
exception
,
fc_assert_exception_message_is
(
not_closed_message
)
);
fc
::
exception
,
fc_assert_exception_message_is
(
not_closed_message
)
);
...
@@ -2360,6 +2364,110 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
...
@@ -2360,6 +2364,110 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
}
FC_LOG_AND_RETHROW
()
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
vote_producers_in_and_out
,
eosio_system_tester
)
try
{
const
asset
net
=
core_from_string
(
"80.0000"
);
const
asset
cpu
=
core_from_string
(
"80.0000"
);
std
::
vector
<
account_name
>
voters
=
{
N
(
producvotera
),
N
(
producvoterb
),
N
(
producvoterc
),
N
(
producvoterd
)
};
for
(
const
auto
&
v
:
voters
)
{
create_account_with_resources
(
v
,
config
::
system_account_name
,
core_from_string
(
"1.0000"
),
false
,
net
,
cpu
);
}
// create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers
std
::
vector
<
account_name
>
producer_names
;
{
producer_names
.
reserve
(
'z'
-
'a'
+
1
);
const
std
::
string
root
(
"defproducer"
);
for
(
char
c
=
'a'
;
c
<=
'z'
;
++
c
)
{
producer_names
.
emplace_back
(
root
+
std
::
string
(
1
,
c
));
}
setup_producer_accounts
(
producer_names
);
for
(
const
auto
&
p
:
producer_names
)
{
BOOST_REQUIRE_EQUAL
(
success
(),
regproducer
(
p
)
);
produce_blocks
(
1
);
ilog
(
"------ get pro----------"
);
wdump
((
p
));
BOOST_TEST
(
0
==
get_producer_info
(
p
)[
"total_votes"
].
as
<
double
>
());
}
}
for
(
const
auto
&
v
:
voters
)
{
transfer
(
config
::
system_account_name
,
v
,
core_from_string
(
"200000000.0000"
),
config
::
system_account_name
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
v
,
core_from_string
(
"30000000.0000"
),
core_from_string
(
"30000000.0000"
))
);
}
{
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvotera
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvotera"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
(
producer_names
.
begin
(),
producer_names
.
begin
()
+
20
))
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvoterb
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvoterb"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
(
producer_names
.
begin
(),
producer_names
.
begin
()
+
21
))
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvoterc
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvoterc"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
(
producer_names
.
begin
(),
producer_names
.
end
()))
)
);
}
// give a chance for everyone to produce blocks
{
produce_blocks
(
23
*
12
+
20
);
bool
all_21_produced
=
true
;
for
(
uint32_t
i
=
0
;
i
<
21
;
++
i
)
{
if
(
0
==
get_producer_info
(
producer_names
[
i
])[
"unpaid_blocks"
].
as
<
uint32_t
>
())
{
all_21_produced
=
false
;
}
}
bool
rest_didnt_produce
=
true
;
for
(
uint32_t
i
=
21
;
i
<
producer_names
.
size
();
++
i
)
{
if
(
0
<
get_producer_info
(
producer_names
[
i
])[
"unpaid_blocks"
].
as
<
uint32_t
>
())
{
rest_didnt_produce
=
false
;
}
}
BOOST_REQUIRE
(
all_21_produced
&&
rest_didnt_produce
);
}
{
produce_block
(
fc
::
hours
(
7
));
const
uint32_t
voted_out_index
=
20
;
const
uint32_t
new_prod_index
=
23
;
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"producvoterd"
,
core_from_string
(
"40000000.0000"
),
core_from_string
(
"40000000.0000"
)));
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvoterd
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvoterd"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
{
producer_names
[
new_prod_index
]
})
)
);
BOOST_REQUIRE_EQUAL
(
0
,
get_producer_info
(
producer_names
[
new_prod_index
])[
"unpaid_blocks"
].
as
<
uint32_t
>
());
produce_blocks
(
4
*
12
*
21
);
BOOST_REQUIRE
(
0
<
get_producer_info
(
producer_names
[
new_prod_index
])[
"unpaid_blocks"
]);
const
uint32_t
initial_unpaid_blocks
=
get_producer_info
(
producer_names
[
voted_out_index
])[
"unpaid_blocks"
].
as
<
uint32_t
>
();
produce_blocks
(
2
*
12
*
21
);
BOOST_REQUIRE_EQUAL
(
initial_unpaid_blocks
,
get_producer_info
(
producer_names
[
voted_out_index
])[
"unpaid_blocks"
].
as
<
uint32_t
>
());
produce_block
(
fc
::
hours
(
24
));
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
N
(
producvoterd
),
N
(
voteproducer
),
mvo
()
(
"voter"
,
"producvoterd"
)
(
"proxy"
,
name
(
0
).
to_string
())
(
"producers"
,
vector
<
account_name
>
{
producer_names
[
voted_out_index
]
})
)
);
produce_blocks
(
2
*
12
*
21
);
BOOST_REQUIRE
(
fc
::
crypto
::
public_key
()
!=
fc
::
crypto
::
public_key
(
get_producer_info
(
producer_names
[
voted_out_index
])[
"producer_key"
].
as_string
()));
BOOST_REQUIRE_EQUAL
(
success
(),
push_action
(
producer_names
[
voted_out_index
],
N
(
claimrewards
),
mvo
()(
"owner"
,
producer_names
[
voted_out_index
])));
}
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
setparams
,
eosio_system_tester
)
try
{
BOOST_FIXTURE_TEST_CASE
(
setparams
,
eosio_system_tester
)
try
{
//install multisig contract
//install multisig contract
abi_serializer
msig_abi_ser
=
initialize_multisig
();
abi_serializer
msig_abi_ser
=
initialize_multisig
();
...
...
unittests/ram_tests.cpp
浏览文件 @
38eb6298
...
@@ -40,7 +40,7 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
...
@@ -40,7 +40,7 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
buyrambytes
(
N
(
eosio
),
N
(
eosio
),
70000
);
buyrambytes
(
N
(
eosio
),
N
(
eosio
),
70000
);
produce_blocks
(
10
);
produce_blocks
(
10
);
create_account_with_resources
(
N
(
testram11111
),
N
(
eosio
),
init_request_bytes
);
create_account_with_resources
(
N
(
testram11111
),
N
(
eosio
),
init_request_bytes
);
create_account_with_resources
(
N
(
testram22222
),
N
(
eosio
),
init_request_bytes
);
create_account_with_resources
(
N
(
testram22222
),
N
(
eosio
),
init_request_bytes
+
1150
);
produce_blocks
(
10
);
produce_blocks
(
10
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"eosio.stake"
,
"testram11111"
,
core_from_string
(
"10.0000"
),
core_from_string
(
"5.0000"
)
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"eosio.stake"
,
"testram11111"
,
core_from_string
(
"10.0000"
),
core_from_string
(
"5.0000"
)
)
);
produce_blocks
(
10
);
produce_blocks
(
10
);
...
@@ -189,7 +189,6 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
...
@@ -189,7 +189,6 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
fc_exception_message_starts_with
(
"account testram11111 has insufficient ram"
));
fc_exception_message_starts_with
(
"account testram11111 has insufficient ram"
));
produce_blocks
(
1
);
produce_blocks
(
1
);
#if 0
// verify that the new entry is under the allocation bytes limit
// verify that the new entry is under the allocation bytes limit
tester
->
push_action
(
N
(
testram11111
),
N
(
setentry
),
{
N
(
testram11111
),
N
(
testram22222
)},
mvo
()
tester
->
push_action
(
N
(
testram11111
),
N
(
setentry
),
{
N
(
testram11111
),
N
(
testram22222
)},
mvo
()
(
"payer"
,
"testram22222"
)
(
"payer"
,
"testram22222"
)
...
@@ -260,7 +259,7 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
...
@@ -260,7 +259,7 @@ BOOST_FIXTURE_TEST_CASE(ram_tests, eosio_system::eosio_system_tester) { try {
(
"to"
,
22
)
(
"to"
,
22
)
(
"size"
,
1910
));
(
"size"
,
1910
));
produce_blocks
(
1
);
produce_blocks
(
1
);
#endif
}
FC_LOG_AND_RETHROW
()
}
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录