2018-07-14 02:15:37 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
2018-07-14 19:48:42 +00:00
|
|
|
"flag"
|
2018-07-31 04:41:27 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2018-07-14 02:15:37 +00:00
|
|
|
"testing"
|
|
|
|
|
2018-08-20 15:50:11 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
2018-07-14 02:15:37 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
2018-08-20 15:50:11 +00:00
|
|
|
// Test that beacon chain node can close.
|
2019-02-22 15:11:26 +00:00
|
|
|
func TestNodeClose_OK(t *testing.T) {
|
2018-08-20 15:50:11 +00:00
|
|
|
hook := logTest.NewGlobal()
|
2018-11-06 21:43:10 +00:00
|
|
|
|
2019-02-13 23:49:06 +00:00
|
|
|
tmp := fmt.Sprintf("%s/datadirtest2", testutil.TempDir())
|
2018-11-06 21:43:10 +00:00
|
|
|
os.RemoveAll(tmp)
|
|
|
|
|
2018-08-20 15:50:11 +00:00
|
|
|
app := cli.NewApp()
|
|
|
|
set := flag.NewFlagSet("test", 0)
|
|
|
|
set.String("web3provider", "ws//127.0.0.1:8546", "web3 provider ws or IPC endpoint")
|
2019-03-04 20:10:03 +00:00
|
|
|
set.Bool("test-skip-pow", true, "skip pow dial")
|
2018-08-20 15:50:11 +00:00
|
|
|
set.String("datadir", tmp, "node data directory")
|
2018-10-02 02:04:37 +00:00
|
|
|
set.Bool("demo-config", true, "demo configuration")
|
2019-03-04 20:10:03 +00:00
|
|
|
set.String("deposit-contract", "0x0000000000000000000000000000000000000000", "deposit contract address")
|
2018-08-20 15:50:11 +00:00
|
|
|
|
|
|
|
context := cli.NewContext(app, set, nil)
|
|
|
|
|
|
|
|
node, err := NewBeaconNode(context)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to create BeaconNode: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
node.Close()
|
|
|
|
|
|
|
|
testutil.AssertLogsContain(t, hook, "Stopping beacon node")
|
|
|
|
|
2018-07-31 04:41:27 +00:00
|
|
|
os.RemoveAll(tmp)
|
2018-07-14 02:15:37 +00:00
|
|
|
}
|