Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
8531b006
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,发现更多精彩内容 >>
提交
8531b006
编写于
7月 28, 2017
作者:
B
Brian Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding some tests for wallet
上级
56ffe903
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
55 addition
and
1 deletion
+55
-1
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-1
tests/tests/misc_tests.cpp
tests/tests/misc_tests.cpp
+54
-0
未找到文件。
tests/CMakeLists.txt
浏览文件 @
8531b006
...
@@ -8,7 +8,7 @@ endif()
...
@@ -8,7 +8,7 @@ endif()
file
(
GLOB UNIT_TESTS
"tests/*.cpp"
)
file
(
GLOB UNIT_TESTS
"tests/*.cpp"
)
add_executable
(
chain_test
${
UNIT_TESTS
}
${
COMMON_SOURCES
}
)
add_executable
(
chain_test
${
UNIT_TESTS
}
${
COMMON_SOURCES
}
)
target_link_libraries
(
chain_test eos_native_contract eos_chain chainbase eos_utilities eos_egenesis_none fc
${
PLATFORM_SPECIFIC_LIBS
}
)
target_link_libraries
(
chain_test eos_native_contract eos_chain chainbase eos_utilities eos_egenesis_none
eos_wallet
fc
${
PLATFORM_SPECIFIC_LIBS
}
)
if
(
WASM_TOOLCHAIN
)
if
(
WASM_TOOLCHAIN
)
file
(
GLOB SLOW_TESTS
"slow_tests/*.cpp"
)
file
(
GLOB SLOW_TESTS
"slow_tests/*.cpp"
)
...
...
tests/tests/misc_tests.cpp
浏览文件 @
8531b006
#include <eos/chain/BlockchainConfiguration.hpp>
#include <eos/chain/BlockchainConfiguration.hpp>
#include <eos/chain/authority.hpp>
#include <eos/chain/authority.hpp>
#include <eos/utilities/key_conversion.hpp>
#include <eos/utilities/rand.hpp>
#include <eos/utilities/rand.hpp>
#include <eos/wallet/wallet.hpp>
#include <fc/io/json.hpp>
#include <fc/io/json.hpp>
...
@@ -130,6 +132,58 @@ BOOST_AUTO_TEST_CASE(authority_checker)
...
@@ -130,6 +132,58 @@ BOOST_AUTO_TEST_CASE(authority_checker)
BOOST_CHECK
(
!
MakeAuthorityChecker
(
GetCAuthority
,
{
b
}).
satisfied
(
A
));
BOOST_CHECK
(
!
MakeAuthorityChecker
(
GetCAuthority
,
{
b
}).
satisfied
(
A
));
}
FC_LOG_AND_RETHROW
()
}
}
FC_LOG_AND_RETHROW
()
}
/// Test creating the wallet
BOOST_AUTO_TEST_CASE
(
wallet_test
)
{
try
{
using
namespace
eos
::
wallet
;
using
namespace
eos
::
utilities
;
wallet_data
d
;
d
.
ws_server
=
"test_server"
;
d
.
ws_port
=
99
;
d
.
ws_user
=
"bob"
;
d
.
ws_password
=
"user_pwd"
;
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
());
BOOST_CHECK_EQUAL
(
0
,
wallet
.
list_keys
().
size
());
auto
priv
=
fc
::
ecc
::
private_key
::
generate
();
auto
pub
=
public_key_type
(
priv
.
get_public_key
()
);
auto
wif
=
key_to_wif
(
priv
.
get_secret
());
wallet
.
import_key
(
wif
);
BOOST_CHECK_EQUAL
(
1
,
wallet
.
list_keys
().
size
());
auto
privCopy
=
wallet
.
get_private_key
(
pub
);
BOOST_CHECK_EQUAL
(
wif
,
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
,
privCopy2
);
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_END
()
}
// namespace eos
}
// namespace eos
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录