test is getting close to passing
This commit is contained in:
parent
597dbe369c
commit
41d13b12a0
@ -10,6 +10,7 @@ import (
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node/impl"
|
||||
@ -54,7 +55,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
deal, err := client.ClientStartDeal(ctx, fcid, maddr, types.NewInt(200), 100)
|
||||
deal, err := client.ClientStartDeal(ctx, fcid, maddr, types.NewInt(400), 100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -66,10 +67,15 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println("DEAL STATE: ", *deal, di.State)
|
||||
switch di.State {
|
||||
case api.DealRejected:
|
||||
t.Fatal("deal rejected")
|
||||
case api.DealFailed:
|
||||
t.Fatal("deal failed")
|
||||
case api.DealComplete:
|
||||
fmt.Println("COMPLETE", di)
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second / 2)
|
||||
}
|
||||
fmt.Println("Deal done!", deal)
|
||||
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
|
@ -59,6 +59,25 @@ func (s *Store) SectorStatus(sid uint64) (*sectorbuilder.SectorSealingStatus, er
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
func computePaddedSize(size uint64) uint64 {
|
||||
logv := 64 - bits.LeadingZeros64(size)
|
||||
sectSize := uint64(1 << logv)
|
||||
bound := sectorbuilder.UserBytesForSectorSize(sectSize)
|
||||
if size <= bound {
|
||||
return bound
|
||||
}
|
||||
return sectorbuilder.UserBytesForSectorSize(1 << (logv + 1))
|
||||
}
|
||||
|
||||
type nullReader struct{}
|
||||
|
||||
func (nr nullReader) Read(b []byte) (int, error) {
|
||||
for i := range b {
|
||||
b[i] = 0
|
||||
}
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (s *Store) AddPiece(ref string, size uint64, r io.Reader, dealIDs ...uint64) (sectorID uint64, err error) {
|
||||
padSize := computePaddedSize(size)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user