fix ClientRetrieve with CAR exporting & add test coverage

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
This commit is contained in:
Ignacio Hagopian
2020-03-30 11:08:20 -03:00
parent 34e9e9fe34
commit 8f89501118
3 changed files with 50 additions and 9 deletions
+1 -1
View File
@@ -377,7 +377,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref
unsubscribe()
if ref.IsCAR {
f, err := os.Open(ref.Path)
f, err := os.OpenFile(ref.Path, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
+11 -6
View File
@@ -4,14 +4,15 @@ import (
"bytes"
"context"
"crypto/rand"
"github.com/filecoin-project/lotus/lib/lotuslog"
"github.com/filecoin-project/lotus/storage/mockstorage"
"github.com/filecoin-project/sector-storage/ffiwrapper"
"io/ioutil"
"net/http/httptest"
"testing"
"time"
"github.com/filecoin-project/lotus/lib/lotuslog"
"github.com/filecoin-project/lotus/storage/mockstorage"
"github.com/filecoin-project/sector-storage/ffiwrapper"
"github.com/filecoin-project/go-fil-markets/storedcounter"
"github.com/ipfs/go-datastore"
logging "github.com/ipfs/go-log/v2"
@@ -43,7 +44,7 @@ import (
"github.com/filecoin-project/lotus/node/modules"
modtest "github.com/filecoin-project/lotus/node/modules/testing"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/sector-storage"
sectorstorage "github.com/filecoin-project/sector-storage"
"github.com/filecoin-project/sector-storage/mock"
)
@@ -449,7 +450,11 @@ func TestAPIDealFlow(t *testing.T) {
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestDealFlow(t, mockSbBuilder, 10*time.Millisecond)
test.TestDealFlow(t, mockSbBuilder, 10*time.Millisecond, false)
t.Run("WithExportedCAR", func(t *testing.T) {
test.TestDealFlow(t, mockSbBuilder, 10*time.Millisecond, true)
})
}
func TestAPIDealFlowReal(t *testing.T) {
@@ -463,5 +468,5 @@ func TestAPIDealFlowReal(t *testing.T) {
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestDealFlow(t, builder, time.Second)
test.TestDealFlow(t, builder, time.Second, false)
}