From 235fe84ea3e30a6932bb05fc850c79843d149e05 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 2 May 2023 11:51:30 +0300 Subject: [PATCH] [#298] innerring: Fix broken tests Signed-off-by: Evgenii Stratonikov --- pkg/innerring/blocktimer_test.go | 36 ------------------- pkg/innerring/contracts_test.go | 9 ----- .../processors/netmap/handlers_test.go | 36 ++++++++----------- 3 files changed, 14 insertions(+), 67 deletions(-) diff --git a/pkg/innerring/blocktimer_test.go b/pkg/innerring/blocktimer_test.go index e1a79c2a8..f1cf620a8 100644 --- a/pkg/innerring/blocktimer_test.go +++ b/pkg/innerring/blocktimer_test.go @@ -18,8 +18,6 @@ func TestEpochTimer(t *testing.T) { counter: 99, duration: 10, } - collectHandler := &testEventHandler{} - distributeHandler := &testEventHandler{} args := &epochTimerArgs{ l: test.NewLogger(t, true), @@ -29,16 +27,6 @@ func TestEpochTimer(t *testing.T) { epoch: epochState, stopEstimationDMul: 2, stopEstimationDDiv: 10, - collectBasicIncome: subEpochEventHandler{ - handler: collectHandler.Handle, - durationMul: 3, - durationDiv: 10, - }, - distributeBasicIncome: subEpochEventHandler{ - handler: distributeHandler.Handle, - durationMul: 4, - durationDiv: 10, - }, } et := newEpochTimer(args) err := et.Reset() @@ -47,78 +35,54 @@ func TestEpochTimer(t *testing.T) { et.Tick(100) require.Equal(t, 0, neh.called, "invalid new epoch handler calls") require.Equal(t, 0, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 0, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 0, distributeHandler.called, "invalid distribute basic income calls") et.Tick(101) require.Equal(t, 0, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 0, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 0, distributeHandler.called, "invalid distribute basic income calls") et.Tick(102) require.Equal(t, 0, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 0, distributeHandler.called, "invalid distribute basic income calls") et.Tick(103) require.Equal(t, 0, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") var h uint32 for h = 104; h < 109; h++ { et.Tick(h) require.Equal(t, 0, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") } et.Tick(109) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") et.Tick(110) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") et.Tick(111) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 1, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") et.Tick(112) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 2, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 1, distributeHandler.called, "invalid distribute basic income calls") et.Tick(113) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 2, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 2, distributeHandler.called, "invalid distribute basic income calls") for h = 114; h < 119; h++ { et.Tick(h) require.Equal(t, 1, neh.called, "invalid new epoch handler calls") require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 2, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 2, distributeHandler.called, "invalid distribute basic income calls") } et.Tick(120) require.Equal(t, 2, neh.called, "invalid new epoch handler calls") require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls") - require.Equal(t, 2, collectHandler.called, "invalid collect basic income calls") - require.Equal(t, 2, distributeHandler.called, "invalid distribute basic income calls") } type testAlphabetState struct { diff --git a/pkg/innerring/contracts_test.go b/pkg/innerring/contracts_test.go index 2d6e69c05..e04e22f06 100644 --- a/pkg/innerring/contracts_test.go +++ b/pkg/innerring/contracts_test.go @@ -44,9 +44,6 @@ contracts: processingExp, _ := util.Uint160DecodeStringLE("597f5894867113a41e192801709c02497f611de8") require.Equal(t, processingExp, c.processing, "invalid processing") - auditExp, _ := util.Uint160DecodeStringLE("219e37aed2180b87e7fe945dbf97d67125e8d73f") - require.Equal(t, auditExp, c.audit, "invalid audit") - balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16") require.Equal(t, balanceExp, c.balance, "invalid balance") @@ -80,9 +77,6 @@ contracts: require.Equal(t, util.Uint160{}, c.processing, "invalid processing") - auditExp, _ := util.Uint160DecodeStringLE("219e37aed2180b87e7fe945dbf97d67125e8d73f") - require.Equal(t, auditExp, c.audit, "invalid audit") - balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16") require.Equal(t, balanceExp, c.balance, "invalid balance") @@ -116,9 +110,6 @@ contracts: require.Equal(t, util.Uint160{}, c.processing, "invalid processing") - auditExp, _ := util.Uint160DecodeStringLE("219e37aed2180b87e7fe945dbf97d67125e8d73f") - require.Equal(t, auditExp, c.audit, "invalid audit") - balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16") require.Equal(t, balanceExp, c.balance, "invalid balance") diff --git a/pkg/innerring/processors/netmap/handlers_test.go b/pkg/innerring/processors/netmap/handlers_test.go index 576d6c5dd..4905b45d2 100644 --- a/pkg/innerring/processors/netmap/handlers_test.go +++ b/pkg/innerring/processors/netmap/handlers_test.go @@ -7,9 +7,7 @@ import ( v2netmap "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap" netmapContract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/audit" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/governance" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/settlement" timerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/timers" cntClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container" netmapclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap" @@ -84,8 +82,6 @@ func TestNewEpoch(t *testing.T) { proc, err := newTestProc(t, func(p *Params) { p.NotaryDisabled = true p.NotaryDepositHandler = eh.Handle - p.HandleAudit = eh.Handle - p.AuditSettlementsHandler = eh.Handle p.AlphabetSyncHandler = eh.Handle p.NetmapClient = nc p.ContainerWrapper = cc @@ -115,8 +111,6 @@ func TestNewEpoch(t *testing.T) { require.EqualValues(t, []cntClient.StartEstimationPrm{expEstimation}, cc.estimations, "invalid estimations") require.EqualValues(t, []event.Event{ - audit.NewAuditStartEvent(ev.Num), - settlement.NewAuditEvent(ev.Num), governance.NewSyncEvent(ev.TxHash()), ev, }, eh.handledEvents, "invalid handled events") @@ -409,22 +403,20 @@ func newTestProc(t *testing.T, nonDefault func(p *Params)) (*Processor, error) { eh := &testEventHandler{} p := &Params{ - Log: test.NewLogger(t, true), - PoolSize: 1, - CleanupEnabled: false, - CleanupThreshold: 3, - NotaryDisabled: false, - NodeStateSettings: ns, - NodeValidator: &testValidator{}, - EpochState: es, - EpochTimer: r, - AlphabetState: as, - ContainerWrapper: cc, - NetmapClient: nc, - NotaryDepositHandler: eh.Handle, - HandleAudit: eh.Handle, - AuditSettlementsHandler: eh.Handle, - AlphabetSyncHandler: eh.Handle, + Log: test.NewLogger(t, true), + PoolSize: 1, + CleanupEnabled: false, + CleanupThreshold: 3, + NotaryDisabled: false, + NodeStateSettings: ns, + NodeValidator: &testValidator{}, + EpochState: es, + EpochTimer: r, + AlphabetState: as, + ContainerWrapper: cc, + NetmapClient: nc, + NotaryDepositHandler: eh.Handle, + AlphabetSyncHandler: eh.Handle, } nonDefault(p)