diff --git a/ndf/ndf.go b/ndf/ndf.go index 3eeaa981452f24d9287df3bcf142b247e63299bb..2128ed0867c70d02a2cc0a519ac6015a4f96c658 100644 --- a/ndf/ndf.go +++ b/ndf/ndf.go @@ -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 -func (n *Node) GetGatewayId() (*id.ID, error) { +func (n *Gateway) GetGatewayId() (*id.ID, error) { newID, err := id.Unmarshal(n.ID) if err != nil { return nil, err diff --git a/ndf/ndf_test.go b/ndf/ndf_test.go index b2d13e2d92a7e5952bc09df19f0818a7bcf12ada..d66e1f1ce2a870ae7bf09d22becbd926500cdb1e 100644 --- a/ndf/ndf_test.go +++ b/ndf/ndf_test.go @@ -416,19 +416,14 @@ func TestGetNodeId(t *testing.T) { } // Happy path -func TestNode_GetGatewayId(t *testing.T) { - jsonData, _, err := DecodeNDF(ExampleNDF) - if err != nil { - t.Errorf("DecodeNDF() unexpectedly produced an error"+ - "\n\treceived: %#v\n\texpected: %#v", - err, nil) - } +func TestGetGatewayId(t *testing.T) { + gw := Gateway{make([]byte, 33), "52.41.80.104", "-----BEGIN CERT"} // 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} // Fetch the id - receivedGatewayId, err := jsonData.Nodes[0].GetGatewayId() + receivedGatewayId, err := gw.GetGatewayId() if err != nil { t.Errorf("GetGatewayId() produces an error:\n%v", err) }