Skip to content

Commit

Permalink
Stop exporting NodeTable to consumers.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed Jun 14, 2024
1 parent 0fd1dd0 commit dc796e8
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 88 deletions.
4 changes: 2 additions & 2 deletions adapter_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_RegisterAdapterEndpoint(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -44,7 +44,7 @@ func Test_RegisterAdapterEndpoint(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
4 changes: 2 additions & 2 deletions adapter_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_GetAdapterIEEEAddress(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -43,7 +43,7 @@ func Test_GetAdapterNetworkAddress(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
20 changes: 10 additions & 10 deletions adapter_initialise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Test_Initialise(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer zstack.Stop()

Expand Down Expand Up @@ -120,7 +120,7 @@ func Test_Initialise(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer zstack.Stop()

Expand Down Expand Up @@ -248,7 +248,7 @@ func Test_Initialise(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer zstack.Stop()

Expand Down Expand Up @@ -353,7 +353,7 @@ func Test_verifyAdapterNetworkConfig(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer zstack.Stop()

Expand Down Expand Up @@ -404,7 +404,7 @@ func Test_verifyAdapterNetworkConfig(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer zstack.Stop()

Expand Down Expand Up @@ -457,7 +457,7 @@ func Test_startZigbeeStack(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()

unpiMock.On(SREQ, ZDO, ZDOStartUpFromAppRequestId).Return(Frame{
Expand All @@ -478,7 +478,7 @@ func Test_startZigbeeStack(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()

unpiMock.On(SREQ, ZDO, ZDOStartUpFromAppRequestId).Return(Frame{
Expand Down Expand Up @@ -509,7 +509,7 @@ func Test_startZigbeeStack(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()

unpiMock.On(SREQ, ZDO, ZDOStartUpFromAppRequestId).Return(Frame{
Expand All @@ -532,7 +532,7 @@ func Test_waitForCoordinatorStart(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()

go func() {
Expand All @@ -556,7 +556,7 @@ func Test_waitForCoordinatorStart(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()

err := zstack.waitForCoordinatorStart(ctx)
Expand Down
2 changes: 1 addition & 1 deletion events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Test_ReadEvent(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)

Expand Down
10 changes: 5 additions & 5 deletions joining_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_PermitJoin(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -43,7 +43,7 @@ func Test_PermitJoin(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
zstack.NetworkProperties.NetworkAddress = zigbee.NetworkAddress(0x0102)
Expand All @@ -69,7 +69,7 @@ func Test_PermitJoin(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -93,7 +93,7 @@ func Test_DenyJoin(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -119,7 +119,7 @@ func Test_DenyJoin(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
2 changes: 1 addition & 1 deletion network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (z *ZStack) removeNode(ieee zigbee.IEEEAddress) bool {
}

func (z *ZStack) pollRoutersForNetworkStatus() {
for _, node := range z.nodeTable.Nodes() {
for _, node := range z.nodeTable.nodes() {
if node.LogicalType == zigbee.Coordinator || node.LogicalType == zigbee.Router {
go z.pollNodeForNetworkStatus(node)
}
Expand Down
27 changes: 13 additions & 14 deletions network_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func Test_NetworkManager(t *testing.T) {
t.Run("issues a lqi poll request only for coordinators or routers", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer zstack.Stop()
Expand All @@ -40,7 +40,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("the coordinator is added to the node list as a coordinator", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer zstack.Stop()
Expand Down Expand Up @@ -74,7 +74,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("a node is added to the node table when an ZdoIEEEAddrRsp messages are received", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -109,7 +109,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("a node is added to the node table when an ZdoNWKAddrRsp messages are received", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -147,7 +147,7 @@ func Test_NetworkManager(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -214,7 +214,7 @@ func Test_NetworkManager(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -263,7 +263,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("a new router will be queried for network state", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -318,7 +318,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("nodes in lqi query are added to network manager", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -380,13 +380,12 @@ func Test_NetworkManager(t *testing.T) {

t.Run("nodes in lqi query are added to network manager", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
nt := NewNodeTable()
zstack := New(unpiMock, nt)
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)

nt.addOrUpdate(zigbee.GenerateLocalAdministeredIEEEAddress(), 0x1122)
zstack.nodeTable.addOrUpdate(zigbee.GenerateLocalAdministeredIEEEAddress(), 0x1122)

lqiReqOn := unpiMock.On(SREQ, ZDO, ZdoMGMTLQIReqID).Return(Frame{
MessageType: SRSP,
Expand Down Expand Up @@ -425,7 +424,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("nodes in lqi query are not added if Ext PANID does not match", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down Expand Up @@ -482,7 +481,7 @@ func Test_NetworkManager(t *testing.T) {

t.Run("nodes in lqi query are not added if it has an invalid IEEE address", func(t *testing.T) {
unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
zstack.NetworkProperties.IEEEAddress = zigbee.IEEEAddress(1)

Expand Down Expand Up @@ -544,7 +543,7 @@ func Test_NetworkManager(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()
defer unpiMock.AssertCalls(t)
Expand Down
12 changes: 6 additions & 6 deletions node_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Test_ResolveNodeIEEEAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -36,7 +36,7 @@ func Test_ResolveNodeIEEEAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down Expand Up @@ -77,7 +77,7 @@ func Test_QueryNodeIEEEAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down Expand Up @@ -118,7 +118,7 @@ func Test_ResolveNodeNWKAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand All @@ -135,7 +135,7 @@ func Test_ResolveNodeNWKAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down Expand Up @@ -176,7 +176,7 @@ func Test_QueryNodeNWKAddress(t *testing.T) {

unpiMock := unpiTest.NewMockAdapter()
defer unpiMock.AssertCalls(t)
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
2 changes: 1 addition & 1 deletion node_bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_BindToNode(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
2 changes: 1 addition & 1 deletion node_description_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_QueryNodeDescription(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
2 changes: 1 addition & 1 deletion node_endpoint_description_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_QueryNodeEndpointDescription(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
2 changes: 1 addition & 1 deletion node_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_QueryNodeEndpoints(t *testing.T) {
defer cancel()

unpiMock := unpiTest.NewMockAdapter()
zstack := New(unpiMock, NewNodeTable())
zstack := New(unpiMock)
zstack.sem = semaphore.NewWeighted(8)
defer unpiMock.Stop()

Expand Down
Loading

0 comments on commit dc796e8

Please sign in to comment.