Skip to content

Commit

Permalink
Unlocking of any wallet should refresh timeout for given session. Rel…
Browse files Browse the repository at this point in the history
…ated to clive#235
  • Loading branch information
Mariusz-Trela authored and vogel76 committed Aug 3, 2024
1 parent b0764d0 commit 9b512aa
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions programs/beekeeper/core/beekeeper_wallet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void beekeeper_wallet_manager::lock( const std::string& token, const std::string

void beekeeper_wallet_manager::unlock( const std::string& token, const std::string& wallet_name, const std::string& password )
{
sessions->refresh_timeout( token );
sessions->get_wallet_manager( token )->unlock( wallet_name, password );
}

Expand Down
1 change: 1 addition & 0 deletions programs/beekeeper/core/include/core/session_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class session_base

void set_timeout( const std::chrono::seconds& t );
void check_timeout();
void refresh_timeout();

info get_info();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class session_manager_base

void set_timeout( const std::string& token, const std::chrono::seconds& t );
void check_timeout( const std::string& token );
void refresh_timeout( const std::string& token );
info get_info( const std::string& token );

std::shared_ptr<wallet_manager_impl> get_wallet_manager( const std::string& token );
Expand Down
5 changes: 5 additions & 0 deletions programs/beekeeper/core/session_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ void session_base::check_timeout()
refresh_timeout( true/*refresh_only_active*/ );
}

void session_base::refresh_timeout()
{
refresh_timeout( false/*refresh_only_active*/ );
}

void session_base::refresh_timeout( bool refresh_only_active )
{
auto _now = std::chrono::system_clock::now();
Expand Down
5 changes: 5 additions & 0 deletions programs/beekeeper/core/session_manager_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ void session_manager_base::check_timeout( const std::string& token )
get_session( token )->check_timeout();
}

void session_manager_base::refresh_timeout( const std::string& token )
{
get_session( token )->refresh_timeout();
}

info session_manager_base::get_info( const std::string& token )
{
return get_session( token )->get_info();
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/tests/beekeeper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,25 @@ BOOST_AUTO_TEST_CASE(beekeeper_timeout_list_wallets)
const size_t _wallet_cnt = 0;
BOOST_REQUIRE_EQUAL( _wallets[_wallet_cnt].unlocked, false );
}
{
const size_t _wallet_cnt = 1;
_beekeeper.unlock( _token, _wallets[_wallet_cnt].name, _wallets[_wallet_cnt].password );
}
{
auto _wallets = _beekeeper.list_wallets( _token );
BOOST_REQUIRE_EQUAL( _wallets.size(), 1 );
const size_t _wallet_cnt = 0;
BOOST_REQUIRE_EQUAL( _wallets[_wallet_cnt].unlocked, true );
}
{
std::this_thread::sleep_for( std::chrono::milliseconds(1200) );
}
{
auto _wallets = _beekeeper.list_wallets( _token );
BOOST_REQUIRE_EQUAL( _wallets.size(), 1 );
const size_t _wallet_cnt = 0;
BOOST_REQUIRE_EQUAL( _wallets[_wallet_cnt].unlocked, false );
}
} FC_LOG_AND_RETHROW()
}

Expand Down

0 comments on commit 9b512aa

Please sign in to comment.