Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HELpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
HELpy
Commits
715118d3
Commit
715118d3
authored
1 month ago
by
Krzysztof Mochocki
Browse files
Options
Downloads
Patches
Plain Diff
Fix duplicate keys random fail in tests
parent
253327e1
No related branches found
Branches containing commit
No related tags found
1 merge request
!76
Test hot fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/beekeepy_test/handle/api_tests/test_api_get_public_keys.py
+11
-8
11 additions, 8 deletions
...eekeepy_test/handle/api_tests/test_api_get_public_keys.py
with
11 additions
and
8 deletions
tests/beekeepy_test/handle/api_tests/test_api_get_public_keys.py
+
11
−
8
View file @
715118d3
...
...
@@ -11,6 +11,13 @@ if TYPE_CHECKING:
from
beekeepy.handle.runnable
import
Beekeeper
"""
NOTE 1: Usage of sets in this tests are intentional. It is because keys to import are generated by
random.sample() function 2 times (because of 2 wallets). This means that there is a chance that
the same key will be generated for both wallets. In such case, same key will be shown once in
get_public_keys response for call without wallet name. To avoid this, we are using sets to compare keys.
"""
def
open_and_unlock_wallet
(
beekeeper
:
Beekeeper
,
wallet
:
WalletInfo
)
->
None
:
beekeeper
.
api
.
open
(
wallet_name
=
wallet
.
name
)
...
...
@@ -58,15 +65,13 @@ def test_api_get_public_keys_with_many_wallets(beekeeper: Beekeeper, setup_walle
wallets
=
setup_wallets
(
2
,
import_keys
=
True
,
keys_per_wallet
=
5
)
wallet_1
=
wallets
[
0
]
wallet_2
=
wallets
[
1
]
all_keys
=
wallet_1
.
get_all_public_keys
()
+
wallet_2
.
get_all_public_keys
()
all_keys
.
sort
()
all_keys
=
set
(
wallet_1
.
get_all_public_keys
()
+
wallet_2
.
get_all_public_keys
())
# NOTE 1
# open and and unlock wallets
open_and_unlock_wallet
(
wallet
=
wallet_1
,
beekeeper
=
beekeeper
)
open_and_unlock_wallet
(
wallet
=
wallet_2
,
beekeeper
=
beekeeper
)
# Get ALL public key from bk it should contain both, wallet_1_keys and wallet_2_keys
bk_pub_keys_all
=
[
pub
.
public_key
for
pub
in
(
beekeeper
.
api
.
get_public_keys
()).
keys
]
bk_pub_keys_all
.
sort
()
bk_pub_keys_all
=
{
pub
.
public_key
for
pub
in
(
beekeeper
.
api
.
get_public_keys
()).
keys
}
# NOTE 1
assert
bk_pub_keys_all
==
all_keys
,
"
All keys should be available.
"
# ACT & ASSERT 1
...
...
@@ -94,16 +99,14 @@ def test_api_get_public_keys_with_many_wallets_closed(beekeeper: Beekeeper, setu
wallets
=
setup_wallets
(
2
,
import_keys
=
True
,
keys_per_wallet
=
5
)
wallet_1
=
wallets
[
0
]
wallet_2
=
wallets
[
1
]
all_keys
=
wallet_1
.
get_all_public_keys
()
+
wallet_2
.
get_all_public_keys
()
all_keys
.
sort
()
all_keys
=
set
(
wallet_1
.
get_all_public_keys
()
+
wallet_2
.
get_all_public_keys
())
# NOTE 1
# Open and unlock wallets
open_and_unlock_wallet
(
wallet
=
wallet_1
,
beekeeper
=
beekeeper
)
open_and_unlock_wallet
(
wallet
=
wallet_2
,
beekeeper
=
beekeeper
)
# Get all available public keys ()
bk_pub_keys_all
=
[
pub
.
public_key
for
pub
in
(
beekeeper
.
api
.
get_public_keys
()).
keys
]
bk_pub_keys_all
.
sort
()
bk_pub_keys_all
=
{
pub
.
public_key
for
pub
in
(
beekeeper
.
api
.
get_public_keys
()).
keys
}
# NOTE 1
assert
bk_pub_keys_all
==
all_keys
,
"
Keys from wallet 1 and wallet 2 should be available.
"
# ACT & ASSERT 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment