[#298] innerring: Fix broken tests

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-02 11:51:30 +03:00
parent d00b1c0d29
commit 235fe84ea3
3 changed files with 14 additions and 67 deletions

View file

@ -18,8 +18,6 @@ func TestEpochTimer(t *testing.T) {
counter: 99, counter: 99,
duration: 10, duration: 10,
} }
collectHandler := &testEventHandler{}
distributeHandler := &testEventHandler{}
args := &epochTimerArgs{ args := &epochTimerArgs{
l: test.NewLogger(t, true), l: test.NewLogger(t, true),
@ -29,16 +27,6 @@ func TestEpochTimer(t *testing.T) {
epoch: epochState, epoch: epochState,
stopEstimationDMul: 2, stopEstimationDMul: 2,
stopEstimationDDiv: 10, stopEstimationDDiv: 10,
collectBasicIncome: subEpochEventHandler{
handler: collectHandler.Handle,
durationMul: 3,
durationDiv: 10,
},
distributeBasicIncome: subEpochEventHandler{
handler: distributeHandler.Handle,
durationMul: 4,
durationDiv: 10,
},
} }
et := newEpochTimer(args) et := newEpochTimer(args)
err := et.Reset() err := et.Reset()
@ -47,78 +35,54 @@ func TestEpochTimer(t *testing.T) {
et.Tick(100) et.Tick(100)
require.Equal(t, 0, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(101)
require.Equal(t, 0, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(102)
require.Equal(t, 0, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(103)
require.Equal(t, 0, neh.called, "invalid new epoch handler calls") 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, 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 var h uint32
for h = 104; h < 109; h++ { for h = 104; h < 109; h++ {
et.Tick(h) et.Tick(h)
require.Equal(t, 0, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(109)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(110)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(111)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(112)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(113)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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++ { for h = 114; h < 119; h++ {
et.Tick(h) et.Tick(h)
require.Equal(t, 1, neh.called, "invalid new epoch handler calls") 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, 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) et.Tick(120)
require.Equal(t, 2, neh.called, "invalid new epoch handler calls") 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, 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 { type testAlphabetState struct {

View file

@ -44,9 +44,6 @@ contracts:
processingExp, _ := util.Uint160DecodeStringLE("597f5894867113a41e192801709c02497f611de8") processingExp, _ := util.Uint160DecodeStringLE("597f5894867113a41e192801709c02497f611de8")
require.Equal(t, processingExp, c.processing, "invalid processing") require.Equal(t, processingExp, c.processing, "invalid processing")
auditExp, _ := util.Uint160DecodeStringLE("219e37aed2180b87e7fe945dbf97d67125e8d73f")
require.Equal(t, auditExp, c.audit, "invalid audit")
balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16") balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16")
require.Equal(t, balanceExp, c.balance, "invalid balance") require.Equal(t, balanceExp, c.balance, "invalid balance")
@ -80,9 +77,6 @@ contracts:
require.Equal(t, util.Uint160{}, c.processing, "invalid processing") 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") balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16")
require.Equal(t, balanceExp, c.balance, "invalid balance") require.Equal(t, balanceExp, c.balance, "invalid balance")
@ -116,9 +110,6 @@ contracts:
require.Equal(t, util.Uint160{}, c.processing, "invalid processing") 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") balanceExp, _ := util.Uint160DecodeStringLE("d2aa48d14b17b11bc4c68205027884a96706dd16")
require.Equal(t, balanceExp, c.balance, "invalid balance") require.Equal(t, balanceExp, c.balance, "invalid balance")

View file

@ -7,9 +7,7 @@ import (
v2netmap "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap" v2netmap "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
netmapContract "git.frostfs.info/TrueCloudLab/frostfs-contract/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/governance"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/settlement"
timerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/timers" timerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/timers"
cntClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container" cntClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container"
netmapclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap" 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) { proc, err := newTestProc(t, func(p *Params) {
p.NotaryDisabled = true p.NotaryDisabled = true
p.NotaryDepositHandler = eh.Handle p.NotaryDepositHandler = eh.Handle
p.HandleAudit = eh.Handle
p.AuditSettlementsHandler = eh.Handle
p.AlphabetSyncHandler = eh.Handle p.AlphabetSyncHandler = eh.Handle
p.NetmapClient = nc p.NetmapClient = nc
p.ContainerWrapper = cc 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, []cntClient.StartEstimationPrm{expEstimation}, cc.estimations, "invalid estimations")
require.EqualValues(t, []event.Event{ require.EqualValues(t, []event.Event{
audit.NewAuditStartEvent(ev.Num),
settlement.NewAuditEvent(ev.Num),
governance.NewSyncEvent(ev.TxHash()), governance.NewSyncEvent(ev.TxHash()),
ev, ev,
}, eh.handledEvents, "invalid handled events") }, eh.handledEvents, "invalid handled events")
@ -409,22 +403,20 @@ func newTestProc(t *testing.T, nonDefault func(p *Params)) (*Processor, error) {
eh := &testEventHandler{} eh := &testEventHandler{}
p := &Params{ p := &Params{
Log: test.NewLogger(t, true), Log: test.NewLogger(t, true),
PoolSize: 1, PoolSize: 1,
CleanupEnabled: false, CleanupEnabled: false,
CleanupThreshold: 3, CleanupThreshold: 3,
NotaryDisabled: false, NotaryDisabled: false,
NodeStateSettings: ns, NodeStateSettings: ns,
NodeValidator: &testValidator{}, NodeValidator: &testValidator{},
EpochState: es, EpochState: es,
EpochTimer: r, EpochTimer: r,
AlphabetState: as, AlphabetState: as,
ContainerWrapper: cc, ContainerWrapper: cc,
NetmapClient: nc, NetmapClient: nc,
NotaryDepositHandler: eh.Handle, NotaryDepositHandler: eh.Handle,
HandleAudit: eh.Handle, AlphabetSyncHandler: eh.Handle,
AuditSettlementsHandler: eh.Handle,
AlphabetSyncHandler: eh.Handle,
} }
nonDefault(p) nonDefault(p)