Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
ba4e98fb
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,发现更多精彩内容 >>
提交
ba4e98fb
编写于
5月 10, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'system-contract-tests-fix' of github.com:EOSIO/eos into system-contract-tests-fix
上级
1d23690d
59ea9da3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
8 deletion
+75
-8
contracts/eosio.system/delegate_bandwidth.cpp
contracts/eosio.system/delegate_bandwidth.cpp
+1
-1
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
+1
-1
libraries/chain/transaction_context.cpp
libraries/chain/transaction_context.cpp
+0
-1
programs/cleos/main.cpp
programs/cleos/main.cpp
+23
-3
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+49
-1
未找到文件。
contracts/eosio.system/delegate_bandwidth.cpp
浏览文件 @
ba4e98fb
...
...
@@ -182,7 +182,7 @@ namespace eosiosystem {
* refunds the purchase price to the account. In this way there is no profit to be made through buying
* and selling ram.
*/
void
system_contract
::
sellram
(
account_name
account
,
uint
32
_t
bytes
)
{
void
system_contract
::
sellram
(
account_name
account
,
uint
64
_t
bytes
)
{
require_auth
(
account
);
user_resources_table
userres
(
_self
,
account
);
...
...
contracts/eosio.system/eosio.system.abi
浏览文件 @
ba4e98fb
...
...
@@ -13,7 +13,7 @@
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"bytes", "type":"uint
32
"}
{"name":"bytes", "type":"uint
64
"}
]
},{
"name": "buyram",
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
ba4e98fb
...
...
@@ -171,7 +171,7 @@ namespace eosiosystem {
* Reduces quota my bytes and then performs an inline transfer of tokens
* to receiver based upon the average purchase price of the original quota.
*/
void
sellram
(
account_name
receiver
,
uint
32
_t
bytes
);
void
sellram
(
account_name
receiver
,
uint
64
_t
bytes
);
/**
* This action is called after the delegation-period to claim all pending
...
...
libraries/chain/transaction_context.cpp
浏览文件 @
ba4e98fb
...
...
@@ -61,7 +61,6 @@ namespace eosio { namespace chain {
uint64_t
block_cpu_limit
=
rl
.
get_block_cpu_limit
();
if
(
!
billed_cpu_time_us
)
{
wdump
((
block_cpu_limit
));
auto
potential_deadline
=
fc
::
time_point
::
now
()
+
fc
::
microseconds
(
block_cpu_limit
);
if
(
potential_deadline
<
deadline
)
deadline
=
potential_deadline
;
}
...
...
programs/cleos/main.cpp
浏览文件 @
ba4e98fb
...
...
@@ -331,10 +331,30 @@ void print_result( const fc::variant& result ) { try {
const
auto
&
processed
=
result
[
"processed"
];
const
auto
&
transaction_id
=
processed
[
"id"
].
as_string
();
string
status
=
processed
[
"receipt"
].
is_object
()
?
processed
[
"receipt"
][
"status"
].
as_string
()
:
"failed"
;
auto
net
=
processed
[
"net_usage"
].
as_int64
()
*
8
;
auto
cpu
=
processed
[
"cpu_usage"
].
as_int64
()
/
1024
;
int64_t
net
=
-
1
;
int64_t
cpu
=
-
1
;
if
(
processed
.
get_object
().
contains
(
"receipt"
))
{
const
auto
&
receipt
=
processed
[
"receipt"
];
if
(
receipt
.
is_object
())
{
net
=
receipt
[
"net_usage_words"
].
as_int64
()
*
8
;
cpu
=
receipt
[
"cpu_usage_us"
].
as_int64
();
}
}
cerr
<<
status
<<
" transaction: "
<<
transaction_id
<<
" "
;
if
(
net
<
0
)
{
cerr
<<
"<unknown>"
;
}
else
{
cerr
<<
net
;
}
cerr
<<
" bytes "
;
if
(
cpu
<
0
)
{
cerr
<<
"<unknown>"
;
}
else
{
cerr
<<
cpu
;
}
cerr
<<
status
<<
" transaction: "
<<
transaction_id
<<
" "
<<
net
<<
" bytes "
<<
cpu
<<
"k cycle
s
\n
"
;
cerr
<<
" u
s
\n
"
;
if
(
status
==
"failed"
)
{
auto
soft_except
=
processed
[
"except"
].
as
<
optional
<
fc
::
exception
>>
();
...
...
unittests/eosio.system_tests.cpp
浏览文件 @
ba4e98fb
...
...
@@ -215,7 +215,7 @@ public:
return
push_action
(
payer
,
N
(
buyrambytes
),
mvo
()(
"payer"
,
payer
)(
"receiver"
,
receiver
)(
"bytes"
,
numbytes
)
);
}
action_result
sellram
(
const
account_name
&
account
,
uint
32
_t
numbytes
)
{
action_result
sellram
(
const
account_name
&
account
,
uint
64
_t
numbytes
)
{
return
push_action
(
account
,
N
(
sellram
),
mvo
()(
"account"
,
account
)(
"bytes"
,
numbytes
)
);
}
...
...
@@ -426,6 +426,54 @@ inline uint64_t M( const string& eos_str ) {
BOOST_AUTO_TEST_SUITE
(
eosio_system_tests
)
BOOST_FIXTURE_TEST_CASE
(
buysell
,
eosio_system_tester
)
try
{
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000000000.0000 EOS"
),
get_balance
(
"eosio"
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 EOS"
),
get_balance
(
"alice"
)
);
transfer
(
"eosio"
,
"alice"
,
"1000.0000 EOS"
,
"eosio"
);
BOOST_REQUIRE_EQUAL
(
success
(),
stake
(
"eosio"
,
"alice"
,
"200.0000 EOS"
,
"100.0000 EOS"
)
);
auto
total
=
get_total_stake
(
"alice"
);
auto
init_bytes
=
total
[
"ram_bytes"
].
as_uint64
();
BOOST_REQUIRE_EQUAL
(
success
(),
buyram
(
"alice"
,
"alice"
,
"200.0000 EOS"
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"800.0000 EOS"
),
get_balance
(
"alice"
)
);
total
=
get_total_stake
(
"alice"
);
auto
bytes
=
total
[
"ram_bytes"
].
as_uint64
();
auto
bought_bytes
=
bytes
-
init_bytes
;
wdump
((
init_bytes
)(
bought_bytes
)(
bytes
)
);
BOOST_REQUIRE_EQUAL
(
true
,
0
<
bought_bytes
);
BOOST_REQUIRE_EQUAL
(
success
(),
sellram
(
"alice"
,
bought_bytes
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"999.9999 EOS"
),
get_balance
(
"alice"
)
);
total
=
get_total_stake
(
"alice"
);
BOOST_REQUIRE_EQUAL
(
true
,
total
[
"ram_bytes"
].
as_uint64
()
==
init_bytes
);
transfer
(
"eosio"
,
"alice"
,
"100000000.0000 EOS"
,
"eosio"
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100000999.9999 EOS"
),
get_balance
(
"alice"
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
buyram
(
"alice"
,
"alice"
,
"10000000.0000 EOS"
)
);
total
=
get_total_stake
(
"alice"
);
bytes
=
total
[
"ram_bytes"
].
as_uint64
();
bought_bytes
=
bytes
-
init_bytes
;
wdump
((
init_bytes
)(
bought_bytes
)(
bytes
)
);
BOOST_REQUIRE_EQUAL
(
success
(),
sellram
(
"alice"
,
bought_bytes
)
);
total
=
get_total_stake
(
"alice"
);
bytes
=
total
[
"ram_bytes"
].
as_uint64
();
bought_bytes
=
bytes
-
init_bytes
;
wdump
((
init_bytes
)(
bought_bytes
)(
bytes
)
);
BOOST_REQUIRE_EQUAL
(
true
,
total
[
"ram_bytes"
].
as_uint64
()
==
init_bytes
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100000999.9993 EOS"
),
get_balance
(
"alice"
)
);
}
FC_LOG_AND_RETHROW
()
BOOST_FIXTURE_TEST_CASE
(
stake_unstake
,
eosio_system_tester
)
try
{
//issue( "eosio", "1000.0000 EOS", config::system_account_name );
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录