From 6c9423cfb015ed5e1ad4ebdae5517d27cf932991 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 24 Oct 2022 15:49:13 +0300 Subject: [PATCH] [#1959] neofs-adm: Add tests for more commands Also, fix `restore-containers`, but it is hard to test it now. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/container.go | 3 ++- .../internal/modules/morph/initialize_test.go | 11 +++++++++++ cmd/neofs-adm/internal/modules/morph/remove_node.go | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/container.go b/cmd/neofs-adm/internal/modules/morph/container.go index 4eb89d035..7c6ce122a 100644 --- a/cmd/neofs-adm/internal/modules/morph/container.go +++ b/cmd/neofs-adm/internal/modules/morph/container.go @@ -114,6 +114,7 @@ func restoreContainers(cmd *cobra.Command, _ []string) error { if err != nil { return err } + defer wCtx.close() nnsCs, err := wCtx.Client.GetContractStateByID(1) if err != nil { @@ -179,7 +180,7 @@ func restoreContainers(cmd *cobra.Command, _ []string) error { panic(bw.Err) } - if err := wCtx.sendCommitteeTx(bw.Bytes(), true); err != nil { + if err := wCtx.sendConsensusTx(bw.Bytes()); err != nil { return err } } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_test.go b/cmd/neofs-adm/internal/modules/morph/initialize_test.go index fc1f867ea..2437ca372 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-node/pkg/innerring" @@ -57,6 +58,16 @@ func testInitialize(t *testing.T, committeeSize int) { t.Run("set-config", func(t *testing.T) { require.NoError(t, setConfigCmd(setConfig, []string{"MaintenanceModeAllowed=true"})) }) + t.Run("set-policy", func(t *testing.T) { + require.NoError(t, setPolicyCmd(setPolicy, []string{"ExecFeeFactor=1"})) + }) + t.Run("remove-node", func(t *testing.T) { + pk, err := keys.NewPrivateKey() + require.NoError(t, err) + + pub := hex.EncodeToString(pk.PublicKey().Bytes()) + require.NoError(t, removeNodesCmd(removeNodes, []string{pub})) + }) } func generateTestData(t *testing.T, dir string, size int) { diff --git a/cmd/neofs-adm/internal/modules/morph/remove_node.go b/cmd/neofs-adm/internal/modules/morph/remove_node.go index 14c73aa71..ff5b49d14 100644 --- a/cmd/neofs-adm/internal/modules/morph/remove_node.go +++ b/cmd/neofs-adm/internal/modules/morph/remove_node.go @@ -31,6 +31,7 @@ func removeNodesCmd(cmd *cobra.Command, args []string) error { if err != nil { return fmt.Errorf("can't initialize context: %w", err) } + defer wCtx.close() cs, err := wCtx.Client.GetContractStateByID(1) if err != nil { @@ -52,7 +53,7 @@ func removeNodesCmd(cmd *cobra.Command, args []string) error { return err } - if err := wCtx.sendCommitteeTx(bw.Bytes(), true); err != nil { + if err := wCtx.sendConsensusTx(bw.Bytes()); err != nil { return err }