From 76d77373414d534427a6ba38be7cbc9839e1e568 Mon Sep 17 00:00:00 2001 From: Daniel Krol Date: Fri, 24 Jun 2022 11:30:53 -0400 Subject: [PATCH] Split out wallet test init --- store/store_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/store/store_test.go b/store/store_test.go index a7b8874..fadc4c4 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -306,6 +306,13 @@ func expectWalletNotExists(t *testing.T, s *Store, userId auth.UserId) { } } +func setupWalletTest() auth.UserId { + email, password := auth.Email("abc@example.com"), auth.Password("123") + _ = s.CreateAccount(email, password) + userId, _ := s.GetUserId(email, password) + return userId +} + // Test insertFirstWallet, using GetWallet, CreateAccount and GetUserID as a helpers // Try insertFirstWallet twice with the same user id, error the second time func TestStoreInsertWallet(t *testing.T) { @@ -313,9 +320,7 @@ func TestStoreInsertWallet(t *testing.T) { defer StoreTestCleanup(sqliteTmpFile) // Get a valid userId - email, password := auth.Email("abc@example.com"), auth.Password("123") - _ = s.CreateAccount(email, password) - userId, _ := s.GetUserId(email, password) + userId = setupWalletTest() // Get a wallet, come back empty expectWalletNotExists(t, &s, userId) @@ -347,9 +352,7 @@ func TestStoreUpdateWallet(t *testing.T) { defer StoreTestCleanup(sqliteTmpFile) // Get a valid userId - email, password := auth.Email("abc@example.com"), auth.Password("123") - _ = s.CreateAccount(email, password) - userId, _ := s.GetUserId(email, password) + userId = setupWalletTest() // Try to update a wallet, fail for nothing to update if err := s.updateWalletToSequence(userId, wallet.EncryptedWallet("my-encrypted-wallet-a"), wallet.Sequence(1), wallet.WalletHmac("my-hmac-a")); err != ErrNoWallet {