More post-refactor fixes

This commit is contained in:
Łukasz Magiera 2019-11-07 19:43:15 +01:00
parent 58c21b4a5e
commit f40eb8a521
4 changed files with 19 additions and 14 deletions

View File

@ -12,6 +12,7 @@ import (
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl" "github.com/filecoin-project/lotus/node/impl"
@ -20,6 +21,8 @@ import (
func TestDealFlow(t *testing.T, b APIBuilder) { func TestDealFlow(t *testing.T, b APIBuilder) {
os.Setenv("BELLMAN_NO_GPU", "1") os.Setenv("BELLMAN_NO_GPU", "1")
build.SectorSizes = []uint64{1024}
logging.SetAllLoggers(logging.LevelInfo) logging.SetAllLoggers(logging.LevelInfo)
ctx := context.Background() ctx := context.Background()
n, sn := b(t, 1, []int{0}) n, sn := b(t, 1, []int{0})
@ -36,7 +39,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
} }
time.Sleep(time.Second) time.Sleep(time.Second)
r := io.LimitReader(rand.New(rand.NewSource(17)), 350) r := io.LimitReader(rand.New(rand.NewSource(17)), 257)
fcid, err := client.ClientImportLocal(ctx, r) fcid, err := client.ClientImportLocal(ctx, r)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -7,9 +7,9 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
xerrors "golang.org/x/xerrors" xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
) )
type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error) type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error)

View File

@ -43,11 +43,13 @@ func (m *Miner) finishPacking(ctx context.Context, sector SectorInfo) (func(*Sec
allocated += piece.Size allocated += piece.Size
} }
if allocated > m.sb.SectorSize() { ubytes := sectorbuilder.UserBytesForSectorSize(m.sb.SectorSize())
return nil, xerrors.Errorf("too much data in sector: %d > %d", allocated, m.sb.SectorSize())
if allocated > ubytes {
return nil, xerrors.Errorf("too much data in sector: %d > %d", allocated, ubytes)
} }
fillerSizes, err := fillersFromRem(m.sb.SectorSize() - allocated) fillerSizes, err := fillersFromRem(ubytes - allocated)
if err != nil { if err != nil {
return nil, err return nil, err
} }