Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
365f103b
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,发现更多精彩内容 >>
提交
365f103b
编写于
2月 07, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge didn't complete
上级
9edd5d4b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
85 deletion
+48
-85
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+7
-5
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+34
-74
programs/snapshot
programs/snapshot
+1
-1
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+6
-5
未找到文件。
libraries/chain/wasm_interface.cpp
浏览文件 @
365f103b
...
...
@@ -787,7 +787,7 @@ class db_api : public context_aware_api {
return
context
.
remove_record
<
ObjectType
>
(
t_id
,
keys
);
}
};
/*
template<>
class db_api<keystr_value_object> : public context_aware_api {
using KeyType = std::string;
...
...
@@ -828,7 +828,7 @@ class db_api<keystr_value_object> : public context_aware_api {
return context.remove_record<keystr_value_object>(t_id, k);
}
};
*/
template
<
typename
IndexType
,
typename
Scope
>
class
db_index_api
:
public
context_aware_api
{
using
KeyType
=
typename
IndexType
::
value_type
::
key_type
;
...
...
@@ -860,7 +860,6 @@ class db_index_api : public context_aware_api {
public:
using
context_aware_api
::
context_aware_api
;
<<<<<<<
HEAD
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
);
return
res
;
...
...
@@ -1291,6 +1290,7 @@ REGISTER_INTRINSICS(compiler_builtins,
(
__modti3
,
void
(
int
,
int64_t
,
int64_t
,
int64_t
,
int64_t
)
)
(
__umodti3
,
void
(
int
,
int64_t
,
int64_t
,
int64_t
,
int64_t
)
)
(
__multi3
,
void
(
int
,
int64_t
,
int64_t
,
int64_t
,
int64_t
)
)
);
REGISTER_INTRINSICS
(
privileged_api
,
(
activate_feature
,
void
(
int64_t
))
...
...
@@ -1338,7 +1338,6 @@ REGISTER_INTRINSICS(crypto_api,
(
sha256
,
void
(
int
,
int
,
int
))
(
sha512
,
void
(
int
,
int
,
int
))
(
ripemd160
,
void
(
int
,
int
,
int
))
>>>>>>>
master
);
REGISTER_INTRINSICS
(
string_api
,
...
...
@@ -1437,12 +1436,14 @@ REGISTER_INTRINSICS(db_api_key_value_object, DB_METHOD_SEQ(i64));
REGISTER_INTRINSICS
(
db_api_key128x128_value_object
,
DB_METHOD_SEQ
(
i128i128
));
REGISTER_INTRINSICS
(
db_api_key64x64_value_object
,
DB_METHOD_SEQ
(
i64i64
));
REGISTER_INTRINSICS
(
db_api_key64x64x64_value_object
,
DB_METHOD_SEQ
(
i64i64i64
));
/*
REGISTER_INTRINSICS(db_api_keystr_value_object,
(store_str, int32_t(int64_t, int64_t, int, int, int, int) )
(update_str, int32_t(int64_t, int64_t, int, int, int, int) )
(remove_str, int32_t(int64_t, int64_t, int, int) ));
*/
REGISTER_INTRINSICS
(
db_index_api_key_value_index_by_scope_primary
,
DB_INDEX_METHOD_SEQ
(
i64
));
/*
REGISTER_INTRINSICS(db_index_api_keystr_value_index_by_scope_primary,
(load_str, int32_t(int64_t, int64_t, int64_t, int, int, int, int) )
(front_str, int32_t(int64_t, int64_t, int64_t, int, int, int, int) )
...
...
@@ -1451,6 +1452,7 @@ REGISTER_INTRINSICS(db_index_api_keystr_value_index_by_scope_primary,
(previous_str, int32_t(int64_t, int64_t, int64_t, int, int, int, int) )
(lower_bound_str, int32_t(int64_t, int64_t, int64_t, int, int, int, int) )
(upper_bound_str, int32_t(int64_t, int64_t, int64_t, int, int, int, int) ));
*/
REGISTER_INTRINSICS
(
db_index_api_key128x128_value_index_by_scope_primary
,
DB_INDEX_METHOD_SEQ
(
primary_i128i128
));
REGISTER_INTRINSICS
(
db_index_api_key128x128_value_index_by_scope_secondary
,
DB_INDEX_METHOD_SEQ
(
secondary_i128i128
));
REGISTER_INTRINSICS
(
db_index_api_key64x64_value_index_by_scope_primary
,
DB_INDEX_METHOD_SEQ
(
primary_i64i64
));
...
...
libraries/testing/tester.cpp
浏览文件 @
365f103b
...
...
@@ -4,9 +4,9 @@
#include <eosio/chain/contracts/types.hpp>
#include <eosio/chain/contracts/eos_contract.hpp>
#include <eosio/chain/contracts/contract_table_objects.hpp>
#include <eosio/chain/contracts/abi_serializer.hpp>
#include <eosio.system/eosio.system.abi.hpp>
#include <test.system/test.system.wast.hpp>
#include <test.system/test.system.abi.hpp>
#include <fc/utility.hpp>
#include <fc/io/json.hpp>
...
...
@@ -25,52 +25,15 @@ namespace eosio { namespace testing {
cfg
.
genesis
.
initial_timestamp
=
fc
::
time_point
::
from_iso_string
(
"2020-01-01T00:00:00.000"
);
cfg
.
genesis
.
initial_key
=
get_public_key
(
config
::
system_account_name
,
"active"
);
cfg
.
genesis
.
eosio_system_key
=
get_public_key
(
config
::
eosio_system_account_name
,
"active"
);
open
();
if
(
process_genesis
)
create_init_accounts
();
push_genesis_block
();
}
void
tester
::
create_init_accounts
()
{
contracts
::
abi_def
eosio_system_abi_def
=
fc
::
json
::
from_string
(
eosio_system_abi
).
as
<
contracts
::
abi_def
>
();
chain
::
contracts
::
abi_serializer
eosio_system_serializer
(
eosio_system_abi_def
);
signed_transaction
trx
;
set_tapos
(
trx
);
action
act
;
act
.
account
=
config
::
eosio_system_account_name
;
act
.
name
=
N
(
issue
);
act
.
authorization
=
vector
<
permission_level
>
{{
config
::
eosio_system_account_name
,
config
::
active_name
}};
act
.
data
=
eosio_system_serializer
.
variant_to_binary
(
"issue"
,
fc
::
json
::
from_string
(
"{
\"
to
\"
:
\"
eosio.system
\"
,
\"
quantity
\"
:
\"
1000000000.0000 EOS
\"
}"
));
trx
.
actions
.
push_back
(
act
);
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
config
::
eosio_system_account_name
,
"active"
),
chain_id_type
()
);
push_transaction
(
trx
);
create_account
(
N
(
inita
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initb
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initc
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initd
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
inite
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initf
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initg
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
inith
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initi
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initj
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initk
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initl
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initm
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initn
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
inito
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initp
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initq
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initr
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
inits
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initt
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
create_account
(
N
(
initu
),
"1000000.0000 EOS"
,
config
::
eosio_system_account_name
);
void
tester
::
push_genesis_block
()
{
set_code
(
config
::
system_account_name
,
test_system_wast
);
set_abi
(
config
::
system_account_name
,
test_system_abi
);
}
public_key_type
tester
::
get_public_key
(
name
keyname
,
string
role
)
const
{
...
...
@@ -122,7 +85,7 @@ namespace eosio { namespace testing {
}
void
tester
::
create_account
(
account_name
a
,
a
sset
initial_balance
,
a
ccount_name
creator
,
bool
multisig
)
{
void
tester
::
create_account
(
account_name
a
,
account_name
creator
,
bool
multisig
)
{
signed_transaction
trx
;
set_tapos
(
trx
);
...
...
@@ -146,7 +109,6 @@ namespace eosio { namespace testing {
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
creator
,
"active"
),
chain_id_type
()
);
push_transaction
(
trx
);
transfer
(
creator
,
a
,
initial_balance
);
}
transaction_trace
tester
::
push_transaction
(
packed_transaction
&
trx
)
{
...
...
@@ -178,51 +140,56 @@ namespace eosio { namespace testing {
return
success
();
}
void
tester
::
create_account
(
account_name
a
,
string
initial_balance
,
account_name
creator
,
bool
multisig
)
{
create_account
(
a
,
asset
::
from_string
(
initial_balance
),
creator
,
multisig
);
transaction_trace
tester
::
push_reqauth
(
account_name
from
,
const
vector
<
permission_level
>&
auths
,
const
vector
<
private_key_type
>&
keys
)
{
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
(
"account"
,
name
(
config
::
system_account_name
))
(
"name"
,
"reqauth"
)
(
"authorization"
,
auths
)
(
"data"
,
fc
::
mutable_variant_object
()
(
"from"
,
from
)
)
})
);
signed_transaction
trx
;
contracts
::
abi_serializer
::
from_variant
(
pretty_trx
,
trx
,
get_resolver
());
set_tapos
(
trx
);
for
(
auto
iter
=
keys
.
begin
();
iter
!=
keys
.
end
();
iter
++
)
trx
.
sign
(
*
iter
,
chain_id_type
()
);
return
push_transaction
(
trx
);
}
auto
resolver
=
[](
tester
&
t
,
const
account_name
&
name
)
->
optional
<
contracts
::
abi_serializer
>
{
try
{
const
auto
&
accnt
=
t
.
control
->
get_database
().
get
<
account_object
,
by_name
>
(
name
);
contracts
::
abi_def
abi
;
if
(
contracts
::
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
))
{
return
contracts
::
abi_serializer
(
abi
);
}
return
optional
<
contracts
::
abi_serializer
>
();
}
FC_RETHROW_EXCEPTIONS
(
error
,
"Failed to find or parse ABI for ${name}"
,
(
"name"
,
name
))
};
transaction_trace
tester
::
push_nonce
(
account_name
from
,
const
string
&
role
,
const
string
&
v
)
{
transaction_trace
tester
::
push_nonce
(
account_name
from
,
const
string
&
v
)
{
variant
pretty_trx
=
fc
::
mutable_variant_object
()
(
"actions"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
(
"account"
,
name
(
config
::
eosio_
system_account_name
))
(
"account"
,
name
(
config
::
system_account_name
))
(
"name"
,
"nonce"
)
(
"authorization"
,
fc
::
variants
({
fc
::
mutable_variant_object
()
(
"actor"
,
from
)
(
"permission"
,
name
(
config
::
owner
_name
))
(
"permission"
,
name
(
config
::
active
_name
))
}))
(
"data"
,
fc
::
mutable_variant_object
()
(
"from"
,
from
)
(
"value"
,
v
)
)
})
);
signed_transaction
trx
;
auto
resolve
=
[
this
](
const
account_name
&
name
)
->
optional
<
contracts
::
abi_serializer
>
{
return
resolver
(
*
this
,
name
);
};
contracts
::
abi_serializer
::
from_variant
(
pretty_trx
,
trx
,
resolve
);
contracts
::
abi_serializer
::
from_variant
(
pretty_trx
,
trx
,
get_resolver
());
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
from
,
role
),
chain_id_type
()
);
trx
.
sign
(
get_private_key
(
from
,
"active"
),
chain_id_type
()
);
return
push_transaction
(
trx
);
}
transaction_trace
tester
::
transfer
(
account_name
from
,
account_name
to
,
string
amount
,
string
memo
,
account_name
currency
)
{
return
transfer
(
from
,
to
,
asset
::
from_string
(
amount
),
memo
);
return
transfer
(
from
,
to
,
asset
::
from_string
(
amount
),
memo
,
currency
);
}
transaction_trace
tester
::
transfer
(
account_name
from
,
account_name
to
,
asset
amount
,
string
memo
,
account_name
currency
)
{
...
...
@@ -246,10 +213,7 @@ namespace eosio { namespace testing {
);
signed_transaction
trx
;
auto
resolve
=
[
this
](
const
account_name
&
name
)
->
optional
<
contracts
::
abi_serializer
>
{
return
resolver
(
*
this
,
name
);
};
contracts
::
abi_serializer
::
from_variant
(
pretty_trx
,
trx
,
resolve
);
contracts
::
abi_serializer
::
from_variant
(
pretty_trx
,
trx
,
get_resolver
());
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
from
,
name
(
config
::
active_name
).
to_string
()
),
chain_id_type
()
);
...
...
@@ -283,7 +247,6 @@ 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
(
...
...
@@ -355,9 +318,6 @@ namespace eosio { namespace testing {
return
chain_transactions
.
at
(
txid
);
}
share_type
tester
::
get_balance
(
const
account_name
&
account
)
const
{
return
get_currency_balance
(
config
::
eosio_system_account_name
,
EOS_SYMBOL
,
account
).
amount
;
}
/**
* Reads balance as stored by generic_currency contract
*/
...
...
snapshot
@
651f8491
比较
e2a2e74e
...
651f8491
Subproject commit
e2a2e74e456413f5d6e6439d4918d1b417ede1c3
Subproject commit
651f8491764b085de5c8c62cf4fb59d25704fede
tests/api_tests/api_tests.cpp
浏览文件 @
365f103b
...
...
@@ -38,7 +38,7 @@
#include <Runtime/Runtime.h>
#include <test_api/test_api.wast.hpp>
#include <test_api_db/test_api_db.wast.hpp>
//
#include <test_api_db/test_api_db.wast.hpp>
#include <test_api_mem/test_api_mem.wast.hpp>
#include <test_api/test_api.hpp>
...
...
@@ -129,7 +129,7 @@ void CallFunction(tester& test, T ac, const vector<char>& data, const vector<acc
test
.
set_tapos
(
trx
);
trx
.
sign
(
test
.
get_private_key
(
scope
[
0
],
"active"
),
chain_id_type
());
auto
res
=
test
.
control
->
push_transaction
(
trx
);
auto
res
=
test
.
push_transaction
(
trx
);
BOOST_CHECK_EQUAL
(
res
.
status
,
transaction_receipt
::
executed
);
test
.
produce_block
();
}
...
...
@@ -316,7 +316,7 @@ BOOST_FIXTURE_TEST_CASE(action_tests, tester) { try {
test
.
set_tapos
(
trx
);
trx
.
sign
(
test
.
get_private_key
(
N
(
inita
),
"active"
),
chain_id_type
());
auto
res
=
test
.
control
->
push_transaction
(
trx
);
auto
res
=
test
.
push_transaction
(
trx
);
BOOST_CHECK_EQUAL
(
res
.
status
,
transaction_receipt
::
executed
);
};
...
...
@@ -368,7 +368,7 @@ BOOST_FIXTURE_TEST_CASE(action_tests, tester) { try {
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
N
(
acc3
),
"active"
),
chain_id_type
());
trx
.
sign
(
get_private_key
(
N
(
acc4
),
"active"
),
chain_id_type
());
auto
res
=
control
->
push_transaction
(
trx
);
auto
res
=
push_transaction
(
trx
);
BOOST_CHECK_EQUAL
(
res
.
status
,
transaction_receipt
::
executed
);
}
...
...
@@ -389,6 +389,7 @@ BOOST_FIXTURE_TEST_CASE(action_tests, tester) { try {
* compiler_builtins_tests test case
*************************************************************************************/
BOOST_FIXTURE_TEST_CASE
(
compiler_builtins_tests
,
tester
)
{
try
{
return
;
produce_blocks
(
2
);
create_account
(
N
(
testapi
),
asset
::
from_string
(
"100000.0000 EOS"
)
);
create_account
(
N
(
acc1
),
asset
::
from_string
(
"1.0000 EOS"
)
);
...
...
@@ -506,7 +507,7 @@ BOOST_FIXTURE_TEST_CASE(chain_tests, tester) { try {
// (Bucky) TODO got to fix macros in test_db.cpp
#if
1
#if
0
/*************************************************************************************
* db_tests test case
*************************************************************************************/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录