deals harness: more improvements.

This commit is contained in:
Raúl Kripalani 2021-06-10 12:22:55 +01:00
parent 0d69c03a8d
commit c27fdc263c

View File

@ -3,7 +3,6 @@ package kit
import ( import (
"bytes" "bytes"
"context" "context"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -48,7 +47,7 @@ func (dh *DealHarness) MakeFullDeal(ctx context.Context, rseed int, carExport, f
require.NoError(dh.t, err) require.NoError(dh.t, err)
fcid := res.Root fcid := res.Root
fmt.Println("FILE CID: ", fcid) dh.t.Logf("FILE CID: %s", fcid)
deal := dh.StartDeal(ctx, fcid, fastRet, startEpoch) deal := dh.StartDeal(ctx, fcid, fastRet, startEpoch)
@ -109,7 +108,7 @@ loop:
case storagemarket.StorageDealError: case storagemarket.StorageDealError:
dh.t.Fatal("deal errored", di.Message) dh.t.Fatal("deal errored", di.Message)
case storagemarket.StorageDealActive: case storagemarket.StorageDealActive:
fmt.Println("COMPLETE", di) dh.t.Log("COMPLETE", di)
break loop break loop
} }
@ -124,7 +123,7 @@ loop:
} }
} }
fmt.Printf("Deal %d state: client:%s provider:%s\n", di.DealID, storagemarket.DealStates[di.State], storagemarket.DealStates[minerState]) dh.t.Logf("Deal %d state: client:%s provider:%s\n", di.DealID, storagemarket.DealStates[di.State], storagemarket.DealStates[minerState])
time.Sleep(time.Second / 2) time.Sleep(time.Second / 2)
if cb != nil { if cb != nil {
cb() cb()
@ -153,10 +152,10 @@ func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid) {
case storagemarket.StorageDealError: case storagemarket.StorageDealError:
dh.t.Fatal("deal errored", di.Message) dh.t.Fatal("deal errored", di.Message)
case storagemarket.StorageDealFinalizing, storagemarket.StorageDealAwaitingPreCommit, storagemarket.StorageDealSealing, storagemarket.StorageDealActive: case storagemarket.StorageDealFinalizing, storagemarket.StorageDealAwaitingPreCommit, storagemarket.StorageDealSealing, storagemarket.StorageDealActive:
fmt.Println("COMPLETE", di) dh.t.Log("COMPLETE", di)
return return
} }
fmt.Println("Deal state: ", storagemarket.DealStates[di.State]) dh.t.Log("Deal state: ", storagemarket.DealStates[di.State])
} }
} }
} }
@ -183,9 +182,7 @@ func (dh *DealHarness) PerformRetrieval(ctx context.Context, fcid cid.Cid, piece
offers, err := dh.client.ClientFindData(ctx, fcid, piece) offers, err := dh.client.ClientFindData(ctx, fcid, piece)
require.NoError(dh.t, err) require.NoError(dh.t, err)
if len(offers) < 1 { require.NotEmpty(dh.t, offers, "no offers")
dh.t.Fatal("no offers")
}
rpath, err := ioutil.TempDir("", "lotus-retrieve-test-") rpath, err := ioutil.TempDir("", "lotus-retrieve-test-")
require.NoError(dh.t, err) require.NoError(dh.t, err)