github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/client/context/verifier_test.go (about)

     1  package context_test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
    10  )
    11  
    12  func TestCreateVerifier(t *testing.T) {
    13  	tmpDir, err := ioutil.TempDir("", "example")
    14  	require.NoError(t, err)
    15  
    16  	testCases := []struct {
    17  		name      string
    18  		ctx       context.CLIContext
    19  		expectErr bool
    20  	}{
    21  		{"no chain ID", context.CLIContext{}, true},
    22  		{"no home directory", context.CLIContext{}.WithChainID("test"), true},
    23  		{"no client or RPC URI", context.CLIContext{HomeDir: tmpDir}.WithChainID("test"), true},
    24  	}
    25  
    26  	for _, tc := range testCases {
    27  		tc := tc
    28  		t.Run(tc.name, func(t *testing.T) {
    29  			verifier, err := context.CreateVerifier(tc.ctx, context.DefaultVerifierCacheSize)
    30  			require.Equal(t, tc.expectErr, err != nil, err)
    31  
    32  			if !tc.expectErr {
    33  				require.NotNil(t, verifier)
    34  			}
    35  		})
    36  	}
    37  }