From ac9adcb3dcf25cfbc36beb7df475108e1b1d7819 Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 21 Sep 2022 19:39:00 -0400 Subject: [PATCH] fix: test: flaky TestDeadlineToggling --- itests/deadlines_test.go | 57 ++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/itests/deadlines_test.go b/itests/deadlines_test.go index 18f68150bda..c3c6b8e7051 100644 --- a/itests/deadlines_test.go +++ b/itests/deadlines_test.go @@ -160,7 +160,7 @@ func TestDeadlineToggling(t *testing.T) { build.Clock.Sleep(blocktime) } - checkMiner := func(ma address.Address, power abi.StoragePower, active, activeIfCron bool, tsk types.TipSetKey) { + checkMiner := func(ma address.Address, power abi.StoragePower, active bool, tsk types.TipSetKey) { //stm: @CHAIN_STATE_MINER_POWER_001 p, err := client.StateMinerPower(ctx, ma, tsk) require.NoError(t, err) @@ -178,21 +178,6 @@ func TestDeadlineToggling(t *testing.T) { act, err := mst.DeadlineCronActive() require.NoError(t, err) - if tsk != types.EmptyTSK { - ts, err := client.ChainGetTipSet(ctx, tsk) - require.NoError(t, err) - di, err := mst.DeadlineInfo(ts.Height()) - require.NoError(t, err) - - // cron happened on the same epoch some other condition would have happened - if di.Open <= ts.Height() { - act, err := mst.DeadlineCronActive() - require.NoError(t, err) - require.Equal(t, activeIfCron, act) - return - } - } - require.Equal(t, active, act) } @@ -218,19 +203,19 @@ func TestDeadlineToggling(t *testing.T) { require.NoError(t, err) // first round of miner checks - checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, true, types.EmptyTSK) - checkMiner(maddrC, types.NewInt(uint64(ssz)*sectorsC), true, true, types.EmptyTSK) + checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, types.EmptyTSK) + checkMiner(maddrC, types.NewInt(uint64(ssz)*sectorsC), true, types.EmptyTSK) - checkMiner(maddrB, types.NewInt(0), false, false, types.EmptyTSK) - checkMiner(maddrD, types.NewInt(0), false, false, types.EmptyTSK) - checkMiner(maddrE, types.NewInt(0), false, false, types.EmptyTSK) + checkMiner(maddrB, types.NewInt(0), false, types.EmptyTSK) + checkMiner(maddrD, types.NewInt(0), false, types.EmptyTSK) + checkMiner(maddrE, types.NewInt(0), false, types.EmptyTSK) // pledge sectors on minerB/minerD, stop post on minerC minerB.PledgeSectors(ctx, sectorsB, 0, nil) - checkMiner(maddrB, types.NewInt(0), true, true, types.EmptyTSK) + checkMiner(maddrB, types.NewInt(0), true, types.EmptyTSK) minerD.PledgeSectors(ctx, sectorsD, 0, nil) - checkMiner(maddrD, types.NewInt(0), true, true, types.EmptyTSK) + checkMiner(maddrD, types.NewInt(0), true, types.EmptyTSK) minerC.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).Fail() @@ -281,7 +266,7 @@ func TestDeadlineToggling(t *testing.T) { build.Clock.Sleep(blocktime) } - checkMiner(maddrE, types.NewInt(0), true, true, types.EmptyTSK) + checkMiner(maddrE, types.NewInt(0), true, types.EmptyTSK) // go through rest of the PP for { @@ -296,11 +281,11 @@ func TestDeadlineToggling(t *testing.T) { } // second round of miner checks - checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, true, types.EmptyTSK) - checkMiner(maddrC, types.NewInt(0), true, true, types.EmptyTSK) - checkMiner(maddrB, types.NewInt(uint64(ssz)*sectorsB), true, true, types.EmptyTSK) - checkMiner(maddrD, types.NewInt(uint64(ssz)*sectorsD), true, true, types.EmptyTSK) - checkMiner(maddrE, types.NewInt(0), false, false, types.EmptyTSK) + checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, types.EmptyTSK) + checkMiner(maddrC, types.NewInt(0), true, types.EmptyTSK) + checkMiner(maddrB, types.NewInt(uint64(ssz)*sectorsB), true, types.EmptyTSK) + checkMiner(maddrD, types.NewInt(uint64(ssz)*sectorsD), true, types.EmptyTSK) + checkMiner(maddrE, types.NewInt(0), false, types.EmptyTSK) // disable post on minerB minerB.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).Fail() @@ -353,8 +338,10 @@ func TestDeadlineToggling(t *testing.T) { require.NoError(t, err) require.Equal(t, exitcode.Ok, r.Receipt.ExitCode) - // assert inactive if the message landed in the tipset we run cron in - checkMiner(maddrD, types.NewInt(0), true, false, r.TipSet) + // assert miner has no power + p, err := client.StateMinerPower(ctx, maddrD, r.TipSet) + require.NoError(t, err) + require.True(t, p.MinerPower.RawBytePower.IsZero()) } // go through another PP @@ -369,8 +356,8 @@ func TestDeadlineToggling(t *testing.T) { build.Clock.Sleep(blocktime) } - checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, true, types.EmptyTSK) - checkMiner(maddrC, types.NewInt(0), true, true, types.EmptyTSK) - checkMiner(maddrB, types.NewInt(0), true, true, types.EmptyTSK) - checkMiner(maddrD, types.NewInt(0), false, false, types.EmptyTSK) + checkMiner(maddrA, types.NewInt(uint64(ssz)*kit.DefaultPresealsPerBootstrapMiner), true, types.EmptyTSK) + checkMiner(maddrC, types.NewInt(0), true, types.EmptyTSK) + checkMiner(maddrB, types.NewInt(0), true, types.EmptyTSK) + checkMiner(maddrD, types.NewInt(0), false, types.EmptyTSK) }