Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
eb9f34f2
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,发现更多精彩内容 >>
未验证
提交
eb9f34f2
编写于
5月 04, 2018
作者:
K
Kevin Heifner
提交者:
GitHub
5月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2756 from taokayan/slim_newapi
add unitest cases for new api feature
上级
aaae7167
b26fbb2c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
0 deletion
+66
-0
contracts/test_api/test_api.cpp
contracts/test_api/test_api.cpp
+2
-0
contracts/test_api/test_api.hpp
contracts/test_api/test_api.hpp
+2
-0
contracts/test_api/test_transaction.cpp
contracts/test_api/test_transaction.cpp
+9
-0
unittests/api_tests.cpp
unittests/api_tests.cpp
+53
-0
未找到文件。
contracts/test_api/test_api.cpp
浏览文件 @
eb9f34f2
...
...
@@ -142,6 +142,8 @@ extern "C" {
WASM_TEST_HANDLER
(
test_transaction
,
send_cf_action_fail
);
WASM_TEST_HANDLER
(
test_transaction
,
stateful_api
);
WASM_TEST_HANDLER
(
test_transaction
,
context_free_api
);
WASM_TEST_HANDLER
(
test_transaction
,
new_feature
);
WASM_TEST_HANDLER
(
test_transaction
,
active_new_feature
);
//test chain
WASM_TEST_HANDLER
(
test_chain
,
test_activeprods
);
...
...
contracts/test_api/test_api.hpp
浏览文件 @
eb9f34f2
...
...
@@ -172,6 +172,8 @@ struct test_transaction {
static
void
send_cf_action_fail
();
static
void
stateful_api
();
static
void
context_free_api
();
static
void
new_feature
();
static
void
active_new_feature
();
};
struct
test_chain
{
...
...
contracts/test_api/test_transaction.cpp
浏览文件 @
eb9f34f2
...
...
@@ -297,3 +297,12 @@ void test_transaction::context_free_api() {
char
buf
[
128
]
=
{
0
};
get_context_free_data
(
0
,
buf
,
sizeof
(
buf
));
}
extern
"C"
{
int
is_feature_active
(
int64_t
);
}
void
test_transaction
::
new_feature
()
{
eosio_assert
(
false
==
is_feature_active
(
N
(
newfeature
)),
"we should not have new features unless hardfork"
);
}
void
test_transaction
::
active_new_feature
()
{
activate_feature
(
N
(
newfeature
));
}
unittests/api_tests.cpp
浏览文件 @
eb9f34f2
...
...
@@ -1652,4 +1652,57 @@ BOOST_FIXTURE_TEST_CASE(datastream_tests, TESTER) { try {
BOOST_REQUIRE_EQUAL
(
validate
(),
true
);
}
FC_LOG_AND_RETHROW
()
}
/*************************************************************************************
* new api feature test
*************************************************************************************/
BOOST_FIXTURE_TEST_CASE
(
new_api_feature_tests
,
TESTER
)
{
try
{
produce_blocks
(
1
);
create_account
(
N
(
testapi
)
);
produce_blocks
(
1
);
set_code
(
N
(
testapi
),
test_api_wast
);
produce_blocks
(
1
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"new_feature"
,
{}
),
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
return
expect_assert_message
(
e
,
"context.privileged: testapi does not have permission to call this API"
);
});
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"active_new_feature"
,
{}
),
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
return
expect_assert_message
(
e
,
"context.privileged: testapi does not have permission to call this API"
);
});
// change privilege
{
chainbase
::
database
&
db
=
control
->
db
();
const
account_object
&
account
=
db
.
get
<
account_object
,
by_name
>
(
N
(
testapi
));
db
.
modify
(
account
,
[
&
](
account_object
&
v
)
{
v
.
privileged
=
true
;
});
}
#ifndef NON_VALIDATING_TEST
{
chainbase
::
database
&
db
=
validating_node
->
db
();
const
account_object
&
account
=
db
.
get
<
account_object
,
by_name
>
(
N
(
testapi
));
db
.
modify
(
account
,
[
&
](
account_object
&
v
)
{
v
.
privileged
=
true
;
});
}
#endif
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"new_feature"
,
{}
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"active_new_feature"
,
{}
),
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
return
expect_assert_message
(
e
,
"Unsupported Hardfork Detected"
);
});
BOOST_REQUIRE_EQUAL
(
validate
(),
true
);
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录