Merge pull request #1168 from filecoin-project/bugs/invalid-state-transition

planCommitting must handle SectorCommitFailed
This commit is contained in:
Łukasz Magiera 2020-01-28 23:32:42 +01:00 committed by GitHub
commit b60860456d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -205,6 +205,8 @@ func planCommitting(events []statemachine.Event, state *SectorInfo) error {
state.State = api.SealCommitFailed
case SectorSealFailed:
state.State = api.CommitFailed
case SectorCommitFailed:
state.State = api.CommitFailed
default:
return xerrors.Errorf("planCommitting got event of unknown type %T, events: %+v", event.User, events)
}

View File

@ -83,3 +83,17 @@ func TestSeedRevert(t *testing.T) {
m.planSingle(SectorProving{})
require.Equal(m.t, m.state.State, api.Proving)
}
func TestPlanCommittingHandlesSectorCommitFailed(t *testing.T) {
m := test{
s: &Sealing{},
t: t,
state: &SectorInfo{State: api.Committing},
}
events := []statemachine.Event{{SectorCommitFailed{}}}
require.NoError(t, planCommitting(events, m.state))
require.Equal(t, api.SectorStates[api.CommitFailed], api.SectorStates[m.state.State])
}