2021-05-17 12:28:09 +00:00
|
|
|
package itests
|
2020-10-12 06:31:23 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
2021-06-18 18:45:29 +00:00
|
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
2020-10-12 06:31:23 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-05-18 20:32:10 +00:00
|
|
|
func TestTapeFix(t *testing.T) {
|
2021-06-18 18:45:29 +00:00
|
|
|
kit.QuietMiningLogs()
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
var blocktime = 2 * time.Millisecond
|
|
|
|
|
2021-02-19 21:08:43 +00:00
|
|
|
// The "before" case is disabled, because we need the builder to mock 32 GiB sectors to accurately repro this case
|
|
|
|
// TODO: Make the mock sector size configurable and reenable this
|
2021-05-18 20:32:10 +00:00
|
|
|
// t.Run("before", func(t *testing.T) { testTapeFix(t, b, blocktime, false) })
|
2021-06-14 13:51:10 +00:00
|
|
|
t.Run("after", func(t *testing.T) { testTapeFix(t, blocktime, true) })
|
2020-10-12 06:31:23 +00:00
|
|
|
}
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-14 13:51:10 +00:00
|
|
|
func testTapeFix(t *testing.T, blocktime time.Duration, after bool) {
|
2020-10-12 06:31:23 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2021-08-06 00:46:05 +00:00
|
|
|
networkVersion := network.Version4
|
2020-10-12 06:31:23 +00:00
|
|
|
if after {
|
2021-08-06 00:46:05 +00:00
|
|
|
networkVersion = network.Version5
|
2020-10-12 06:31:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 00:46:05 +00:00
|
|
|
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(networkVersion))
|
2021-06-14 13:51:10 +00:00
|
|
|
ens.InterconnectAll().BeginMining(blocktime)
|
2020-10-12 06:31:23 +00:00
|
|
|
|
2021-02-16 18:19:16 +00:00
|
|
|
sid, err := miner.PledgeSector(ctx)
|
2020-10-12 06:31:23 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-14 13:51:10 +00:00
|
|
|
t.Log("All sectors is fsm")
|
2020-10-12 06:31:23 +00:00
|
|
|
|
|
|
|
// If before, we expect the precommit to fail
|
|
|
|
successState := api.SectorState(sealing.CommitFailed)
|
|
|
|
failureState := api.SectorState(sealing.Proving)
|
|
|
|
if after {
|
|
|
|
// otherwise, it should succeed.
|
|
|
|
successState, failureState = failureState, successState
|
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
2021-02-16 18:19:16 +00:00
|
|
|
st, err := miner.SectorsStatus(ctx, sid.Number, false)
|
2020-10-12 06:31:23 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
if st.State == successState {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
require.NotEqual(t, failureState, st.State)
|
|
|
|
build.Clock.Sleep(100 * time.Millisecond)
|
2021-06-14 13:51:10 +00:00
|
|
|
t.Log("WaitSeal")
|
2020-10-12 06:31:23 +00:00
|
|
|
}
|
|
|
|
}
|