NET-1933: option to force destroy network (#3311)

* option to force destroy network

* fix network tests

* fix network defaults func

* fix network destroy action

* delete network if node count is zero

* push peer update network deletion

* send node update
This commit is contained in:
Abhishek K
2025-02-03 15:19:44 +04:00
committed by GitHub
parent cec48be354
commit 4431dc99a7
7 changed files with 109 additions and 53 deletions

View File

@@ -75,11 +75,19 @@ func TestDeleteNetwork(t *testing.T) {
t.Run("NetworkwithNodes", func(t *testing.T) {
})
t.Run("DeleteExistingNetwork", func(t *testing.T) {
err := logic.DeleteNetwork("skynet")
doneCh := make(chan struct{}, 1)
err := logic.DeleteNetwork("skynet", false, doneCh)
assert.Nil(t, err)
})
t.Run("NonExistentNetwork", func(t *testing.T) {
err := logic.DeleteNetwork("skynet")
doneCh := make(chan struct{}, 1)
err := logic.DeleteNetwork("skynet", false, doneCh)
assert.Nil(t, err)
})
createNetv1("test")
t.Run("ForceDeleteNetwork", func(t *testing.T) {
doneCh := make(chan struct{}, 1)
err := logic.DeleteNetwork("test", true, doneCh)
assert.Nil(t, err)
})
}
@@ -214,6 +222,15 @@ func createNet() {
logic.CreateNetwork(network)
}
}
func createNetv1(netId string) {
var network models.Network
network.NetID = netId
network.AddressRange = "100.0.0.1/24"
_, err := logic.GetNetwork(netId)
if err != nil {
logic.CreateNetwork(network)
}
}
func createNetDualStack() {
var network models.Network