go-ethereum/internal/cli/status_test.go
Pratik Patil 9880d754c6
Added flag in Status to wait for backend, and fixed panic issue. (#708)
* checking if backend is available during status call, and added a flag to wait if backend is not available

* added test for status command (does not cover the whole code)
2023-02-07 09:05:34 +05:30

42 lines
788 B
Go

package cli
import (
"testing"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/internal/cli/server"
)
func TestStatusCommand(t *testing.T) {
t.Parallel()
// Start a blockchain in developer
config := server.DefaultConfig()
// enable developer mode
config.Developer.Enabled = true
config.Developer.Period = 2
// start the mock server
srv, err := server.CreateMockServer(config)
require.NoError(t, err)
defer server.CloseMockServer(srv)
// get the grpc port
port := srv.GetGrpcAddr()
command1 := &StatusCommand{
Meta2: &Meta2{
UI: cli.NewMockUi(),
addr: "127.0.0.1:" + port,
},
wait: true,
}
status := command1.Run([]string{"-w", "--address", command1.Meta2.addr})
require.Equal(t, 0, status)
}