2024-06-27 14:21:20 +00:00
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/services/wallet/walletconnect"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestAPI_GetWalletConnectActiveSessions tames coverage
|
|
|
|
func TestAPI_GetWalletConnectActiveSessions(t *testing.T) {
|
|
|
|
db, close := walletconnect.SetupTestDB(t)
|
|
|
|
defer close()
|
|
|
|
api := &API{
|
|
|
|
s: &Service{db: db},
|
|
|
|
}
|
|
|
|
|
|
|
|
sessions, err := api.GetWalletConnectActiveSessions(context.Background(), 0)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 0, len(sessions))
|
|
|
|
}
|
2024-07-02 21:46:47 +00:00
|
|
|
|
|
|
|
// TestAPI_HashMessageEIP191
|
|
|
|
func TestAPI_HashMessageEIP191(t *testing.T) {
|
|
|
|
api := &API{}
|
|
|
|
|
|
|
|
res := api.HashMessageEIP191(context.Background(), []byte("test"))
|
|
|
|
require.Equal(t, "0x4a5c5d454721bbbb25540c3317521e71c373ae36458f960d2ad46ef088110e95", res.String())
|
|
|
|
}
|
2024-07-31 20:25:13 +00:00
|
|
|
|
|
|
|
func TestAPI_IsChecksumValidForAddress(t *testing.T) {
|
|
|
|
api := &API{}
|
|
|
|
|
|
|
|
res, err := api.IsChecksumValidForAddress("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, res)
|
|
|
|
|
|
|
|
res, err = api.IsChecksumValidForAddress("0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, res)
|
|
|
|
}
|