status-go/multiaccounts/accounts/account_test.go
Andrea Maria Piana d65946e9c0 Use IsOwnAccount instead of Wallet when watching for transactions
There was an issue in using the `Wallet` flag when checking accounts to
watch for transactions.
`Wallet` indicates that it's the default wallet, not whether is a wallet
account.
That can only be checked by looking at the type (and the `Wallet` flag).
If the type is `generated`, `key` or `seed` it should be watched for
transactions.
2020-12-07 16:12:50 +01:00

36 lines
626 B
Go

package accounts
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIsOwnAccount(t *testing.T) {
account := Account{Wallet: true}
require.True(t, account.IsOwnAccount())
account = Account{
Type: accountTypeGenerated,
}
require.True(t, account.IsOwnAccount())
account = Account{
Type: accountTypeKey,
}
require.True(t, account.IsOwnAccount())
account = Account{
Type: accountTypeSeed,
}
require.True(t, account.IsOwnAccount())
account = Account{
Type: accountTypeWatch,
}
require.False(t, account.IsOwnAccount())
account = Account{}
require.False(t, account.IsOwnAccount())
}