Skip to content

Commit

Permalink
Complex wallet name is correctly processed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz-Trela authored and vogel76 committed Jul 17, 2024
1 parent 9367533 commit afd6fcb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion programs/beekeeper/core/wallet_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ std::vector< std::string > wallet_manager_impl::list_created_wallets_impl( const
if( !_path_parts.empty() )
{
auto _end = *_path_parts.rbegin();
auto _found = _end.find( extension );
auto _found = _end.rfind( extension );
if( _found != std::string::npos )
_result.emplace_back( _end.substr( 0, _found ) );
}
Expand Down
29 changes: 28 additions & 1 deletion tests/unit/tests/beekeeper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ BOOST_AUTO_TEST_CASE(wallet_test)

} FC_LOG_AND_RETHROW() }


BOOST_AUTO_TEST_CASE(wallet_name_test)
{ try {
test_utils::beekeeper_mgr b_mgr;
Expand Down Expand Up @@ -150,6 +149,34 @@ BOOST_AUTO_TEST_CASE(wallet_name_test)

} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_CASE(wallet_complex_name_test)
{ try {
test_utils::beekeeper_mgr b_mgr;
b_mgr.remove_wallets();

appbase::application app;

beekeeper_wallet_manager wm = b_mgr.create_wallet( app, 900, 3 );

BOOST_REQUIRE( wm.start() );
std::string _token = wm.create_session( "this is salt", std::optional<std::string>() );

std::string _wallet_name = "small.minion.wallet";

wm.create( _token, _wallet_name, std::optional<std::string>() );
BOOST_REQUIRE_EQUAL( wm.list_created_wallets( _token ).size(), 1 );
BOOST_REQUIRE_EQUAL( wm.list_wallets( _token ).size(), 1 );

wm.lock( _token, _wallet_name );
BOOST_REQUIRE_EQUAL( wm.list_created_wallets( _token ).size(), 1 );
BOOST_REQUIRE_EQUAL( wm.list_wallets( _token ).size(), 1 );

wm.open( _token, _wallet_name );
BOOST_REQUIRE_EQUAL( wm.list_created_wallets( _token ).size(), 1 );
BOOST_REQUIRE_EQUAL( wm.list_wallets( _token ).size(), 1 );

} FC_LOG_AND_RETHROW() }

/// Test wallet manager
BOOST_AUTO_TEST_CASE(wallet_manager_test)
{ try {
Expand Down

0 comments on commit afd6fcb

Please sign in to comment.