2018-06-06 02:38:16 +00:00
|
|
|
package node
|
|
|
|
|
2018-06-17 02:26:03 +00:00
|
|
|
import (
|
|
|
|
"flag"
|
2019-02-13 23:49:06 +00:00
|
|
|
"os"
|
2018-06-17 02:26:03 +00:00
|
|
|
"testing"
|
|
|
|
|
2019-02-13 23:49:06 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
2020-06-27 15:48:36 +00:00
|
|
|
v1 "github.com/prysmaticlabs/prysm/validator/accounts/v1"
|
2020-05-31 06:44:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-06-17 02:26:03 +00:00
|
|
|
)
|
2018-06-06 02:38:16 +00:00
|
|
|
|
2018-06-17 02:26:03 +00:00
|
|
|
// Test that the sharding node can build with default flag values.
|
|
|
|
func TestNode_Builds(t *testing.T) {
|
2020-03-19 21:46:44 +00:00
|
|
|
app := cli.App{}
|
2018-06-17 02:26:03 +00:00
|
|
|
set := flag.NewFlagSet("test", 0)
|
2019-02-13 23:49:06 +00:00
|
|
|
set.String("datadir", testutil.TempDir()+"/datadir", "the node data directory")
|
|
|
|
dir := testutil.TempDir() + "/keystore1"
|
2020-04-14 16:41:09 +00:00
|
|
|
defer func() {
|
|
|
|
if err := os.RemoveAll(dir); err != nil {
|
|
|
|
t.Log(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
defer func() {
|
|
|
|
if err := os.RemoveAll(testutil.TempDir() + "/datadir"); err != nil {
|
|
|
|
t.Log(err)
|
|
|
|
}
|
|
|
|
}()
|
2019-02-13 23:49:06 +00:00
|
|
|
set.String("keystore-path", dir, "path to keystore")
|
|
|
|
set.String("password", "1234", "validator account password")
|
2019-09-26 18:23:25 +00:00
|
|
|
set.String("verbosity", "debug", "log verbosity")
|
2020-03-19 21:46:44 +00:00
|
|
|
context := cli.NewContext(&app, set, nil)
|
2018-06-17 02:26:03 +00:00
|
|
|
|
2020-06-27 15:48:36 +00:00
|
|
|
if err := v1.NewValidatorAccount(dir, "1234"); err != nil {
|
2019-02-13 23:49:06 +00:00
|
|
|
t.Fatalf("Could not create validator account: %v", err)
|
|
|
|
}
|
2019-09-26 18:23:25 +00:00
|
|
|
_, err := NewValidatorClient(context)
|
2018-06-17 02:26:03 +00:00
|
|
|
if err != nil {
|
2018-10-18 17:33:38 +00:00
|
|
|
t.Fatalf("Failed to create ValidatorClient: %v", err)
|
2018-06-17 02:26:03 +00:00
|
|
|
}
|
|
|
|
}
|