storj/internal/test/utils.go
Dennis Coyle ea077e4dcb
node-node communication (#145)
* node-node communication

* PR reviews comments from @bryanchriswhite addressed
2018-07-19 10:48:08 -04:00

30 lines
697 B
Go

package test
import (
"testing"
pb "github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/assert"
"storj.io/storj/pkg/kademlia"
proto "storj.io/storj/protos/overlay"
"storj.io/storj/storage"
)
// NewNodeAddressValue provides a convient way to create a storage.Value for testing purposes
func NewNodeAddressValue(t *testing.T, address string) storage.Value {
na := &proto.NodeAddress{Transport: proto.NodeTransport_TCP, Address: address}
d, err := pb.Marshal(na)
assert.NoError(t, err)
return d
}
// NewNodeID returns the string representation of a dht node ID
func NewNodeID(t *testing.T) string {
id, err := kademlia.NewID()
assert.NoError(t, err)
return id.String()
}