Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
befe1876
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,发现更多精彩内容 >>
提交
befe1876
编写于
9月 07, 2017
作者:
B
Bart Wyatt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
allow zero length messages, test for inline failure propagation and empty transaction failure
ref EOSIO/eos#175
上级
8dd711dd
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
54 addition
and
19 deletion
+54
-19
contracts/test_api/test_api.cpp
contracts/test_api/test_api.cpp
+3
-0
contracts/test_api/test_api.hpp
contracts/test_api/test_api.hpp
+3
-0
contracts/test_api/test_transaction.cpp
contracts/test_api/test_transaction.cpp
+31
-9
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+12
-10
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+5
-0
未找到文件。
contracts/test_api/test_api.cpp
浏览文件 @
befe1876
...
...
@@ -62,10 +62,13 @@ extern "C" {
//test transaction
WASM_TEST_HANDLER
(
test_transaction
,
send_message
);
WASM_TEST_HANDLER
(
test_transaction
,
send_message_empty
);
WASM_TEST_HANDLER
(
test_transaction
,
send_message_max
);
WASM_TEST_HANDLER
(
test_transaction
,
send_message_large
);
WASM_TEST_HANDLER
(
test_transaction
,
send_message_recurse
);
WASM_TEST_HANDLER
(
test_transaction
,
send_message_inline_fail
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction_empty
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction_max
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction_large
);
...
...
contracts/test_api/test_api.hpp
浏览文件 @
befe1876
...
...
@@ -108,10 +108,13 @@ struct test_crypto {
struct
test_transaction
{
static
unsigned
int
send_message
();
static
unsigned
int
send_message_empty
();
static
unsigned
int
send_message_max
();
static
unsigned
int
send_message_large
();
static
unsigned
int
send_message_recurse
();
static
unsigned
int
send_message_inline_fail
();
static
unsigned
int
send_transaction
();
static
unsigned
int
send_transaction_empty
();
static
unsigned
int
send_transaction_max
();
static
unsigned
int
send_transaction_large
();
};
contracts/test_api/test_transaction.cpp
浏览文件 @
befe1876
...
...
@@ -10,15 +10,9 @@ unsigned int test_transaction::send_message() {
return
WASM_TEST_PASS
;
}
unsigned
int
test_transaction
::
send_transaction
()
{
dummy_message
payload
=
{
DUMMY_MESSAGE_DEFAULT_A
,
DUMMY_MESSAGE_DEFAULT_B
,
DUMMY_MESSAGE_DEFAULT_C
};
auto
msg
=
messageCreate
(
N
(
testapi
),
WASM_TEST_ACTION
(
"test_message"
,
"read_message"
),
&
payload
,
sizeof
(
dummy_message
));
auto
trx
=
transactionCreate
();
transactionRequireScope
(
trx
,
N
(
testapi
));
transactionAddMessage
(
trx
,
msg
);
transactionSend
(
trx
);
unsigned
int
test_transaction
::
send_message_empty
()
{
auto
msg
=
messageCreate
(
N
(
testapi
),
WASM_TEST_ACTION
(
"test_message"
,
"assert_true"
),
nullptr
,
0
);
messageSend
(
msg
);
return
WASM_TEST_PASS
;
}
...
...
@@ -54,6 +48,34 @@ unsigned int test_transaction::send_message_recurse() {
return
WASM_TEST_PASS
;
}
/**
* cause failure due to inline TX failure
*/
unsigned
int
test_transaction
::
send_message_inline_fail
()
{
auto
msg
=
messageCreate
(
N
(
testapi
),
WASM_TEST_ACTION
(
"test_message"
,
"assert_false"
),
nullptr
,
0
);
messageSend
(
msg
);
return
WASM_TEST_PASS
;
}
unsigned
int
test_transaction
::
send_transaction
()
{
dummy_message
payload
=
{
DUMMY_MESSAGE_DEFAULT_A
,
DUMMY_MESSAGE_DEFAULT_B
,
DUMMY_MESSAGE_DEFAULT_C
};
auto
msg
=
messageCreate
(
N
(
testapi
),
WASM_TEST_ACTION
(
"test_message"
,
"read_message"
),
&
payload
,
sizeof
(
dummy_message
));
auto
trx
=
transactionCreate
();
transactionRequireScope
(
trx
,
N
(
testapi
));
transactionAddMessage
(
trx
,
msg
);
transactionSend
(
trx
);
return
WASM_TEST_PASS
;
}
unsigned
int
test_transaction
::
send_transaction_empty
()
{
auto
trx
=
transactionCreate
();
transactionRequireScope
(
trx
,
N
(
testapi
));
transactionSend
(
trx
);
return
WASM_TEST_FAIL
;
}
/**
* cause failure due to too many pending deferred transactions
*/
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
befe1876
...
...
@@ -290,10 +290,11 @@ DEFINE_INTRINSIC_FUNCTION4(env,messageCreate,messageCreate,i32,i64,code,i64,type
auto
&
wasm
=
wasm_interface
::
get
();
auto
mem
=
wasm
.
current_memory
;
EOS_ASSERT
(
length
>
0
,
tx_unknown_argument
,
"
Attempting to push an empty message
"
);
EOS_ASSERT
(
length
>
=
0
,
tx_unknown_argument
,
"
Pushing a message with a negative length
"
);
Bytes
payload
;
if
(
length
>
0
)
{
try
{
// memoryArrayPtr checks that the entire array of bytes is valid and
// within the bounds of the memory segment so that transactions cannot pass
...
...
@@ -303,6 +304,7 @@ DEFINE_INTRINSIC_FUNCTION4(env,messageCreate,messageCreate,i32,i64,code,i64,type
}
catch
(
const
Runtime
::
Exception
&
e
)
{
FC_THROW_EXCEPTION
(
tx_unknown_argument
,
"Message data is not a valid memory range"
);
}
}
auto
&
pmsg
=
wasm
.
current_apply_context
->
create_pending_message
(
Name
(
code
),
Name
(
type
),
payload
);
return
pmsg
.
handle
;
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
befe1876
...
...
@@ -384,13 +384,18 @@ BOOST_FIXTURE_TEST_CASE(test_all, testing_fixture)
//Test transaction
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message"
),
{},
{})
==
WASM_TEST_PASS
,
"test_transaction::send_message()"
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message_empty"
),
{},
{})
==
WASM_TEST_PASS
,
"test_transaction::send_message_empty()"
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message_large"
),
{},
{}
),
tx_resource_exhausted
,
is_tx_resource_exhausted
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message_max"
),
{},
{}
),
tx_resource_exhausted
,
is_tx_resource_exhausted
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message_recurse"
),
{},
fc
::
raw
::
pack
(
dummy13
)
),
tx_resource_exhausted
,
is_tx_resource_exhausted
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_message_inline_fail"
),
{},
{}
),
fc
::
assert_exception
,
is_assert_exception
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_transaction"
),
{},
{})
==
WASM_TEST_PASS
,
"test_transaction::send_message()"
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_transaction_empty"
),
{},
{}
),
tx_unknown_argument
,
is_tx_unknown_argument
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_transaction_large"
),
{},
{}
),
tx_resource_exhausted
,
is_tx_resource_exhausted
);
BOOST_CHECK_EXCEPTION
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_transaction"
,
"send_transaction_max"
),
{},
{}
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录