Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
eee5c1da
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,发现更多精彩内容 >>
提交
eee5c1da
编写于
5月 08, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Additional tests for context free action access
上级
0dde5ef0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
2 deletion
+33
-2
contracts/test_api/test_action.cpp
contracts/test_api/test_action.cpp
+31
-0
unittests/api_tests.cpp
unittests/api_tests.cpp
+2
-2
未找到文件。
contracts/test_api/test_action.cpp
浏览文件 @
eee5c1da
...
...
@@ -101,6 +101,16 @@ void test_action::test_cf_action() {
memccpy
(
&
v
,
&
i
,
sizeof
(
i
),
sizeof
(
i
));
// verify transaction api access
eosio_assert
(
transaction_size
()
>
0
,
"transaction_size failed"
);
// verify softfloat api access
float
f1
=
1.0
f
,
f2
=
2.0
f
;
float
f3
=
f1
+
f2
;
eosio_assert
(
f3
>
2.0
f
,
"Unable to add float."
);
// verify compiler builtin api access
__int128
ret
;
__divti3
(
ret
,
2
,
2
,
2
,
2
);
// verify context_free_system_api
eosio_assert
(
true
,
"verify eosio_assert can be called"
);
}
else
if
(
cfa
.
payload
==
200
)
{
// attempt to access non context free api, privileged_api
...
...
@@ -120,10 +130,31 @@ void test_action::test_cf_action() {
db_idx64_store
(
N
(
testapi
),
N
(
testapi
),
N
(
testapi
),
0
,
&
i
);
eosio_assert
(
false
,
"db_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
204
)
{
db_find_i64
(
N
(
testapi
),
N
(
testapi
),
N
(
testapi
),
1
);
eosio_assert
(
false
,
"db_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
205
)
{
// attempt to access non context free api, send action
eosio
::
action
dum_act
;
dum_act
.
send
();
eosio_assert
(
false
,
"action send should not be allowed"
);
}
else
if
(
cfa
.
payload
==
206
)
{
eosio
::
require_auth
(
N
(
test
));
eosio_assert
(
false
,
"authorization_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
207
)
{
now
();
eosio_assert
(
false
,
"system_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
208
)
{
current_time
();
eosio_assert
(
false
,
"system_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
209
)
{
publication_time
();
eosio_assert
(
false
,
"system_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
210
)
{
send_inline
(
"hello"
,
6
);
eosio_assert
(
false
,
"transaction_api should not be allowed"
);
}
else
if
(
cfa
.
payload
==
211
)
{
send_deferred
(
N
(
testapi
),
N
(
testapi
),
"hello"
,
6
);
eosio_assert
(
false
,
"transaction_api should not be allowed"
);
}
}
...
...
unittests/api_tests.cpp
浏览文件 @
eee5c1da
...
...
@@ -441,7 +441,7 @@ BOOST_FIXTURE_TEST_CASE(cf_action_tests, TESTER) { try {
trx
.
actions
.
clear
();
trx
.
actions
.
push_back
(
act2
);
set_transaction_headers
(
trx
);
// run
normal passing case
// run
(dummy_action.b = 200) case looking for invalid use of context_free api
sigs
=
trx
.
sign
(
get_private_key
(
N
(
testapi
),
"active"
),
chain_id_type
());
BOOST_CHECK_EXCEPTION
(
push_transaction
(
trx
),
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
...
...
@@ -458,7 +458,7 @@ BOOST_FIXTURE_TEST_CASE(cf_action_tests, TESTER) { try {
trx
.
actions
.
push_back
(
act1
);
// attempt to access non context free api
for
(
uint32_t
i
=
200
;
i
<=
2
04
;
++
i
)
{
for
(
uint32_t
i
=
200
;
i
<=
2
11
;
++
i
)
{
trx
.
context_free_actions
.
clear
();
trx
.
context_free_data
.
clear
();
cfa
.
payload
=
i
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录