github.com/badrootd/nibiru-cometbft@v0.37.5-0.20240307173500-2a75559eee9b/rpc/client/main_test.go (about)

     1  package client_test
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/badrootd/nibiru-cometbft/abci/example/kvstore"
     8  	nm "github.com/badrootd/nibiru-cometbft/node"
     9  	rpctest "github.com/badrootd/nibiru-cometbft/rpc/test"
    10  )
    11  
    12  var node *nm.Node
    13  
    14  func TestMain(m *testing.M) {
    15  	// start a CometBFT node (and kvstore) in the background to test against
    16  	dir, err := os.MkdirTemp("/tmp", "rpc-client-test")
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	app := kvstore.NewPersistentKVStoreApplication(dir)
    22  	// If testing block event generation
    23  	// app.SetGenBlockEvents() // needs to be called here (see TestBlockSearch in rpc_test.go)
    24  	node = rpctest.StartTendermint(app)
    25  
    26  	code := m.Run()
    27  
    28  	// and shut down proper at the end
    29  	rpctest.StopTendermint(node)
    30  	_ = os.RemoveAll(dir)
    31  	os.Exit(code)
    32  }