github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/internal/cli/status_test.go (about)

     1  package cli
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/mitchellh/cli"
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/ethereum/go-ethereum/internal/cli/server"
    10  )
    11  
    12  func TestStatusCommand(t *testing.T) {
    13  	t.Parallel()
    14  
    15  	// Start a blockchain in developer
    16  	config := server.DefaultConfig()
    17  
    18  	// enable developer mode
    19  	config.Developer.Enabled = true
    20  	config.Developer.Period = 2
    21  
    22  	// start the mock server
    23  	srv, err := server.CreateMockServer(config)
    24  	require.NoError(t, err)
    25  
    26  	defer server.CloseMockServer(srv)
    27  
    28  	// get the grpc port
    29  	port := srv.GetGrpcAddr()
    30  
    31  	command1 := &StatusCommand{
    32  		Meta2: &Meta2{
    33  			UI:   cli.NewMockUi(),
    34  			addr: "127.0.0.1:" + port,
    35  		},
    36  		wait: true,
    37  	}
    38  
    39  	status := command1.Run([]string{"-w", "--address", command1.Meta2.addr})
    40  
    41  	require.Equal(t, 0, status)
    42  }