beekeeper | Problem (?) with locking wallet
Based on https://gitlab.syncad.com/hive/clive/-/jobs/794458
We have a test, that checks if the wallet is locked after some period of time - by passing --unlock-timeout
flag.
Here is the test
async def check_wallet_lock(beekeeper: Beekeeper, required_status: bool) -> None:
"""Check if wallets are have required unlock status."""
response_list_wallets = await beekeeper.api.list_wallets()
for wallet in response_list_wallets.wallets:
assert wallet.unlocked == required_status
@pytest.mark.parametrize("unlock_timeout", [2, 3, 4])
async def test_unlock_time(unlock_timeout: int) -> None:
"""Test will check command line flag --unlock-time."""
beekeeper = await Beekeeper().launch(unlock_timeout=unlock_timeout)
await beekeeper.api.create(wallet_name="wallet_name")
await check_wallet_lock(beekeeper, True) <-- here wallet SHOULD be unlocked
await asyncio.sleep(int(unlock_timeout))
await check_wallet_lock(beekeeper, False) <-- here wallet SHOULD be locked
Here we are launching bk with flag --unlock-timeout, wait that time, and check if the wallet was locked. Yet, lately, we have encountered an issue during CI, that shows us that the wallet was unlocked after this period of time.
Here is a log (where unlock-timeout = 2[s]):
2029744ms json_rpc_plugin.cpp:225 initialize ] initializing JSON RPC plugin
2029744ms webserver_plugin.cpp:587 plugin_initialize ] initializing webserver plugin
2029744ms webserver_plugin.cpp:590 plugin_initialize ] configured with 1 thread pool size
2029744ms webserver_plugin.cpp:593 plugin_initialize ] Compression in webserver is disabled
2029745ms webserver_plugin.cpp:605 plugin_initialize ] configured http to listen on 0.0.0.0:0
2029745ms beekeeper_app_init.cpp:163 initialize_program_o ] initializing options
2029745ms notifications.cpp:64 setup ] setting up notification handler for 1 address
2029747ms beekeeper_app_init.cpp:188 initialize_program_o ] Backtrace on segfault is enabled.
2029748ms application.cpp:193 startup ] Setting up a startup_io_handler...
2029748ms webserver_plugin.cpp:293 operator() ] start processing http thread
2029748ms application.cpp:505 exec ] Entering application main loop...
2029748ms webserver_plugin.cpp:308 operator() ] start listening for http requests on 0.0.0.0:42429
2029754ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.create_session","params":{"notifications_endpoint":"127.0.0.1:37403","salt":"140318016414640"}}
2029764ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.create","params":{"wallet_name":"wallet_name","token":"f97302aa47cf5b0ff625e09ea4a8339c29b3b05c55b843e12b712b93bb64b2fe"}}
2029765ms beekeeper_wallet.cpp:189 save_wallet_file ] saving wallet to file /builds/hive/clive/tests/functional/beekeeper/commandline/application_options/generated_during_test_unlock_timeout/test_unlock_time_with_parameters_2/beekeeper/wallet_name.wallet
2029770ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.list_wallets","params":{"token":"f97302aa47cf5b0ff625e09ea4a8339c29b3b05c55b843e12b712b93bb64b2fe"}}
2031776ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.list_wallets","params":{"token":"f97302aa47cf5b0ff625e09ea4a8339c29b3b05c55b843e12b712b93bb64b2fe"}}
Two last lines are crucial
2029770ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.list_wallets","params":{"token":""}}
2031776ms json_rpc_plugin.cpp:443 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.list_wallets","params":{"token":""}}
If we substrack 2031776ms - 2029770ms = 2006ms
If we take into account 2s of unlock-timeout we get 6ms for lock time...
YES, I KNOW THAT IS A VERY SMALL VALUE
, and end-user would not see it, but the user can be a bot as well, and now it makes a difference (as we can see on that test).
We discussed it with @mzebrak and decided that it would be nice, to make an issue, so that we may discuss if we should be concern or not.
That's why this issue has a discussion
label.