Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Nov 5, 2024
1 parent 3e8bf09 commit 0ff2589
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tools/walletextension/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"errors"
"testing"

"github.com/ten-protocol/go-ten/integration/common/testlog"

"github.com/ten-protocol/go-ten/go/common/viewingkey"

"github.com/stretchr/testify/require"
Expand All @@ -26,7 +28,7 @@ func TestGatewayStorage(t *testing.T) {

for name, test := range tests {
t.Run(name, func(t *testing.T) {
storage, err := New("sqlite", "", "", randomKey)
storage, err := New("sqlite", "", "", randomKey, testlog.Logger())
// storage, err := New("cosmosDB", "", "", randomKey)
require.NoError(t, err)

Expand Down Expand Up @@ -61,8 +63,8 @@ func testAddAndGetUser(storage UserStorage, t *testing.T) {
}

// Check if retrieved private key matches the original
if !bytes.Equal(user.PrivateKey, privateKey) {
t.Errorf("privateKey mismatch: got %v, want %v", user.PrivateKey, privateKey)
if !bytes.Equal(user.UserKey, privateKey) {
t.Errorf("privateKey mismatch: got %v, want %v", user.UserKey, privateKey)
}
}

Expand Down Expand Up @@ -118,10 +120,10 @@ func testAddAccounts(storage UserStorage, t *testing.T) {

// Iterate through retrieved accounts and check if they match the added accounts
for _, account := range user.Accounts {
if bytes.Equal(account.AccountAddress, accountAddress1) && bytes.Equal(account.Signature, signature1) {
if bytes.Equal(account.Address.Bytes(), accountAddress1) && bytes.Equal(account.Signature, signature1) {
foundAccount1 = true
}
if bytes.Equal(account.AccountAddress, accountAddress2) && bytes.Equal(account.Signature, signature2) {
if bytes.Equal(account.Address.Bytes(), accountAddress2) && bytes.Equal(account.Signature, signature2) {
foundAccount2 = true
}
}
Expand Down Expand Up @@ -183,12 +185,12 @@ func testGetUser(storage UserStorage, t *testing.T) {
}

// Check if retrieved user matches the added user
if !bytes.Equal(user.UserId, userID) {
t.Errorf("Retrieved user ID does not match. Expected %x, got %x", userID, user.UserId)
if !bytes.Equal(user.UserID, userID) {
t.Errorf("Retrieved user ID does not match. Expected %x, got %x", userID, user.UserID)
}

if !bytes.Equal(user.PrivateKey, privateKey) {
t.Errorf("Retrieved private key does not match. Expected %x, got %x", privateKey, user.PrivateKey)
if !bytes.Equal(user.UserKey, privateKey) {
t.Errorf("Retrieved private key does not match. Expected %x, got %x", privateKey, user.UserKey)
}

// Try to get a non-existent user
Expand Down

0 comments on commit 0ff2589

Please sign in to comment.