Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
bdd91caf
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,发现更多精彩内容 >>
提交
bdd91caf
编写于
8月 07, 2017
作者:
M
Matias Romeo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test missing db functions
上级
a484af6f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
440 addition
and
74 deletion
+440
-74
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
+1
-0
contracts/test_api/test_db.cpp
contracts/test_api/test_db.cpp
+433
-71
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+4
-3
未找到文件。
contracts/test_api/test_api.cpp
浏览文件 @
bdd91caf
...
@@ -46,6 +46,8 @@ extern "C" {
...
@@ -46,6 +46,8 @@ extern "C" {
WASM_TEST_HANDLER
(
test_db
,
key_i64_store_scope
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_store_scope
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_remove_scope
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_remove_scope
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_not_found
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_not_found
);
WASM_TEST_HANDLER
(
test_db
,
key_i64_front_back
);
WASM_TEST_HANDLER
(
test_db
,
key_i128i128_general
);
WASM_TEST_HANDLER
(
test_db
,
key_i128i128_general
);
//test crypto
//test crypto
...
...
contracts/test_api/test_api.hpp
浏览文件 @
bdd91caf
...
@@ -84,6 +84,7 @@ struct test_db {
...
@@ -84,6 +84,7 @@ struct test_db {
static
unsigned
int
key_i64_store_scope
();
static
unsigned
int
key_i64_store_scope
();
static
unsigned
int
key_i64_remove_scope
();
static
unsigned
int
key_i64_remove_scope
();
static
unsigned
int
key_i64_not_found
();
static
unsigned
int
key_i64_not_found
();
static
unsigned
int
key_i64_front_back
();
static
unsigned
int
key_i128i128_general
();
static
unsigned
int
key_i128i128_general
();
};
};
...
...
contracts/test_api/test_db.cpp
浏览文件 @
bdd91caf
...
@@ -16,15 +16,19 @@ struct TestModelV2 : TestModel {
...
@@ -16,15 +16,19 @@ struct TestModelV2 : TestModel {
uint64_t
new_field
;
uint64_t
new_field
;
};
};
struct
OrderID
{
struct
TestModelV3
:
TestModelV2
{
AccountName
name
=
0
;
uint64_t
another_field
;
uint64_t
number
=
0
;
};
};
struct
TestModel128x2
{
struct
TestModel128x2
{
OrderID
id
;
uint128_t
number
;
uint128_t
price
;
uint128_t
price
;
uint64_t
extra
;
uint64_t
extra
;
uint64_t
table_name
;
};
struct
TestModel128x2_V2
:
TestModel128x2
{
uint64_t
new_field
;
};
};
#pragma pack(pop)
#pragma pack(pop)
...
@@ -56,6 +60,49 @@ unsigned int test_db::key_i64_general() {
...
@@ -56,6 +60,49 @@ unsigned int test_db::key_i64_general() {
res
=
store_i64
(
currentCode
(),
N
(
test_table
),
&
alice
,
sizeof
(
TestModel
));
res
=
store_i64
(
currentCode
(),
N
(
test_table
),
&
alice
,
sizeof
(
TestModel
));
WASM_ASSERT
(
res
!=
0
,
"store alice"
);
WASM_ASSERT
(
res
!=
0
,
"store alice"
);
//fill with different ages in adjacent tables
dave
.
age
=
123
;
store_i64
(
currentCode
(),
N
(
test_tabld
),
&
dave
,
sizeof
(
TestModel
));
dave
.
age
=
124
;
store_i64
(
currentCode
(),
N
(
test_tablf
),
&
dave
,
sizeof
(
TestModel
));
carol
.
age
=
125
;
store_i64
(
currentCode
(),
N
(
test_tabld
),
&
carol
,
sizeof
(
TestModel
));
carol
.
age
=
126
;
store_i64
(
currentCode
(),
N
(
test_tablf
),
&
carol
,
sizeof
(
TestModel
));
bob
.
age
=
127
;
store_i64
(
currentCode
(),
N
(
test_tabld
),
&
bob
,
sizeof
(
TestModel
));
bob
.
age
=
128
;
store_i64
(
currentCode
(),
N
(
test_tablf
),
&
bob
,
sizeof
(
TestModel
));
alice
.
age
=
129
;
store_i64
(
currentCode
(),
N
(
test_tabld
),
&
alice
,
sizeof
(
TestModel
));
alice
.
age
=
130
;
store_i64
(
currentCode
(),
N
(
test_tablf
),
&
alice
,
sizeof
(
TestModel
));
TestModel
tmp
;
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"front_i64 1"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"front_i64 2"
);
res
=
previous_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
carol
)
&&
tmp
.
age
==
30
&&
tmp
.
phone
==
545342453
,
"carol previous"
);
res
=
previous_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
bob
)
&&
tmp
.
age
==
15
&&
tmp
.
phone
==
11932435
,
"bob previous"
);
res
=
previous_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"alice previous"
);
res
=
previous_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"previous null"
);
res
=
next_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
bob
)
&&
tmp
.
age
==
15
&&
tmp
.
phone
==
11932435
,
"bob next"
);
res
=
next_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
carol
)
&&
tmp
.
age
==
30
&&
tmp
.
phone
==
545342453
,
"carol next"
);
res
=
next_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"dave next"
);
res
=
next_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"next null"
);
my_memset
(
&
alice
,
0
,
sizeof
(
TestModel
));
my_memset
(
&
alice
,
0
,
sizeof
(
TestModel
));
WASM_ASSERT
(
alice
.
name
==
0
&&
alice
.
age
==
0
&&
alice
.
phone
==
0
,
"my_memset"
);
WASM_ASSERT
(
alice
.
name
==
0
&&
alice
.
age
==
0
&&
alice
.
phone
==
0
,
"my_memset"
);
...
@@ -118,31 +165,126 @@ unsigned int test_db::key_i64_general() {
...
@@ -118,31 +165,126 @@ unsigned int test_db::key_i64_general() {
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
alicev2
,
sizeof
(
TestModelV2
));
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
alicev2
,
sizeof
(
TestModelV2
));
WASM_ASSERT
(
res
==
sizeof
(
TestModelV2
)
&&
alicev2
.
age
==
21
&&
alicev2
.
phone
==
1234
&&
alicev2
.
new_field
==
66655444
,
"alice model v2"
);
WASM_ASSERT
(
res
==
sizeof
(
TestModelV2
)
&&
alicev2
.
age
==
21
&&
alicev2
.
phone
==
1234
&&
alicev2
.
new_field
==
66655444
,
"alice model v2"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
bob
);
res
=
lower_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
bob
),
"lower_bound_i64 bob"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
boc
);
res
=
lower_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
carol
),
"lower_bound_i64 carol"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
dave
);
res
=
lower_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
uint64_t
)
);
WASM_ASSERT
(
res
==
sizeof
(
uint64_t
)
&&
tmp
.
name
==
N
(
dave
),
"lower_bound_i64 dave"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
davf
);
res
=
lower_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
uint64_t
)
);
WASM_ASSERT
(
res
==
-
1
,
"lower_bound_i64 fail"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
alice
);
res
=
upper_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
age
==
15
&&
tmp
.
name
==
N
(
bob
),
"upper_bound_i64 bob"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
tmp
.
name
=
N
(
dave
);
res
=
upper_bound_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"upper_bound_i64 dave"
);
TestModelV3
tmp2
;
tmp2
.
name
=
N
(
alice
);
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp2
,
sizeof
(
TestModelV3
));
WASM_ASSERT
(
res
==
sizeof
(
TestModelV2
)
&&
tmp2
.
age
==
21
&&
tmp2
.
phone
==
1234
&&
tmp2
.
new_field
==
66655444
,
"load4update"
);
tmp2
.
another_field
=
221122
;
res
=
update_i64
(
currentCode
(),
N
(
test_table
),
&
tmp2
,
sizeof
(
TestModelV3
));
WASM_ASSERT
(
res
==
1
,
"update_i64"
);
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp2
,
sizeof
(
TestModelV3
));
WASM_ASSERT
(
res
==
sizeof
(
TestModelV3
)
&&
tmp2
.
age
==
21
&&
tmp2
.
phone
==
1234
&&
tmp2
.
new_field
==
66655444
&&
tmp2
.
another_field
==
221122
,
"load4update"
);
tmp2
.
age
=
11
;
res
=
update_i64
(
currentCode
(),
N
(
test_table
),
&
tmp2
,
sizeof
(
uint64_t
)
+
1
);
WASM_ASSERT
(
res
==
1
,
"update_i64 small"
);
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp2
,
sizeof
(
TestModelV3
));
WASM_ASSERT
(
res
==
sizeof
(
TestModelV3
)
&&
tmp2
.
age
==
11
&&
tmp2
.
phone
==
1234
&&
tmp2
.
new_field
==
66655444
&&
tmp2
.
another_field
==
221122
,
"load_i64 update_i64"
);
//Remove dummy records
uint64_t
tables
[]
{
N
(
test_tabld
),
N
(
test_tablf
)
};
for
(
auto
&
t
:
tables
)
{
while
(
front_i64
(
currentCode
(),
currentCode
(),
t
,
&
tmp
,
sizeof
(
TestModel
)
)
!=
-
1
)
{
remove_i64
(
currentCode
(),
t
,
&
tmp
);
}
}
return
WASM_TEST_PASS
;
return
WASM_TEST_PASS
;
}
}
unsigned
int
test_db
::
key_i64_remove_all
()
{
unsigned
int
test_db
::
key_i64_remove_all
()
{
uint32_t
res
=
0
;
uint32_t
res
=
0
;
uint64_t
key
;
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
alice
));
key
=
N
(
alice
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
1
,
"remove alice"
);
WASM_ASSERT
(
res
==
1
,
"remove alice"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
bob
));
key
=
N
(
bob
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
1
,
"remove bob"
);
WASM_ASSERT
(
res
==
1
,
"remove bob"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
carol
));
key
=
N
(
carol
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
1
,
"remove carol"
);
WASM_ASSERT
(
res
==
1
,
"remove carol"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
dave
));
key
=
N
(
dave
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
1
,
"remove dave"
);
WASM_ASSERT
(
res
==
1
,
"remove dave"
);
TestModel
tmp
;
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"front_i64 remove"
);
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
test_table
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"back_i64_i64 remove"
);
key
=
N
(
alice
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
0
,
"remove alice 1"
);
key
=
N
(
bob
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
0
,
"remove bob 1"
);
key
=
N
(
carol
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
0
,
"remove carol 1"
);
key
=
N
(
dave
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
&
key
);
WASM_ASSERT
(
res
==
0
,
"remove dave 1"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
alice
));
WASM_ASSERT
(
res
==
0
,
"remove alice 2"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
bob
));
WASM_ASSERT
(
res
==
0
,
"remove bob 2"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
carol
));
WASM_ASSERT
(
res
==
0
,
"remove carol 2"
);
res
=
remove_i64
(
currentCode
(),
N
(
test_table
),
N
(
dave
));
WASM_ASSERT
(
res
==
0
,
"remove dave 2"
);
return
WASM_TEST_PASS
;
return
WASM_TEST_PASS
;
}
}
...
@@ -177,86 +319,164 @@ unsigned int test_db::key_i64_not_found() {
...
@@ -177,86 +319,164 @@ unsigned int test_db::key_i64_not_found() {
auto
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
just_uint64
),
&
dummy
,
sizeof
(
uint64_t
));
auto
res
=
load_i64
(
currentCode
(),
currentCode
(),
N
(
just_uint64
),
&
dummy
,
sizeof
(
uint64_t
));
WASM_ASSERT
(
res
==
-
1
,
"i64_not_found load"
);
WASM_ASSERT
(
res
==
-
1
,
"i64_not_found load"
);
res
=
remove_i64
(
currentCode
(),
N
(
just_uint64
),
dummy
);
res
=
remove_i64
(
currentCode
(),
N
(
just_uint64
),
&
dummy
);
WASM_ASSERT
(
res
==
0
,
"i64_not_found remove"
);
WASM_ASSERT
(
res
==
0
,
"i64_not_found remove"
);
return
WASM_TEST_PASS
;
return
WASM_TEST_PASS
;
}
}
// extern "C" {
unsigned
int
test_db
::
key_i64_front_back
()
{
// unsigned int store_set_in_table(uint64_t table_name);
// };
uint32_t
res
=
0
;
TestModel
dave
{
N
(
dave
),
46
,
6535354
};
TestModel
carol
{
N
(
carol
),
30
,
545342453
};
store_i64
(
currentCode
(),
N
(
b
),
&
dave
,
sizeof
(
TestModel
));
store_i64
(
currentCode
(),
N
(
b
),
&
carol
,
sizeof
(
TestModel
));
TestModel
bob
{
N
(
bob
),
15
,
11932435
};
TestModel
alice
{
N
(
alice
),
20
,
4234622
};
store_i64
(
currentCode
(),
N
(
a
),
&
bob
,
sizeof
(
TestModel
));
store_i64
(
currentCode
(),
N
(
a
),
&
alice
,
sizeof
(
TestModel
));
TestModel
tmp
;
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"key_i64_front 1"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
bob
)
&&
tmp
.
age
==
15
&&
tmp
.
phone
==
11932435
,
"key_i64_front 2"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
carol
)
&&
tmp
.
age
==
30
&&
tmp
.
phone
==
545342453
,
"key_i64_front 3"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"key_i64_front 4"
);
uint64_t
key
=
N
(
carol
);
remove_i64
(
currentCode
(),
N
(
b
),
&
key
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"key_i64_front 5"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"key_i64_front 6"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"key_i64_front 7"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
bob
)
&&
tmp
.
age
==
15
&&
tmp
.
phone
==
11932435
,
"key_i64_front 8"
);
key
=
N
(
dave
);
remove_i64
(
currentCode
(),
N
(
b
),
&
key
);
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"key_i64_front 9"
);
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
b
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"key_i64_front 10"
);
key
=
N
(
bob
);
remove_i64
(
currentCode
(),
N
(
a
),
&
key
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"key_i64_front 11"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel
));
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"key_i64_front 12"
);
key
=
N
(
alice
);
remove_i64
(
currentCode
(),
N
(
a
),
&
key
);
res
=
front_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"key_i64_front 13"
);
res
=
back_i64
(
currentCode
(),
currentCode
(),
N
(
a
),
&
tmp
,
sizeof
(
TestModel
)
);
WASM_ASSERT
(
res
==
-
1
,
"key_i64_front 14"
);
return
WASM_TEST_PASS
;
}
unsigned
int
store_set_in_table
(
uint64_t
table_name
)
unsigned
int
store_set_in_table
(
uint64_t
table_name
)
{
{
uint32_t
res
=
0
;
uint32_t
res
=
0
;
TestModel128x2
alice0
{{
N
(
alice
),
0
},
500
,
N
(
alice0
)};
TestModel128x2
alice0
{
0
,
500
,
N
(
alice0
),
table_name
};
TestModel128x2
alice1
{{
N
(
alice
),
1
},
400
,
N
(
alice1
)};
TestModel128x2
alice1
{
1
,
400
,
N
(
alice1
),
table_name
};
TestModel128x2
alice2
{{
N
(
alice
),
2
},
300
,
N
(
alice2
)};
TestModel128x2
alice2
{
2
,
300
,
N
(
alice2
),
table_name
};
TestModel128x2
alice22
{
2
,
200
,
N
(
alice22
),
table_name
};
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice0
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice0
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store alice0"
);
WASM_ASSERT
(
res
==
1
,
"store alice0"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice1
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice1
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store alice1"
);
WASM_ASSERT
(
res
==
1
,
"store alice1"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice2
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice2
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store alice2"
);
WASM_ASSERT
(
res
==
1
,
"store alice2"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
alice22
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
==
1
,
"store alice22"
);
TestModel128x2
bob0
{
{
N
(
bob
),
0
},
1
,
N
(
bob0
)
};
TestModel128x2
bob0
{
10
,
1
,
N
(
bob0
),
table_name
};
TestModel128x2
bob1
{
{
N
(
bob
),
1
},
2
,
N
(
bob1
)
};
TestModel128x2
bob1
{
11
,
2
,
N
(
bob1
),
table_name
};
TestModel128x2
bob2
{
{
N
(
bob
),
2
},
3
,
N
(
bob2
)
};
TestModel128x2
bob2
{
12
,
3
,
N
(
bob2
),
table_name
};
TestModel128x2
bob3
{
{
N
(
bob
),
3
},
4
,
N
(
bob3
)
};
TestModel128x2
bob3
{
13
,
4
,
N
(
bob3
),
table_name
};
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob0
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob0
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store bob0"
);
WASM_ASSERT
(
res
==
1
,
"store bob0"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob1
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob1
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store bob1"
);
WASM_ASSERT
(
res
==
1
,
"store bob1"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob2
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob2
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store bob2"
);
WASM_ASSERT
(
res
==
1
,
"store bob2"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob3
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
bob3
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store bob3"
);
WASM_ASSERT
(
res
==
1
,
"store bob3"
);
TestModel128x2
carol0
{
{
N
(
carol
),
0
},
900
,
N
(
carol0
)
};
TestModel128x2
carol0
{
20
,
900
,
N
(
carol0
),
table_name
};
TestModel128x2
carol1
{
{
N
(
carol
),
1
},
800
,
N
(
carol1
)
};
TestModel128x2
carol1
{
21
,
800
,
N
(
carol1
),
table_name
};
TestModel128x2
carol2
{
{
N
(
carol
),
2
},
700
,
N
(
carol2
)
};
TestModel128x2
carol2
{
22
,
700
,
N
(
carol2
),
table_name
};
TestModel128x2
carol3
{
{
N
(
carol
),
3
},
600
,
N
(
carol3
)
};
TestModel128x2
carol3
{
23
,
600
,
N
(
carol3
),
table_name
};
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol0
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol0
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store carol0"
);
WASM_ASSERT
(
res
==
1
,
"store carol0"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol1
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol1
,
sizeof
(
TestModel128x2
));
eos
::
print
(
"Store carol1 "
,
res
,
"
\n
"
);
WASM_ASSERT
(
res
==
1
,
"store carol1"
);
WASM_ASSERT
(
res
>
0
,
"store carol1"
);
eos
::
print
(
"Store carol1 "
,
res
,
" "
,
carol1
.
id
.
name
,
" "
,
carol1
.
id
.
number
,
" "
,
carol1
.
price
,
" "
,
carol1
.
extra
,
"
\n
"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol2
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol2
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store carol2"
);
WASM_ASSERT
(
res
==
1
,
"store carol2"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol3
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
carol3
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store carol3"
);
WASM_ASSERT
(
res
==
1
,
"store carol3"
);
TestModel128x2
dave0
{
{
N
(
dave
)
,
0
},
8
,
N
(
dave0
)
};
TestModel128x2
dave0
{
30
,
8
,
N
(
dave0
),
table_name
};
TestModel128x2
dave1
{
{
N
(
dave
)
,
1
},
7
,
N
(
dave1
)
};
TestModel128x2
dave1
{
31
,
7
,
N
(
dave1
),
table_name
};
TestModel128x2
dave2
{
{
N
(
dave
)
,
2
},
5
,
N
(
dave2
)
};
TestModel128x2
dave2
{
32
,
5
,
N
(
dave2
),
table_name
};
TestModel128x2
dave3
{
{
N
(
dave
)
,
3
},
4
,
N
(
dave3
)
};
TestModel128x2
dave3
{
33
,
4
,
N
(
dave3
),
table_name
};
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave0
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave0
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store dave0"
);
WASM_ASSERT
(
res
==
1
,
"store dave0"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave1
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave1
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store dave1"
);
WASM_ASSERT
(
res
==
1
,
"store dave1"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave2
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave2
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store dave2"
);
WASM_ASSERT
(
res
==
1
,
"store dave2"
);
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave3
,
sizeof
(
TestModel128x2
));
res
=
store_i128i128
(
currentCode
(),
table_name
,
&
dave3
,
sizeof
(
TestModel128x2
));
WASM_ASSERT
(
res
>
0
,
"store dave3"
);
WASM_ASSERT
(
res
==
1
,
"store dave3"
);
return
WASM_TEST_PASS
;
return
WASM_TEST_PASS
;
}
}
...
@@ -265,42 +485,184 @@ unsigned int test_db::key_i128i128_general() {
...
@@ -265,42 +485,184 @@ unsigned int test_db::key_i128i128_general() {
uint32_t
res
=
0
;
uint32_t
res
=
0
;
if
(
store_set_in_table
(
N
(
table
1
))
!=
WASM_TEST_PASS
)
if
(
store_set_in_table
(
N
(
table
0
))
!=
WASM_TEST_PASS
)
return
WASM_TEST_FAIL
;
return
WASM_TEST_FAIL
;
// if(store_set_in_table(N(table2
)) != WASM_TEST_PASS)
if
(
store_set_in_table
(
N
(
table1
))
!=
WASM_TEST_PASS
)
//
return WASM_TEST_FAIL;
return
WASM_TEST_FAIL
;
// if(store_set_in_table(N(table3
)) != WASM_TEST_PASS)
if
(
store_set_in_table
(
N
(
table2
))
!=
WASM_TEST_PASS
)
//
return WASM_TEST_FAIL;
return
WASM_TEST_FAIL
;
TestModel128x2
tmp
;
TestModel128x2
tmp
;
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel128x2
));
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel128x2
));
tmp
.
id
.
name
=
N
(
carol
);
tmp
.
number
=
21
;
tmp
.
id
.
number
=
1
;
tmp
.
price
=
800
;
res
=
load_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
res
=
load_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
id
.
name
==
N
(
carol
)
&&
tmp
.
id
.
number
==
1
&&
tmp
.
price
==
800
&&
tmp
.
price
==
800
&&
tmp
.
extra
==
N
(
carol1
),
tmp
.
extra
==
N
(
carol1
)
&&
tmp
.
table_name
==
N
(
table1
),
"carol1 primary load"
);
"carol1 primary load"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel128x2
));
my_memset
(
&
tmp
,
0
,
sizeof
(
TestModel128x2
));
tmp
.
price
=
4
;
//TestModel128x2 dave3{{N(dave) ,3}, 4, N(dave3)};
tmp
.
price
=
4
;
//TestModel128x2 bob3{{N(bob), 3}, 4, N(bob3)};
res
=
load_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
res
=
load_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
//eos::print("SECOND -> ", res, " ", tmp.id.name, " ", tmp.id.number, " ", tmp.price, " ", tmp.extra, "\n");
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
id
.
name
==
N
(
bob
)
&&
tmp
.
number
==
13
&&
tmp
.
id
.
number
==
3
&&
tmp
.
price
==
4
&&
tmp
.
price
==
4
&&
tmp
.
extra
==
N
(
bob3
),
tmp
.
extra
==
N
(
bob3
)
&&
tmp
.
table_name
==
N
(
table1
),
"bob3 secondary load"
);
"bob3 secondary load"
);
res
=
front_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
0
&&
tmp
.
price
==
500
&&
tmp
.
extra
==
N
(
alice0
)
&&
tmp
.
table_name
==
N
(
table1
),
"front primary load"
);
res
=
previous_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
-
1
,
"previous primary fail"
);
res
=
next_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
1
&&
tmp
.
price
==
400
&&
tmp
.
extra
==
N
(
alice1
)
&&
tmp
.
table_name
==
N
(
table1
),
"next primary ok"
);
res
=
front_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
10
&&
tmp
.
price
==
1
&&
tmp
.
extra
==
N
(
bob0
)
&&
tmp
.
table_name
==
N
(
table1
),
"front secondary ok"
);
res
=
previous_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
-
1
,
"previous secondary fail"
);
res
=
next_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
11
&&
tmp
.
price
==
2
&&
tmp
.
extra
==
N
(
bob1
)
&&
tmp
.
table_name
==
N
(
table1
),
"next secondary ok"
);
res
=
back_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
33
&&
tmp
.
price
==
4
&&
tmp
.
extra
==
N
(
dave3
)
&&
tmp
.
table_name
==
N
(
table1
),
"back primary ok"
);
res
=
next_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
-
1
,
"next primary fail"
);
res
=
previous_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
32
&&
tmp
.
price
==
5
&&
tmp
.
extra
==
N
(
dave2
)
&&
tmp
.
table_name
==
N
(
table1
),
"previous primary ok"
);
res
=
back_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
20
&&
tmp
.
price
==
900
&&
tmp
.
extra
==
N
(
carol0
)
&&
tmp
.
table_name
==
N
(
table1
),
"back secondary ok"
);
res
=
next_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
-
1
,
"next secondary fail"
);
res
=
previous_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
21
&&
tmp
.
price
==
800
&&
tmp
.
extra
==
N
(
carol1
)
&&
tmp
.
table_name
==
N
(
table1
),
"previous secondary ok"
);
tmp
.
number
=
1
;
res
=
lower_bound_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
1
&&
tmp
.
price
==
400
&&
tmp
.
extra
==
N
(
alice1
)
&&
tmp
.
table_name
==
N
(
table1
),
"lb primary ok"
);
res
=
upper_bound_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
2
&&
tmp
.
price
==
200
&&
tmp
.
extra
==
N
(
alice22
)
&&
tmp
.
table_name
==
N
(
table1
),
"ub primary ok"
);
tmp
.
price
=
800
;
res
=
lower_bound_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp
,
sizeof
(
TestModel128x2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp
.
number
==
21
&&
tmp
.
price
==
800
&&
tmp
.
extra
==
N
(
carol1
)
&&
tmp
.
table_name
==
N
(
table1
),
"lb secondary ok"
);
TestModel128x2_V2
tmp2
;
tmp2
.
price
=
800
;
res
=
upper_bound_secondary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp2
,
sizeof
(
TestModel128x2_V2
)
);
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2
)
&&
tmp2
.
number
==
20
&&
tmp2
.
price
==
900
&&
tmp2
.
extra
==
N
(
carol0
)
&&
tmp2
.
table_name
==
N
(
table1
),
"ub secondary ok"
);
tmp2
.
new_field
=
123456
;
res
=
update_i128i128
(
currentCode
(),
N
(
table1
),
&
tmp2
,
sizeof
(
TestModel128x2_V2
));
WASM_ASSERT
(
res
==
1
,
"update_i128i128 ok"
);
my_memset
(
&
tmp2
,
0
,
sizeof
(
TestModel128x2_V2
));
tmp2
.
number
=
20
;
res
=
load_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp2
,
sizeof
(
TestModel128x2_V2
));
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2_V2
)
&&
tmp2
.
number
==
20
&&
tmp2
.
price
==
900
&&
tmp2
.
extra
==
N
(
carol0
)
&&
tmp2
.
table_name
==
N
(
table1
)
&&
tmp2
.
new_field
==
123456
,
"lp update_i128i128 ok"
);
tmp2
.
extra
=
N
(
xxxxx
);
res
=
update_i128i128
(
currentCode
(),
N
(
table1
),
&
tmp2
,
sizeof
(
uint128_t
)
*
2
+
sizeof
(
uint64_t
));
WASM_ASSERT
(
res
==
1
,
"update_i128i128 small ok"
);
res
=
load_primary_i128i128
(
currentCode
(),
currentCode
(),
N
(
table1
),
&
tmp2
,
sizeof
(
TestModel128x2_V2
));
WASM_ASSERT
(
res
==
sizeof
(
TestModel128x2_V2
)
&&
tmp2
.
number
==
20
&&
tmp2
.
price
==
900
&&
tmp2
.
extra
==
N
(
xxxxx
)
&&
tmp2
.
table_name
==
N
(
table1
)
&&
tmp2
.
new_field
==
123456
,
"lp small update_i128i128 ok"
);
return
WASM_TEST_PASS
;
return
WASM_TEST_PASS
;
}
}
//eos::print("xxxx ", res, " ", tmp2.name, " ", uint64_t(tmp2.age), " ", tmp2.phone, " ", tmp2.new_field, "\n");
\ No newline at end of file
tests/api_tests/api_tests.cpp
浏览文件 @
bdd91caf
...
@@ -109,7 +109,7 @@ uint32_t CallFunction( testing_blockchain& chain, const types::Message& msg, con
...
@@ -109,7 +109,7 @@ uint32_t CallFunction( testing_blockchain& chain, const types::Message& msg, con
vector
<
char
>&
dest
=
*
(
vector
<
char
>
*
)(
&
msg
.
data
);
vector
<
char
>&
dest
=
*
(
vector
<
char
>
*
)(
&
msg
.
data
);
std
::
copy
(
data
.
begin
(),
data
.
end
(),
std
::
back_inserter
(
dest
));
std
::
copy
(
data
.
begin
(),
data
.
end
(),
std
::
back_inserter
(
dest
));
std
::
cout
<<
"MANDO: "
<<
msg
.
code
<<
" "
<<
msg
.
type
<<
std
::
endl
;
//
std::cout << "MANDO: " << msg.code << " " << msg.type << std::endl;
trx
.
emplaceMessage
(
msg
);
trx
.
emplaceMessage
(
msg
);
trx
.
expiration
=
chain
.
head_block_time
()
+
expiration
++
;
trx
.
expiration
=
chain
.
head_block_time
()
+
expiration
++
;
...
@@ -197,8 +197,8 @@ uint32_t last_fnc_err = 0;
...
@@ -197,8 +197,8 @@ uint32_t last_fnc_err = 0;
BOOST_FIXTURE_TEST_CASE
(
test_all
,
testing_fixture
)
BOOST_FIXTURE_TEST_CASE
(
test_all
,
testing_fixture
)
{
try
{
{
try
{
std
::
string
test_api_wast_str
(
test_api_wast
);
//
std::string test_api_wast_str(test_api_wast);
//auto test_api_wast
= readFile2("/home/matu/Documents/Dev/eos/contracts/test_api/test_api.wast");
auto
test_api_wast_str
=
readFile2
(
"/home/matu/Documents/Dev/eos/contracts/test_api/test_api.wast"
);
//std::cout << test_api_wast << std::endl;
//std::cout << test_api_wast << std::endl;
Make_Blockchain
(
chain
);
Make_Blockchain
(
chain
);
...
@@ -365,6 +365,7 @@ BOOST_FIXTURE_TEST_CASE(test_all, testing_fixture)
...
@@ -365,6 +365,7 @@ BOOST_FIXTURE_TEST_CASE(test_all, testing_fixture)
tx_missing_scope
,
is_tx_missing_scope
);
tx_missing_scope
,
is_tx_missing_scope
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_db"
,
"key_i64_not_found"
),
{},
{}
)
==
WASM_TEST_PASS
,
"test_db::key_i64_not_found()"
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_db"
,
"key_i64_not_found"
),
{},
{}
)
==
WASM_TEST_PASS
,
"test_db::key_i64_not_found()"
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_db"
,
"key_i64_front_back"
),
{},
{}
)
==
WASM_TEST_PASS
,
"test_db::key_i64_front_back()"
);
//Test db (i128i128)
//Test db (i128i128)
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_db"
,
"key_i128i128_general"
),
{},
{}
)
==
WASM_TEST_PASS
,
"test_db::key_i128i128_general()"
);
BOOST_CHECK_MESSAGE
(
CALL_TEST_FUNCTION
(
TEST_METHOD
(
"test_db"
,
"key_i128i128_general"
),
{},
{}
)
==
WASM_TEST_PASS
,
"test_db::key_i128i128_general()"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录