Skip to content

Commit

Permalink
Beekeeper fix. Wallets with a dot in a name are correctly found
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz-Trela authored and vogel76 committed Apr 18, 2024
1 parent 078dcae commit 76289ce
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
8 changes: 4 additions & 4 deletions programs/beekeeper/core/wallet_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ std::vector< std::string > wallet_manager_impl::list_created_wallets_impl( const
boost::split( _path_parts, itr->path().c_str(), boost::is_any_of("/") );
if( !_path_parts.empty() )
{
std::vector<std::string> _file_parts;
boost::split( _file_parts, *_path_parts.rbegin(), boost::is_any_of(".") );
if( !_file_parts.empty() )
_result.emplace_back( *_file_parts.begin() );
auto _end = *_path_parts.rbegin();
auto _found = _end.find( extension );
if( _found != std::string::npos )
_result.emplace_back( _end.substr( 0, _found ) );
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/tests/beekeeper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,37 @@ BOOST_AUTO_TEST_CASE(wallet_manager_sessions)
} FC_LOG_AND_RETHROW()
}

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

const std::string _host = "";
const uint64_t _timeout = 90;
const uint32_t _limit = 3;

appbase::application app;
{
bool _checker = false;
beekeeper_wallet_manager wm = b_mgr.create_wallet( app, _timeout, _limit, [&_checker](){ _checker = true; } );
BOOST_REQUIRE( wm.start() );

auto _token = wm.create_session( "aaaa", _host );

wm.create(_token, "...watermelon", std::optional<std::string>());
wm.create(_token, ".lemon", std::optional<std::string>());
wm.create(_token, ".peach.pear", std::optional<std::string>());
wm.create(_token, ".plum.", std::optional<std::string>());
wm.create(_token, "avocado.banana", std::optional<std::string>());

BOOST_REQUIRE_EQUAL( wm.list_created_wallets( _token ).size(), 5 );
BOOST_REQUIRE_EQUAL( wm.list_wallets( _token ).size(), 5 );
}

} FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE(wallet_manager_info)
{
try {
Expand Down

0 comments on commit 76289ce

Please sign in to comment.