fix tests

This commit is contained in:
Łukasz Magiera 2019-09-23 13:43:32 +02:00
parent b79b826805
commit 182b754aa2
4 changed files with 15 additions and 20 deletions

View File

@ -2,6 +2,10 @@ version: 2.1
orbs:
go: gotest/tools@0.0.9
executors:
golang:
docker:
- image: circleci/golang:1.13
commands:
install-deps:
@ -22,9 +26,6 @@ commands:
- 'v2-lotus-params-'
paths:
- /var/tmp/filecoin-proof-parameters/
- run:
command: GO111MODULE=on go get github.com/ipfs/ipget@c0cbd7d9d1925965a5aa0895d5ff32dbdb4a009e
working_directory: "~"
- run: make build/.params-1024
- save_cache:
name: Save parameters cache
@ -35,7 +36,7 @@ commands:
jobs:
mod-tidy-check:
executor: go/circleci-golang
executor: golang
steps:
- install-deps
- prepare
@ -48,7 +49,7 @@ jobs:
parameters:
executor:
type: executor
default: go/circleci-golang
default: golang
go-test-flags:
type: string
default: ""
@ -116,7 +117,7 @@ jobs:
parameters:
executor:
type: executor
default: go/circleci-golang
default: golang
golangci-lint-version:
type: string
default: 1.17.1

View File

@ -51,7 +51,7 @@ build/.update-modules:
## PROOFS
bin/ipget:
./bin/dist_get /ipns/dist.ipfs.io ipget bin/ipget v0.4.0
./bin/dist_get /ipns/dist.ipfs.io ipget bin/ipget v0.5.0
PARAM_SECTOR_SIZES:=1024 16777216 268435456 1073741824
PARAM_SECTOR_SIZES:=$(addprefix build/.params-,$(PARAM_SECTOR_SIZES))

View File

@ -159,12 +159,12 @@ func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
return nil, nil, err
}
var copyWait sync.WaitGroup
copyWait.Add(1)
var wait sync.Mutex
var werr error
wait.Lock()
go func() {
defer copyWait.Done()
defer wait.Unlock()
_, werr = io.CopyN(w, r, n)
@ -175,7 +175,7 @@ func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
}()
return f, func() error {
copyWait.Wait()
return nil
wait.Lock()
return werr
}, nil
}

View File

@ -34,15 +34,9 @@ func TestSealAndVerify(t *testing.T) {
t.Fatal(err)
}
fi, err := ioutil.TempFile("", "sbtestfi")
if err != nil {
t.Fatal(err)
}
defer fi.Close()
r := io.LimitReader(rand.New(rand.NewSource(42)), 1016)
io.CopyN(fi, rand.New(rand.NewSource(42)), 1016)
if _, err := sb.AddPiece("foo", 1016, fi.Name()); err != nil {
if _, err := sb.AddPiece("foo", 1016, r); err != nil {
t.Fatal(err)
}