From 3d784e69b169cdfd3c1f114db6c21d2aa062cb69 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Tue, 30 Mar 2021 11:03:28 -0700 Subject: [PATCH] Improve upon tests in gateway package --- network/gateway/gateway_test.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/network/gateway/gateway_test.go b/network/gateway/gateway_test.go index ad56cdb06..7cb2c1796 100644 --- a/network/gateway/gateway_test.go +++ b/network/gateway/gateway_test.go @@ -108,11 +108,14 @@ func TestHostPool_ManageHostPool(t *testing.T) { } + newNdf := getTestNdf(t) // Update the ndf, removing some gateways at a cutoff - testPool.ndf.Gateways = newGateways - testPool.ndf.Nodes = newNodes + newNdf.Gateways = newGateways + newNdf.Nodes = newNodes + + testPool.UpdateNdf(newNdf) - time.Sleep(1 * time.Second) + time.Sleep(2 * time.Second) // Check that old gateways are not in pool for _, ndfGw := range testNdf.Gateways { @@ -627,9 +630,12 @@ func TestHostPool_UpdateConns_AddGateways(t *testing.T) { } - // Update the ndf, removing some gateways at a cutoff - testPool.ndf.Gateways = append(testPool.ndf.Gateways, newGateways...) - testPool.ndf.Nodes = append(testPool.ndf.Nodes, newNodes...) + // Update the ndf + newNdf := getTestNdf(t) + newNdf.Gateways = append(newNdf.Gateways, newGateways...) + newNdf.Nodes = append(newNdf.Nodes, newNodes...) + + testPool.UpdateNdf(newNdf) // Update the connections err = testPool.updateConns() @@ -699,9 +705,12 @@ func TestHostPool_UpdateConns_RemoveGateways(t *testing.T) { } - // Update the ndf, removing some gateways at a cutoff - testPool.ndf.Gateways = newGateways - testPool.ndf.Nodes = newNodes + // Update the ndf, replacing old data entirely + newNdf := getTestNdf(t) + newNdf.Gateways = newGateways + newNdf.Nodes = newNodes + + testPool.UpdateNdf(newNdf) // Update the connections err = testPool.updateConns() -- GitLab