Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
b2157180
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,发现更多精彩内容 >>
提交
b2157180
编写于
4月 24, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove plugin dependency from unit_tests
上级
31ed46cd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
1 addition
and
175 deletion
+1
-175
unittests/CMakeLists.txt
unittests/CMakeLists.txt
+1
-3
unittests/wallet_tests.cpp
unittests/wallet_tests.cpp
+0
-172
未找到文件。
unittests/CMakeLists.txt
浏览文件 @
b2157180
...
...
@@ -14,7 +14,6 @@ set( CMAKE_CXX_STANDARD 14 )
include_directories
(
"
${
CMAKE_BINARY_DIR
}
/contracts"
)
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/contracts"
)
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/plugins/wallet_plugin/include"
)
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/libraries/testing/include"
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.hpp.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.hpp ESCAPE_QUOTES
)
...
...
@@ -22,11 +21,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in ${CMAKE_CURRENT_SOURCE_
file
(
GLOB UNIT_TESTS
"*.cpp"
)
add_executable
(
unit_test
${
UNIT_TESTS
}
${
WASM_UNIT_TESTS
}
)
target_link_libraries
(
unit_test eosio_chain chainbase eosio_testing eos_utilities
wallet_plugin
abi_generator fc
${
PLATFORM_SPECIFIC_LIBS
}
)
target_link_libraries
(
unit_test eosio_chain chainbase eosio_testing eos_utilities abi_generator fc
${
PLATFORM_SPECIFIC_LIBS
}
)
target_include_directories
(
unit_test PUBLIC
${
CMAKE_BINARY_DIR
}
/contracts
${
CMAKE_CURRENT_BINARY_DIR
}
/tests/contracts
)
target_include_directories
(
unit_test PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/wasm_tests
)
target_include_directories
(
unit_test PUBLIC
${
CMAKE_SOURCE_DIR
}
/plugins/net_plugin/include
)
target_include_directories
(
unit_test PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
add_dependencies
(
unit_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange currency proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig
)
...
...
unittests/wallet_tests.cpp
已删除
100644 → 0
浏览文件 @
31ed46cd
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio/utilities/key_conversion.hpp>
#include <eosio/utilities/rand.hpp>
#include <eosio/wallet_plugin/wallet.hpp>
#include <eosio/wallet_plugin/wallet_manager.hpp>
#include <boost/test/unit_test.hpp>
#include <eosio/chain/authority.hpp>
namespace
eosio
{
BOOST_AUTO_TEST_SUITE
(
wallet_tests
)
/// Test creating the wallet
BOOST_AUTO_TEST_CASE
(
wallet_test
)
{
try
{
using
namespace
eosio
::
wallet
;
using
namespace
eosio
::
utilities
;
wallet_data
d
;
wallet_api
wallet
(
d
);
BOOST_CHECK
(
wallet
.
is_locked
());
wallet
.
set_password
(
"pass"
);
BOOST_CHECK
(
wallet
.
is_locked
());
wallet
.
unlock
(
"pass"
);
BOOST_CHECK
(
!
wallet
.
is_locked
());
wallet
.
set_wallet_filename
(
"test"
);
BOOST_CHECK_EQUAL
(
"test"
,
wallet
.
get_wallet_filename
());
BOOST_CHECK_EQUAL
(
0
,
wallet
.
list_keys
().
size
());
auto
priv
=
fc
::
crypto
::
private_key
::
generate
();
auto
pub
=
priv
.
get_public_key
();
auto
wif
=
(
std
::
string
)
priv
;
wallet
.
import_key
(
wif
);
BOOST_CHECK_EQUAL
(
1
,
wallet
.
list_keys
().
size
());
auto
privCopy
=
wallet
.
get_private_key
(
pub
);
BOOST_CHECK_EQUAL
(
wif
,
(
std
::
string
)
privCopy
);
wallet
.
lock
();
BOOST_CHECK
(
wallet
.
is_locked
());
wallet
.
unlock
(
"pass"
);
BOOST_CHECK_EQUAL
(
1
,
wallet
.
list_keys
().
size
());
wallet
.
save_wallet_file
(
"wallet_test.json"
);
wallet_data
d2
;
wallet_api
wallet2
(
d2
);
BOOST_CHECK
(
wallet2
.
is_locked
());
wallet2
.
load_wallet_file
(
"wallet_test.json"
);
BOOST_CHECK
(
wallet2
.
is_locked
());
wallet2
.
unlock
(
"pass"
);
BOOST_CHECK_EQUAL
(
1
,
wallet2
.
list_keys
().
size
());
auto
privCopy2
=
wallet2
.
get_private_key
(
pub
);
BOOST_CHECK_EQUAL
(
wif
,
(
std
::
string
)
privCopy2
);
}
FC_LOG_AND_RETHROW
()
}
/// Test wallet manager
BOOST_AUTO_TEST_CASE
(
wallet_manager_test
)
{
try
{
using
namespace
eosio
::
wallet
;
if
(
fc
::
exists
(
"test.wallet"
))
fc
::
remove
(
"test.wallet"
);
if
(
fc
::
exists
(
"test2.wallet"
))
fc
::
remove
(
"test2.wallet"
);
constexpr
auto
key1
=
"5JktVNHnRX48BUdtewU7N1CyL4Z886c42x7wYW7XhNWkDQRhdcS"
;
constexpr
auto
key2
=
"5Ju5RTcVDo35ndtzHioPMgebvBM6LkJ6tvuU6LTNQv8yaz3ggZr"
;
constexpr
auto
key3
=
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
;
// eosio key
wallet_manager
wm
;
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_wallets
().
size
());
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
BOOST_CHECK_NO_THROW
(
wm
.
lock_all
());
BOOST_CHECK_THROW
(
wm
.
lock
(
"test"
),
fc
::
exception
);
BOOST_CHECK_THROW
(
wm
.
unlock
(
"test"
,
"pw"
),
fc
::
exception
);
BOOST_CHECK_THROW
(
wm
.
import_key
(
"test"
,
"pw"
),
fc
::
exception
);
auto
pw
=
wm
.
create
(
"test"
);
BOOST_CHECK
(
!
pw
.
empty
());
BOOST_CHECK_EQUAL
(
0
,
pw
.
find
(
"PW"
));
// starts with PW
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_wallets
().
size
());
// eosio key is imported automatically when a wallet is created
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_keys
().
size
());
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
!=
std
::
string
::
npos
);
wm
.
lock
(
"test"
);
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
==
std
::
string
::
npos
);
wm
.
unlock
(
"test"
,
pw
);
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
!=
std
::
string
::
npos
);
wm
.
import_key
(
"test"
,
key1
);
BOOST_CHECK_EQUAL
(
2
,
wm
.
list_keys
().
size
());
auto
keys
=
wm
.
list_keys
();
auto
pub_pri_pair
=
[](
const
char
*
key
)
->
auto
{
private_key_type
prikey
=
private_key_type
(
std
::
string
(
key
));
return
std
::
pair
<
const
public_key_type
,
private_key_type
>
(
prikey
.
get_public_key
(),
prikey
);
};
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key1
))
!=
keys
.
cend
());
wm
.
import_key
(
"test"
,
key2
);
keys
=
wm
.
list_keys
();
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key1
))
!=
keys
.
cend
());
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key2
))
!=
keys
.
cend
());
// key3 was automatically imported
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key3
))
!=
keys
.
cend
());
wm
.
lock
(
"test"
);
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
wm
.
unlock
(
"test"
,
pw
);
BOOST_CHECK_EQUAL
(
3
,
wm
.
list_keys
().
size
());
wm
.
lock_all
();
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
==
std
::
string
::
npos
);
auto
pw2
=
wm
.
create
(
"test2"
);
BOOST_CHECK_EQUAL
(
2
,
wm
.
list_wallets
().
size
());
// eosio key is imported automatically when a wallet is created
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_keys
().
size
());
BOOST_CHECK_THROW
(
wm
.
import_key
(
"test2"
,
key3
),
fc
::
exception
);
keys
=
wm
.
list_keys
();
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key1
))
==
keys
.
cend
());
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key2
))
==
keys
.
cend
());
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key3
))
!=
keys
.
cend
());
wm
.
unlock
(
"test"
,
pw
);
keys
=
wm
.
list_keys
();
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key1
))
!=
keys
.
cend
());
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key2
))
!=
keys
.
cend
());
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
pub_pri_pair
(
key3
))
!=
keys
.
cend
());
private_key_type
pkey1
{
std
::
string
(
key1
)};
private_key_type
pkey2
{
std
::
string
(
key2
)};
private_key_type
pkey3
{
std
::
string
(
key3
)};
chain
::
signed_transaction
trx
;
flat_set
<
public_key_type
>
pubkeys
;
pubkeys
.
emplace
(
pkey1
.
get_public_key
());
pubkeys
.
emplace
(
pkey2
.
get_public_key
());
pubkeys
.
emplace
(
pkey3
.
get_public_key
());
trx
=
wm
.
sign_transaction
(
trx
,
pubkeys
,
chain_id_type
{});
const
auto
&
pks
=
trx
.
get_signature_keys
(
chain_id_type
{});
BOOST_CHECK_EQUAL
(
3
,
pks
.
size
());
BOOST_CHECK
(
find
(
pks
.
cbegin
(),
pks
.
cend
(),
pkey1
.
get_public_key
())
!=
pks
.
cend
());
BOOST_CHECK
(
find
(
pks
.
cbegin
(),
pks
.
cend
(),
pkey2
.
get_public_key
())
!=
pks
.
cend
());
BOOST_CHECK
(
find
(
pks
.
cbegin
(),
pks
.
cend
(),
pkey3
.
get_public_key
())
!=
pks
.
cend
());
BOOST_CHECK_EQUAL
(
3
,
wm
.
list_keys
().
size
());
wm
.
set_timeout
(
chrono
::
seconds
(
0
));
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
BOOST_CHECK
(
fc
::
exists
(
"test.wallet"
));
BOOST_CHECK
(
fc
::
exists
(
"test2.wallet"
));
fc
::
remove
(
"test.wallet"
);
fc
::
remove
(
"test2.wallet"
);
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_SUITE_END
()
}
// namespace eos
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录