2020-03-23 11:40:02 +00:00
|
|
|
package mock
|
2020-01-09 20:50:45 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-02-26 22:54:34 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-01-09 20:50:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOpFinish(t *testing.T) {
|
2020-03-23 11:40:02 +00:00
|
|
|
sb := NewMockSectorMgr(1, 2048)
|
2020-01-09 20:50:45 +00:00
|
|
|
|
2020-03-18 01:08:11 +00:00
|
|
|
sid, pieces, err := sb.StageFakeData(123)
|
2020-01-09 20:50:45 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx, done := AddOpFinish(context.TODO())
|
|
|
|
|
|
|
|
finished := make(chan struct{})
|
|
|
|
go func() {
|
2020-03-05 22:02:01 +00:00
|
|
|
_, err := sb.SealPreCommit1(ctx, sid, abi.SealRandomness{}, pieces)
|
2020-01-09 20:50:45 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|