Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
d2770060
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,发现更多精彩内容 >>
提交
d2770060
编写于
9月 06, 2018
作者:
K
Kayan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case for get_scope
上级
04fc7fae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
127 addition
and
4 deletion
+127
-4
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+1
-2
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
.../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
+1
-1
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-1
tests/get_table_tests.cpp
tests/get_table_tests.cpp
+124
-0
未找到文件。
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
d2770060
...
...
@@ -1136,8 +1136,7 @@ read_only::get_table_by_scope_result read_only::get_table_by_scope( const read_o
}
continue
;
}
get_table_by_scope_result_row
row
{
itr
->
code
,
itr
->
scope
,
itr
->
table
,
itr
->
payer
,
itr
->
count
};
result
.
rows
.
emplace_back
(
fc
::
variant
(
row
));
result
.
rows
.
push_back
({
itr
->
code
,
itr
->
scope
,
itr
->
table
,
itr
->
payer
,
itr
->
count
});
if
(
++
count
==
p
.
limit
||
fc
::
time_point
::
now
()
>
end
)
{
++
itr
;
break
;
...
...
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
浏览文件 @
d2770060
...
...
@@ -277,7 +277,7 @@ public:
uint32_t
count
;
};
struct
get_table_by_scope_result
{
vector
<
fc
::
variant
>
rows
;
///< one row per item, either encoded as hex String or JSON object
vector
<
get_table_by_scope_result_row
>
rows
;
bool
more
=
false
;
///< true if last element in data is not the end and sizeof data() < limit
};
...
...
tests/CMakeLists.txt
浏览文件 @
d2770060
...
...
@@ -13,7 +13,7 @@ set( CMAKE_CXX_STANDARD 14 )
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/plugins/wallet_plugin/include"
)
file
(
GLOB UNIT_TESTS
"
wallet_tests
.cpp"
)
file
(
GLOB UNIT_TESTS
"
*
.cpp"
)
add_executable
(
plugin_test
${
UNIT_TESTS
}
${
WASM_UNIT_TESTS
}
main.cpp
)
target_link_libraries
(
plugin_test eosio_testing eosio_chain chainbase eos_utilities chain_plugin wallet_plugin abi_generator fc
${
PLATFORM_SPECIFIC_LIBS
}
)
...
...
tests/get_table_tests.cpp
0 → 100644
浏览文件 @
d2770060
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <eosio/chain/wasm_eosio_constraints.hpp>
#include <eosio/chain/resource_limits.hpp>
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <asserter/asserter.wast.hpp>
#include <asserter/asserter.abi.hpp>
#include <stltest/stltest.wast.hpp>
#include <stltest/stltest.abi.hpp>
#include <eosio.system/eosio.system.wast.hpp>
#include <eosio.system/eosio.system.abi.hpp>
#include <eosio.token/eosio.token.wast.hpp>
#include <eosio.token/eosio.token.abi.hpp>
#include <fc/io/fstream.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <fc/io/json.hpp>
#include <array>
#include <utility>
#ifdef NON_VALIDATING_TEST
#define TESTER tester
#else
#define TESTER validating_tester
#endif
using
namespace
eosio
;
using
namespace
eosio
::
chain
;
using
namespace
eosio
::
testing
;
using
namespace
fc
;
BOOST_AUTO_TEST_SUITE
(
get_table_tests
)
BOOST_FIXTURE_TEST_CASE
(
get_scope_test
,
TESTER
)
try
{
produce_blocks
(
2
);
create_accounts
({
N
(
eosio
.
token
),
N
(
eosio
.
ram
),
N
(
eosio
.
ramfee
),
N
(
eosio
.
stake
),
N
(
eosio
.
bpay
),
N
(
eosio
.
vpay
),
N
(
eosio
.
saving
),
N
(
eosio
.
names
)
});
std
::
vector
<
account_name
>
accs
{
N
(
inita
),
N
(
initb
),
N
(
initc
),
N
(
initd
)};
create_accounts
(
accs
);
produce_block
();
set_code
(
N
(
eosio
.
token
),
eosio_token_wast
);
set_abi
(
N
(
eosio
.
token
),
eosio_token_abi
);
produce_blocks
(
1
);
// create currency
auto
act
=
mutable_variant_object
()
(
"issuer"
,
"eosio"
)
(
"maximum_supply"
,
eosio
::
chain
::
asset
::
from_string
(
"1000000000.0000 SYS"
));
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
act
);
// issue
for
(
account_name
a
:
accs
)
{
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
"eosio"
,
mutable_variant_object
()
(
"to"
,
name
(
a
)
)
(
"quantity"
,
eosio
::
chain
::
asset
::
from_string
(
"999.0000 SYS"
)
)
(
"memo"
,
""
)
);
}
produce_blocks
(
1
);
// iterate over scope
eosio
::
chain_apis
::
read_only
plugin
(
*
(
this
->
control
),
fc
::
microseconds
(
INT_MAX
));
eosio
::
chain_apis
::
read_only
::
get_table_by_scope_params
param
{
N
(
eosio
.
token
),
N
(
accounts
),
"inita"
,
""
,
10
};
eosio
::
chain_apis
::
read_only
::
get_table_by_scope_result
result
=
plugin
.
read_only
::
get_table_by_scope
(
param
);
BOOST_REQUIRE_EQUAL
(
4
,
result
.
rows
.
size
());
BOOST_REQUIRE_EQUAL
(
false
,
result
.
more
);
if
(
result
.
rows
.
size
()
>=
4
)
{
BOOST_REQUIRE_EQUAL
(
name
(
N
(
eosio
.
token
)),
result
.
rows
[
0
].
code
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
inita
)),
result
.
rows
[
0
].
scope
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
accounts
)),
result
.
rows
[
0
].
table
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
eosio
)),
result
.
rows
[
0
].
payer
);
BOOST_REQUIRE_EQUAL
(
1
,
result
.
rows
[
0
].
count
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
initb
)),
result
.
rows
[
1
].
scope
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
initc
)),
result
.
rows
[
2
].
scope
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
initd
)),
result
.
rows
[
3
].
scope
);
}
param
.
lower_bound
=
"initb"
;
param
.
upper_bound
=
"initd"
;
result
=
plugin
.
read_only
::
get_table_by_scope
(
param
);
BOOST_REQUIRE_EQUAL
(
2
,
result
.
rows
.
size
());
BOOST_REQUIRE_EQUAL
(
false
,
result
.
more
);
if
(
result
.
rows
.
size
()
>=
2
)
{
BOOST_REQUIRE_EQUAL
(
name
(
N
(
initb
)),
result
.
rows
[
0
].
scope
);
BOOST_REQUIRE_EQUAL
(
name
(
N
(
initc
)),
result
.
rows
[
1
].
scope
);
}
param
.
limit
=
1
;
result
=
plugin
.
read_only
::
get_table_by_scope
(
param
);
BOOST_REQUIRE_EQUAL
(
1
,
result
.
rows
.
size
());
BOOST_REQUIRE_EQUAL
(
true
,
result
.
more
);
param
.
table
=
name
(
0
);
result
=
plugin
.
read_only
::
get_table_by_scope
(
param
);
BOOST_REQUIRE_EQUAL
(
1
,
result
.
rows
.
size
());
BOOST_REQUIRE_EQUAL
(
true
,
result
.
more
);
param
.
table
=
N
(
invalid
);
result
=
plugin
.
read_only
::
get_table_by_scope
(
param
);
BOOST_REQUIRE_EQUAL
(
0
,
result
.
rows
.
size
());
BOOST_REQUIRE_EQUAL
(
false
,
result
.
more
);
}
FC_LOG_AND_RETHROW
()
/// get_scope_test
BOOST_AUTO_TEST_SUITE_END
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录