lotus/extern/sector-storage/mock/mock_test.go

46 lines
772 B
Go
Raw Normal View History

2020-03-23 11:40:02 +00:00
package mock
import (
"context"
"testing"
"time"
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
2020-03-23 11:40:02 +00:00
)
func TestOpFinish(t *testing.T) {
2020-11-05 06:34:24 +00:00
sb := NewMockSectorMgr(nil)
2020-03-23 11:40:02 +00:00
2020-11-05 06:34:24 +00:00
sid, pieces, err := sb.StageFakeData(123, abi.RegisteredSealProof_StackedDrg2KiBV1_1)
2020-03-23 11:40:02 +00:00
if err != nil {
t.Fatal(err)
}
ctx, done := AddOpFinish(context.TODO())
finished := make(chan struct{})
go func() {
_, err := sb.SealPreCommit1(ctx, sid, abi.SealRandomness{}, pieces)
if err != nil {
t.Error(err)
return
}
close(finished)
}()
select {
case <-finished:
t.Fatal("should not finish until we tell it to")
case <-time.After(time.Second / 2):
}
done()
select {
case <-finished:
case <-time.After(time.Second / 2):
t.Fatal("should finish after we tell it to")
}
}