Split out wallet test init
This commit is contained in:
parent
377f598b23
commit
76d7737341
1 changed files with 9 additions and 6 deletions
|
@ -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
|
// Test insertFirstWallet, using GetWallet, CreateAccount and GetUserID as a helpers
|
||||||
// Try insertFirstWallet twice with the same user id, error the second time
|
// Try insertFirstWallet twice with the same user id, error the second time
|
||||||
func TestStoreInsertWallet(t *testing.T) {
|
func TestStoreInsertWallet(t *testing.T) {
|
||||||
|
@ -313,9 +320,7 @@ func TestStoreInsertWallet(t *testing.T) {
|
||||||
defer StoreTestCleanup(sqliteTmpFile)
|
defer StoreTestCleanup(sqliteTmpFile)
|
||||||
|
|
||||||
// Get a valid userId
|
// Get a valid userId
|
||||||
email, password := auth.Email("abc@example.com"), auth.Password("123")
|
userId = setupWalletTest()
|
||||||
_ = s.CreateAccount(email, password)
|
|
||||||
userId, _ := s.GetUserId(email, password)
|
|
||||||
|
|
||||||
// Get a wallet, come back empty
|
// Get a wallet, come back empty
|
||||||
expectWalletNotExists(t, &s, userId)
|
expectWalletNotExists(t, &s, userId)
|
||||||
|
@ -347,9 +352,7 @@ func TestStoreUpdateWallet(t *testing.T) {
|
||||||
defer StoreTestCleanup(sqliteTmpFile)
|
defer StoreTestCleanup(sqliteTmpFile)
|
||||||
|
|
||||||
// Get a valid userId
|
// Get a valid userId
|
||||||
email, password := auth.Email("abc@example.com"), auth.Password("123")
|
userId = setupWalletTest()
|
||||||
_ = s.CreateAccount(email, password)
|
|
||||||
userId, _ := s.GetUserId(email, password)
|
|
||||||
|
|
||||||
// Try to update a wallet, fail for nothing to update
|
// 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 {
|
if err := s.updateWalletToSequence(userId, wallet.EncryptedWallet("my-encrypted-wallet-a"), wallet.Sequence(1), wallet.WalletHmac("my-hmac-a")); err != ErrNoWallet {
|
||||||
|
|
Loading…
Reference in a new issue