2022-05-20 10:18:59 +01:00
|
|
|
// Copyright (C) 2022 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package storjscan_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"storj.io/common/testcontext"
|
|
|
|
"storj.io/common/testrand"
|
|
|
|
"storj.io/storj/private/blockchain"
|
|
|
|
"storj.io/storj/satellite"
|
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWalletsDB(t *testing.T) {
|
|
|
|
userID1 := testrand.UUID()
|
|
|
|
userID2 := testrand.UUID()
|
|
|
|
userID3 := testrand.UUID()
|
|
|
|
walletAddress1, err := blockchain.BytesToAddress(testrand.Bytes(20))
|
|
|
|
require.NoError(t, err)
|
|
|
|
walletAddress2, err := blockchain.BytesToAddress(testrand.Bytes(20))
|
|
|
|
require.NoError(t, err)
|
|
|
|
walletAddress3, err := blockchain.BytesToAddress(testrand.Bytes(20))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
t.Run("get wallet", func(t *testing.T) {
|
|
|
|
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
|
|
|
err := db.Wallets().Add(ctx, userID1, walletAddress1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = db.Wallets().Add(ctx, userID2, walletAddress2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = db.Wallets().Add(ctx, userID3, walletAddress3)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-06-17 00:29:31 +01:00
|
|
|
address1, err := db.Wallets().GetWallet(ctx, userID1)
|
2022-05-20 10:18:59 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, walletAddress1, address1)
|
2022-06-17 00:29:31 +01:00
|
|
|
address2, err := db.Wallets().GetWallet(ctx, userID2)
|
2022-05-20 10:18:59 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, walletAddress2, address2)
|
2022-06-17 00:29:31 +01:00
|
|
|
address3, err := db.Wallets().GetWallet(ctx, userID3)
|
2022-05-20 10:18:59 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, walletAddress3, address3)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|