Merge pull request #6521 from yaohcn/fix-commit-finalize

fix commit finalize failed
This commit is contained in:
Łukasz Magiera 2021-06-18 10:38:58 +02:00 committed by GitHub
commit 715176698f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -156,7 +156,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),
), ),
CommitFinalizeFailed: planOne( CommitFinalizeFailed: planOne(
on(SectorRetryFinalize{}, CommitFinalizeFailed), on(SectorRetryFinalize{}, CommitFinalize),
), ),
CommitFailed: planOne( CommitFailed: planOne(
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),

View File

@ -154,6 +154,45 @@ func TestHappyPathFinalizeEarly(t *testing.T) {
} }
} }
func TestCommitFinalizeFailed(t *testing.T) {
var notif []struct{ before, after SectorInfo }
ma, _ := address.NewIDAddress(55151)
m := test{
s: &Sealing{
maddr: ma,
stats: SectorStats{
bySector: map[abi.SectorID]statSectorState{},
},
notifee: func(before, after SectorInfo) {
notif = append(notif, struct{ before, after SectorInfo }{before, after})
},
},
t: t,
state: &SectorInfo{State: Committing},
}
m.planSingle(SectorProofReady{})
require.Equal(m.t, m.state.State, CommitFinalize)
m.planSingle(SectorFinalizeFailed{})
require.Equal(m.t, m.state.State, CommitFinalizeFailed)
m.planSingle(SectorRetryFinalize{})
require.Equal(m.t, m.state.State, CommitFinalize)
m.planSingle(SectorFinalized{})
require.Equal(m.t, m.state.State, SubmitCommit)
expected := []SectorState{Committing, CommitFinalize, CommitFinalizeFailed, CommitFinalize, SubmitCommit}
for i, n := range notif {
if n.before.State != expected[i] {
t.Fatalf("expected before state: %s, got: %s", expected[i], n.before.State)
}
if n.after.State != expected[i+1] {
t.Fatalf("expected after state: %s, got: %s", expected[i+1], n.after.State)
}
}
}
func TestSeedRevert(t *testing.T) { func TestSeedRevert(t *testing.T) {
ma, _ := address.NewIDAddress(55151) ma, _ := address.NewIDAddress(55151)
m := test{ m := test{