You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
679 B

package factory
import (
"encoding/hex"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/types"
)
// NodeID returns a valid NodeID based on an inputted string
func NodeID(t *testing.T, str string) types.NodeID {
t.Helper()
id, err := types.NewNodeID(strings.Repeat(str, 2*types.NodeIDByteLength))
require.NoError(t, err)
return id
}
// RandomNodeID returns a randomly generated valid NodeID
func RandomNodeID(t *testing.T) types.NodeID {
t.Helper()
id, err := types.NewNodeID(hex.EncodeToString(rand.Bytes(types.NodeIDByteLength)))
require.NoError(t, err)
return id
}