Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
3cf761c9
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,发现更多精彩内容 >>
提交
3cf761c9
编写于
1月 25, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Still working on DB
上级
51327e58
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
47 deletion
+46
-47
contracts/test_api/test_api.cpp
contracts/test_api/test_api.cpp
+5
-5
contracts/test_api_db/test_db.cpp
contracts/test_api_db/test_db.cpp
+8
-11
libraries/chain/include/eosio/chain/apply_context.hpp
libraries/chain/include/eosio/chain/apply_context.hpp
+15
-13
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+17
-17
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+1
-0
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+0
-1
未找到文件。
contracts/test_api/test_api.cpp
浏览文件 @
3cf761c9
...
...
@@ -75,11 +75,11 @@ extern "C" {
WASM_TEST_HANDLER
(
test_crypto
,
assert_sha256_true
);
//test transaction
WASM_TEST_HANDLER
(
test_transaction
,
send_
message
);
WASM_TEST_HANDLER
(
test_transaction
,
send_
message
_empty
);
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_
action
);
WASM_TEST_HANDLER
(
test_transaction
,
send_
action
_empty
);
WASM_TEST_HANDLER
(
test_transaction
,
send_
action
_large
);
WASM_TEST_HANDLER
(
test_transaction
,
send_
action
_recurse
);
WASM_TEST_HANDLER
(
test_transaction
,
send_
action
_inline_fail
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction_empty
);
WASM_TEST_HANDLER
(
test_transaction
,
send_transaction_large
);
...
...
contracts/test_api_db/test_db.cpp
浏览文件 @
3cf761c9
...
...
@@ -273,7 +273,6 @@ void test_db::key_str_general() {
void
test_db
::
key_i64_general
()
{
uint32_t
res
=
0
;
test_model
alice
{
N
(
alice
),
20
,
4234622
};
test_model
bob
{
N
(
bob
),
15
,
11932435
};
test_model
carol
{
N
(
carol
),
30
,
545342453
};
...
...
@@ -304,12 +303,6 @@ void test_db::key_i64_general() {
test_model
tmp
;
res
=
front_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
prints
(
"size "
);
printi
(
res
);
prints
(
"
\n
"
);
printi
(
sizeof
(
test_model
));
prints
(
"
\n
"
);
assert
(
res
==
sizeof
(
test_model
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"front_i64 1"
);
my_memset
(
&
tmp
,
0
,
sizeof
(
test_model
));
...
...
@@ -326,7 +319,7 @@ void test_db::key_i64_general() {
assert
(
res
==
sizeof
(
test_model
)
&&
tmp
.
name
==
N
(
alice
)
&&
tmp
.
age
==
20
&&
tmp
.
phone
==
4234622
,
"alice previous"
);
res
=
previous_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
-
1
,
"previous null"
);
assert
(
res
==
0
,
"previous null"
);
res
=
next_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
sizeof
(
test_model
)
&&
tmp
.
name
==
N
(
bob
)
&&
tmp
.
age
==
15
&&
tmp
.
phone
==
11932435
,
"bob next"
);
...
...
@@ -338,7 +331,7 @@ void test_db::key_i64_general() {
assert
(
res
==
sizeof
(
test_model
)
&&
tmp
.
name
==
N
(
dave
)
&&
tmp
.
age
==
46
&&
tmp
.
phone
==
6535354
,
"dave next"
);
res
=
next_i64
(
current_receiver
(),
current_receiver
(),
N
(
test_table
),
&
tmp
,
sizeof
(
test_model
)
);
assert
(
res
==
-
1
,
"next null"
);
assert
(
res
==
0
,
"next null"
);
my_memset
(
&
alice
,
0
,
sizeof
(
test_model
));
...
...
@@ -380,10 +373,14 @@ void test_db::key_i64_general() {
assert
(
res
==
sizeof
(
test_model
)
&&
dave
.
age
==
46
&&
dave
.
phone
==
6535354
,
"dave error 1"
);
res
=
load_i64
(
current_receiver
(),
N
(
other_code
),
N
(
test_table
),
&
alice
,
sizeof
(
test_model
));
assert
(
res
==
-
1
,
"other_code"
);
prints
(
"other "
);
printi
(
res
);
prints
(
"
\n
"
);
return
;
assert
(
res
==
0
,
"other_code"
);
res
=
load_i64
(
current_receiver
(),
current_receiver
(),
N
(
other_table
),
&
alice
,
sizeof
(
test_model
));
assert
(
res
==
-
1
,
"other_table"
);
assert
(
res
==
0
,
"other_table"
);
test_model_v2
alicev2
;
...
...
libraries/chain/include/eosio/chain/apply_context.hpp
浏览文件 @
3cf761c9
...
...
@@ -7,6 +7,7 @@
#include <eosio/chain/contracts/contract_table_objects.hpp>
#include <fc/utility.hpp>
#include <sstream>
#include <iostream>
namespace
chainbase
{
class
database
;
}
...
...
@@ -396,6 +397,7 @@ using apply_handler = std::function<void(apply_context&)>;
const
auto
*
obj
=
db
.
find
<
ObjectType
,
contracts
::
by_scope_primary
>
(
tuple
);
if
(
obj
)
{
auto
prev_size
=
obj
->
value
.
size
();
mutable_db
.
modify
(
*
obj
,
[
&
](
auto
&
o
)
{
o
.
value
.
assign
(
value
,
valuelen
);
});
...
...
@@ -469,10 +471,10 @@ using apply_handler = std::function<void(apply_context&)>;
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
||
!
impl
::
record_scope_compare
<
IndexType
,
Scope
>::
compare
(
*
itr
,
keys
))
return
-
1
;
!
impl
::
record_scope_compare
<
IndexType
,
Scope
>::
compare
(
*
itr
,
keys
))
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
std
::
cout
<<
"WHY!"
<<
"
\n
"
;
if
(
valuelen
)
{
auto
copylen
=
std
::
min
<
size_t
>
(
itr
->
value
.
size
(),
valuelen
);
if
(
copylen
)
{
...
...
@@ -493,7 +495,7 @@ using apply_handler = std::function<void(apply_context&)>;
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
)
return
-
1
;
itr
->
t_id
!=
t_id
.
id
)
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
@@ -517,11 +519,11 @@ using apply_handler = std::function<void(apply_context&)>;
auto
tuple
=
boost
::
make_tuple
(
next_tid
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
std
::
distance
(
idx
.
begin
(),
itr
)
==
0
)
return
-
1
;
if
(
std
::
distance
(
idx
.
begin
(),
itr
)
==
0
)
return
0
;
--
itr
;
if
(
itr
->
t_id
!=
t_id
.
id
)
return
-
1
;
if
(
itr
->
t_id
!=
t_id
.
id
)
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
@@ -546,7 +548,7 @@ using apply_handler = std::function<void(apply_context&)>;
auto
pitr
=
pidx
.
find
(
tuple
);
if
(
pitr
==
pidx
.
end
())
return
-
1
;
return
0
;
const
auto
&
fidx
=
db
.
get_index
<
IndexType
>
();
auto
itr
=
fidx
.
indicies
().
template
project
<
Scope
>(
pitr
);
...
...
@@ -556,14 +558,14 @@ using apply_handler = std::function<void(apply_context&)>;
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
||
!
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
compare
(
*
itr
,
keys
)
)
{
return
-
1
;
return
0
;
}
++
itr
;
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
)
{
return
-
1
;
return
0
;
}
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
@@ -589,7 +591,7 @@ using apply_handler = std::function<void(apply_context&)>;
auto
pitr
=
pidx
.
find
(
tuple
);
if
(
pitr
==
pidx
.
end
())
return
-
1
;
return
0
;
const
auto
&
fidx
=
db
.
get_index
<
IndexType
>
();
auto
itr
=
fidx
.
indicies
().
template
project
<
Scope
>(
pitr
);
...
...
@@ -599,11 +601,11 @@ using apply_handler = std::function<void(apply_context&)>;
if
(
itr
==
idx
.
end
()
||
itr
==
idx
.
begin
()
||
itr
->
t_id
!=
t_id
.
id
||
!
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
compare
(
*
itr
,
keys
)
)
return
-
1
;
!
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
compare
(
*
itr
,
keys
)
)
return
0
;
--
itr
;
if
(
itr
->
t_id
!=
t_id
.
id
)
return
-
1
;
if
(
itr
->
t_id
!=
t_id
.
id
)
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
@@ -627,7 +629,7 @@ using apply_handler = std::function<void(apply_context&)>;
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
)
return
-
1
;
itr
->
t_id
!=
t_id
.
id
)
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
@@ -651,7 +653,7 @@ using apply_handler = std::function<void(apply_context&)>;
auto
itr
=
idx
.
upper_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
)
return
-
1
;
itr
->
t_id
!=
t_id
.
id
)
return
0
;
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
3cf761c9
...
...
@@ -751,12 +751,7 @@ class db_api : public context_aware_api {
const
char
*
record_data
=
((
const
char
*
)
data
)
+
sizeof
(
KeyArrayType
);
size_t
record_len
=
data_len
-
sizeof
(
KeyArrayType
);
size_t
ret
=
(
context
.
*
(
method
))(
t_id
,
keys
,
record_data
,
record_len
)
+
sizeof
(
KeyArrayType
);
std
::
cout
<<
"size "
<<
ret
<<
"
\n
"
;
std
::
cout
<<
"key size "
<<
sizeof
(
KeyArrayType
)
<<
"
\n
"
;
std
::
cout
<<
"data size "
<<
data_len
<<
"
\n
"
;
std
::
cout
<<
"record size "
<<
record_len
<<
"
\n
"
;
return
ret
;
return
(
context
.
*
(
method
))(
t_id
,
keys
,
record_data
,
record_len
);
}
public:
...
...
@@ -764,7 +759,6 @@ class db_api : public context_aware_api {
int
store
(
const
scope_name
&
scope
,
const
name
&
table
,
array_ptr
<
const
char
>
data
,
size_t
data_len
)
{
auto
res
=
call
(
&
apply_context
::
store_record
<
ObjectType
>
,
scope
,
table
,
data
,
data_len
);
//ilog("STORE [${scope},${code},${table}] => ${res} :: ${HEX}", ("scope",scope)("code",context.receiver)("table",table)("res",res)("HEX", fc::to_hex(data, data_len)));
return
res
;
}
...
...
@@ -795,7 +789,7 @@ class db_api<keystr_value_object> : public context_aware_api {
const
char
*
record_data
=
((
const
char
*
)
data
);
// + sizeof(KeyArrayType);
size_t
record_len
=
data_len
;
// - sizeof(KeyArrayType);
return
(
context
.
*
(
method
))(
t_id
,
&
keys
,
record_data
,
record_len
);
// + sizeof(KeyArrayType);
return
(
context
.
*
(
method
))(
t_id
,
&
keys
,
record_data
,
record_len
);
}
public:
...
...
@@ -841,7 +835,7 @@ class db_index_api : public context_aware_api {
char
*
record_data
=
((
char
*
)
data
)
+
sizeof
(
KeyArrayType
);
size_t
record_len
=
data_len
-
sizeof
(
KeyArrayType
);
return
(
context
.
*
(
method
))(
t_id
,
keys
,
record_data
,
record_len
);
// + sizeof(KeyArrayType);
return
(
context
.
*
(
method
))(
t_id
,
keys
,
record_data
,
record_len
);
}
public:
...
...
@@ -849,32 +843,38 @@ class db_index_api : public context_aware_api {
int
load
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
auto
res
=
call
(
&
apply_context
::
load_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
//ilog("LOAD [${scope},${code},${table}] => ${res} :: ${HEX}", ("scope",scope)("code",code)("table",table)("res",res)("HEX", fc::to_hex(data, data_len)))
;
return
res
;
std
::
cout
<<
"res "
<<
res
<<
"
\n
"
;
return
(
res
==
0
)
?
0
:
res
+
sizeof
(
KeyArrayType
)
;
}
int
front
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
front_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
front_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
back
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
back_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
back_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
next
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
next_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
next_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
previous
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
previous_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
previous_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
lower_bound
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
lower_bound_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
lower_bound_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
int
upper_bound
(
const
scope_name
&
scope
,
const
account_name
&
code
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
return
call
(
&
apply_context
::
upper_bound_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
auto
res
=
call
(
&
apply_context
::
upper_bound_record
<
IndexType
,
Scope
>
,
scope
,
code
,
table
,
data
,
data_len
);
return
(
res
>
0
)
?
res
+
sizeof
(
KeyArrayType
)
:
0
;
}
};
...
...
libraries/testing/tester.cpp
浏览文件 @
3cf761c9
...
...
@@ -174,6 +174,7 @@ namespace eosio { namespace testing {
Module
module
;
vector
<
Error
>
parse_errors
;
// TODO const_strlen(wast) blows the stack frame on debug build
parseModule
(
wast
,
fc
::
const_strlen
(
wast
),
module
,
parse_errors
);
if
(
!
parse_errors
.
empty
())
{
fc
::
exception
parse_exception
(
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
3cf761c9
...
...
@@ -317,7 +317,6 @@ BOOST_FIXTURE_TEST_CASE(action_tests, tester) { try {
}
);
CALL_TEST_FUNCTION
(
*
this
,
"test_action"
,
"require_notice"
,
raw_bytes
);
auto
scope
=
std
::
vector
<
account_name
>
{
N
(
testapi
)};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录