diff --git a/network/gateway/hostpool_test.go b/network/gateway/hostpool_test.go index 9e48d9ae57ba220ef7a06047fa764d98cddce5a1..a460875fcda03a9b2abf5a98d695532e686fe918 100644 --- a/network/gateway/hostpool_test.go +++ b/network/gateway/hostpool_test.go @@ -395,106 +395,6 @@ func TestHostPool_CheckReplace(t *testing.T) { } -// TODO: Adapt to new methods -// Happy path -//func TestHostPool_PruneHostPool(t *testing.T) { -// manager := newMockManager() -// testNdf := getTestNdf(t) -// newIndex := uint32(20) -// params := DefaultPoolParams() -// params.PoolSize = uint32(len(testNdf.Gateways)) -// rng := csprng.NewSystemRNG() -// -// // Construct a manager (bypass business logic in constructor) -// hostPool := &HostPool{ -// manager: manager, -// hostList: make([]*connect.Host, newIndex+1), -// hostMap: make(map[id.ID]uint32), -// ndf: testNdf, -// poolParams: params, -// rng: rng, -// } -// -// // Pull all gateways from ndf into host manager -// hostList := make([]*connect.Host, 0) -// for _, gw := range testNdf.Gateways { -// -// gwId, err := id.Unmarshal(gw.ID) -// if err != nil { -// t.Errorf("Failed to unmarshal ID in mock ndf: %v", err) -// } -// // Add mock gateway to manager -// h, err := manager.AddHost(gwId, "", nil, connect.GetDefaultHostParams()) -// if err != nil { -// t.Errorf("Could not add mock host to manager: %v", err) -// t.FailNow() -// } -// -// hostList = append(hostList, h) -// -// } -// -// // Construct a host past the error threshold -// errorThresholdIndex := 0 -// overThreshold := params.ErrThreshold + 25 -// hostList[errorThresholdIndex].SetMetricsTesting(connect.NewMetricTesting(overThreshold, t), t) -// oldHost := hostList[0] -// -// // Call prune host pool -// err := hostPool.pruneHostPool() -// if err != nil { -// t.Errorf("Unexpected error in happy path: %v", err) -// } -// -// // Check that the host map has been properly updated -// for _, h := range hostList { -// _, ok := hostPool.hostMap[*h.GetId()] -// if !ok { -// t.Errorf("Gateway %s was not placed in host map after pruning", h.GetId().String()) -// } -// } -// -// // Check that the host list has been has been properly updated -// // at the index with a host past the error threshold -// retrievedHost := hostPool.hostList[errorThresholdIndex] -// if reflect.DeepEqual(oldHost, retrievedHost) { -// t.Errorf("Expected host list to have it's bad host replaced. " + -// "Contains old host information after pruning") -// } -// -//} -// -//// Error path: not enough gateways in ndf compared to -//// required pool size -//func TestHostPool_PruneHostPool_Error(t *testing.T) { -// manager := newMockManager() -// testNdf := getTestNdf(t) -// newIndex := uint32(20) -// params := DefaultPoolParams() -// -// // Trigger the case where the Ndf doesn't have enough gateways -// params.PoolSize = uint32(len(testNdf.Gateways)) + 1 -// rng := csprng.NewSystemRNG() -// -// // Construct a manager (bypass business logic in constructor) -// hostPool := &HostPool{ -// manager: manager, -// hostList: make([]*connect.Host, newIndex+1), -// hostMap: make(map[id.ID]uint32), -// ndf: testNdf, -// poolParams: params, -// rng: rng, -// } -// -// // Call prune -// err := hostPool.pruneHostPool() -// if err == nil { -// t.Errorf("Gateways should not be available: " + -// "not enough gateways in ndf compared to param's pool size") -// } -// -//} - // Unit test func TestHostPool_UpdateNdf(t *testing.T) { manager := newMockManager()