forked from TrueCloudLab/frostfs-node
[#1441] ir: Do not validate subnet removal
It is useless process since subnet owner is able to delete subnet without an Alphabet approval. The Alphabet should only validate netmap state after removal: 1. Update nodes' attributes if they were included in the deleted subnet; 2. Remove nodes without any subnet entrance. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
feef9a98f7
commit
fdd54b0a03
3 changed files with 1 additions and 127 deletions
|
@ -1,44 +0,0 @@
|
|||
package subnetevents
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
)
|
||||
|
||||
// Delete represents a notification about NeoFS subnet removal.
|
||||
// Generated by a contract when intending to delete a subnet.
|
||||
type Delete interface {
|
||||
// Contains the ID of the subnet to be removed.
|
||||
eventWithID
|
||||
}
|
||||
|
||||
// DeleteValidator asserts intent to remove a subnet.
|
||||
type DeleteValidator struct{}
|
||||
|
||||
// Assert processes the attempt to remove a subnet. It approves the removal through nil return.
|
||||
//
|
||||
// All read errors of Delete are forwarded.
|
||||
//
|
||||
// It returns an error on:
|
||||
// * zero subnet creation;
|
||||
// * empty ID or different from the one wired into info;
|
||||
// * empty owner ID or different from the one wired into info.
|
||||
func (x DeleteValidator) Assert(event Delete) error {
|
||||
var err error
|
||||
|
||||
// read ID
|
||||
var id subnetid.ID
|
||||
if err = event.ReadID(&id); err != nil {
|
||||
return fmt.Errorf("read ID: %w", err)
|
||||
}
|
||||
|
||||
// prevent zero subnet removal
|
||||
if subnetid.IsZero(id) {
|
||||
return zeroSubnetOp{
|
||||
op: "removal",
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package subnetevents
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
)
|
||||
|
||||
type delete struct {
|
||||
idEvent
|
||||
}
|
||||
|
||||
func TestDeleteValidator_Assert(t *testing.T) {
|
||||
var (
|
||||
v DeleteValidator
|
||||
|
||||
e delete
|
||||
|
||||
err error
|
||||
)
|
||||
|
||||
// read ID error
|
||||
e.idErr = errors.New("id err")
|
||||
|
||||
err = v.Assert(e)
|
||||
require.ErrorIs(t, err, e.idErr)
|
||||
|
||||
e.idErr = nil
|
||||
|
||||
// zero subnet ID
|
||||
subnetid.MakeZero(&e.id)
|
||||
|
||||
err = v.Assert(e)
|
||||
require.ErrorAs(t, err, new(zeroSubnetOp))
|
||||
|
||||
const idNum = 13
|
||||
e.id.SetNumber(idNum)
|
||||
|
||||
err = v.Assert(e)
|
||||
require.NoError(t, err)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue