lotus/storage/sbmock/sbmock_test.go

46 lines
742 B
Go
Raw Normal View History

package sbmock
import (
"context"
"testing"
"time"
2020-02-26 22:54:34 +00:00
"github.com/filecoin-project/specs-actors/actors/abi"
)
func TestOpFinish(t *testing.T) {
sb := NewMockSectorBuilder(1, 1024)
sid, pieces, err := sb.StageFakeData()
if err != nil {
t.Fatal(err)
}
ctx, done := AddOpFinish(context.TODO())
finished := make(chan struct{})
go func() {
2020-02-26 22:54:34 +00:00
_, _, err := sb.SealPreCommit(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")
}
}