Skip to content

Commit

Permalink
backend/backend_test: add missing use of checkShownAccountsLen
Browse files Browse the repository at this point in the history
Avoid sporadic test failures due to race conditions.
  • Loading branch information
benma committed Dec 5, 2023
1 parent 3f74756 commit 54f0583
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 3 additions & 4 deletions backend/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,7 @@ func TestAccountSupported(t *testing.T) {

// Registering a new keystore persists a set of initial default accounts.
b.registerKeystore(bb02Multi)
require.Len(t, b.Accounts(), 3)
require.Len(t, b.Config().AccountsConfig().Accounts, 3)
checkShownAccountsLen(t, b, 3, 3)

b.DeregisterKeystore()
// Registering a Bitcoin-only like keystore loads also the altcoins that were persisted
Expand All @@ -1064,8 +1063,8 @@ func TestInactiveAccount(t *testing.T) {

// 1) Registering a new keystore persists a set of initial default accounts.
b.registerKeystore(bitbox02LikeKeystore)
require.Len(t, b.Accounts(), 3)
require.Len(t, b.Config().AccountsConfig().Accounts, 3)

checkShownAccountsLen(t, b, 3, 3)
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-btc-0"))
require.False(t, b.Config().AccountsConfig().Lookup("v0-55555555-btc-0").Inactive)
require.True(t, !lookup(b.Accounts(), "v0-55555555-btc-0").Config().Config.Inactive)
Expand Down
9 changes: 3 additions & 6 deletions backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ func TestRegisterKeystore(t *testing.T) {
b := newBackend(t, testnetDisabled, regtestDisabled)
defer b.Close()

require.Len(t, b.Accounts(), 0)
require.Len(t, b.Config().AccountsConfig().Accounts, 0)
checkShownAccountsLen(t, b, 0, 0)

// Registering a new keystore persists a set of initial default accounts and the keystore.
b.registerKeystore(ks1)
require.Equal(t, ks1, b.Keystore())
require.Len(t, b.Accounts(), 3)
require.Len(t, b.Config().AccountsConfig().Accounts, 3)
checkShownAccountsLen(t, b, 3, 3)
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-btc-0"))
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-ltc-0"))
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-eth-0"))
Expand Down Expand Up @@ -208,8 +206,7 @@ func TestAccounts(t *testing.T) {

// 1) Registering a new keystore persists a set of initial default accounts.
b.registerKeystore(ks)
require.Len(t, b.Accounts(), 3)
require.Len(t, b.Config().AccountsConfig().Accounts, 3)
checkShownAccountsLen(t, b, 3, 3)
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-btc-0"))
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-ltc-0"))
require.NotNil(t, b.Config().AccountsConfig().Lookup("v0-55555555-eth-0"))
Expand Down

0 comments on commit 54f0583

Please sign in to comment.