Skip to content
Snippets Groups Projects
Commit 6bab756b authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/ndf-gatewayid' into 'release'

GetGatewayId() should be running off Gateway struct, not Node

See merge request !2
parents 6f3e41ff eb0287ed
No related branches found
No related tags found
No related merge requests found
...@@ -235,7 +235,7 @@ func (n *Node) GetNodeId() (*id.ID, error) { ...@@ -235,7 +235,7 @@ func (n *Node) GetNodeId() (*id.ID, error) {
} }
// GetGatewayId formats the gateway id into the id format specified in the id package of this repo // GetGatewayId formats the gateway id into the id format specified in the id package of this repo
func (n *Node) GetGatewayId() (*id.ID, error) { func (n *Gateway) GetGatewayId() (*id.ID, error) {
newID, err := id.Unmarshal(n.ID) newID, err := id.Unmarshal(n.ID)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -416,19 +416,14 @@ func TestGetNodeId(t *testing.T) { ...@@ -416,19 +416,14 @@ func TestGetNodeId(t *testing.T) {
} }
// Happy path // Happy path
func TestNode_GetGatewayId(t *testing.T) { func TestGetGatewayId(t *testing.T) {
jsonData, _, err := DecodeNDF(ExampleNDF) gw := Gateway{make([]byte, 33), "52.41.80.104", "-----BEGIN CERT"}
if err != nil {
t.Errorf("DecodeNDF() unexpectedly produced an error"+
"\n\treceived: %#v\n\texpected: %#v",
err, nil)
}
// Expected id, pulled from the global ExampleNDF // Expected id, pulled from the global ExampleNDF
expectedId := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} expectedId := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
// Fetch the id // Fetch the id
receivedGatewayId, err := jsonData.Nodes[0].GetGatewayId() receivedGatewayId, err := gw.GetGatewayId()
if err != nil { if err != nil {
t.Errorf("GetGatewayId() produces an error:\n%v", err) t.Errorf("GetGatewayId() produces an error:\n%v", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment