fix: test: flaky TestDeadlineToggling
This commit is contained in:
parent
7a2bc47486
commit
63a02a6c74
@ -64,7 +64,7 @@ func TestDeadlineToggling(t *testing.T) {
|
||||
|
||||
//stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001
|
||||
//stm: @MINER_SECTOR_LIST_001
|
||||
//kit.Expensive(t)
|
||||
kit.Expensive(t)
|
||||
|
||||
kit.QuietMiningLogs()
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -200,7 +185,7 @@ func TestDeadlineToggling(t *testing.T) {
|
||||
{
|
||||
uts, err := client.ChainGetTipSetByHeight(ctx, upgradeH+2, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
checkMiner(maddrB, types.NewInt(0), true, true, uts.Key())
|
||||
checkMiner(maddrB, types.NewInt(0), true, uts.Key())
|
||||
}
|
||||
|
||||
//stm: @CHAIN_STATE_NETWORK_VERSION_001
|
||||
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user