mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
a9a4bb9163
* move testutil * util pkg * build * gaz Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package wallet_test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func init() {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(ioutil.Discard)
|
|
}
|
|
|
|
func Test_Exists_RandomFiles(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "wallet")
|
|
|
|
exists, err := wallet.Exists(path)
|
|
require.Equal(t, false, exists)
|
|
require.NoError(t, err)
|
|
require.NoError(t, os.MkdirAll(path+"/direct", params.BeaconIoConfig().ReadWriteExecutePermissions), "Failed to create directory")
|
|
|
|
exists, err = wallet.Exists(path)
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, exists)
|
|
}
|
|
|
|
func Test_IsValid_RandomFiles(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "wallet")
|
|
valid, err := wallet.IsValid(path)
|
|
require.NoError(t, err)
|
|
require.Equal(t, false, valid)
|
|
|
|
require.NoError(t, os.MkdirAll(path, params.BeaconIoConfig().ReadWriteExecutePermissions), "Failed to create directory")
|
|
|
|
valid, err = wallet.IsValid(path)
|
|
require.ErrorContains(t, "no wallet found", err)
|
|
require.Equal(t, false, valid)
|
|
|
|
walletDir := filepath.Join(path, "direct")
|
|
require.NoError(t, os.MkdirAll(walletDir, params.BeaconIoConfig().ReadWriteExecutePermissions), "Failed to create directory")
|
|
|
|
valid, err = wallet.IsValid(path)
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, valid)
|
|
}
|