From 182b754aa27f9e4c44a88dafe9d6c472a81e9f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Sep 2019 13:43:32 +0200 Subject: [PATCH] fix tests --- .circleci/config.yml | 13 +++++++------ Makefile | 2 +- lib/sectorbuilder/sectorbuilder.go | 10 +++++----- lib/sectorbuilder/sectorbuilder_test.go | 10 ++-------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 933a2d578..e5ae01433 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/Makefile b/Makefile index 2d4f46e17..ae7b13f64 100644 --- a/Makefile +++ b/Makefile @@ -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)) diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 35b3f868b..4613750ae 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -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 } diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index ebe28cfac..fe346dcb3 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -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) }