refactor kit.NewDealHarness to include main miner and market node
This commit is contained in:
parent
51a4657ef7
commit
7fb93d4585
@ -49,7 +49,7 @@ func TestMinerAllInfo(t *testing.T) {
|
||||
|
||||
t.Run("pre-info-all", run)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
deal, res, inPath := dh.MakeOnlineDeal(context.Background(), kit.MakeFullDealParams{Rseed: 6})
|
||||
outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false)
|
||||
kit.AssertFilesEqual(t, inPath, outPath)
|
||||
|
@ -58,7 +58,7 @@ func TestBatchDealInput(t *testing.T) {
|
||||
))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
err := miner.MarketSetAsk(ctx, big.Zero(), big.Zero(), 200, 128, 32<<30)
|
||||
require.NoError(t, err)
|
||||
|
@ -61,7 +61,7 @@ func runTestCCUpgrade(t *testing.T, upgradeHeight abi.ChainEpoch) {
|
||||
err = miner.SectorMarkForUpgrade(ctx, sl[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{Rseed: 6})
|
||||
outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false)
|
||||
kit.AssertFilesEqual(t, inPath, outPath)
|
||||
|
@ -47,13 +47,9 @@ func TestDealCyclesConcurrent(t *testing.T) {
|
||||
runTest := func(t *testing.T, n int, fastRetrieval bool, carExport bool) {
|
||||
api.RunningNodeType = api.NodeMiner // TODO(anteva): fix me
|
||||
|
||||
////TODO: add miner
|
||||
//client, main, _, _ := kit2.EnsembleWithMarket(t, kit2.MockProofs(), kit2.ThroughRPC())
|
||||
|
||||
//dh := kit.NewDealHarness(t, client, main)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
runConcurrentDeals(t, dh, fullDealCyclesOpts{
|
||||
n: n,
|
||||
@ -68,9 +64,9 @@ func TestDealCyclesConcurrent(t *testing.T) {
|
||||
for _, n := range cycles {
|
||||
n := n
|
||||
ns := fmt.Sprintf("%d", n)
|
||||
//t.Run(ns+"-fastretrieval-CAR", func(t *testing.T) { runTest(t, n, true, true) })
|
||||
//t.Run(ns+"-fastretrieval-NoCAR", func(t *testing.T) { runTest(t, n, true, false) })
|
||||
//t.Run(ns+"-stdretrieval-CAR", func(t *testing.T) { runTest(t, n, true, false) })
|
||||
t.Run(ns+"-fastretrieval-CAR", func(t *testing.T) { runTest(t, n, true, true) })
|
||||
t.Run(ns+"-fastretrieval-NoCAR", func(t *testing.T) { runTest(t, n, true, false) })
|
||||
t.Run(ns+"-stdretrieval-CAR", func(t *testing.T) { runTest(t, n, true, false) })
|
||||
t.Run(ns+"-stdretrieval-NoCAR", func(t *testing.T) { runTest(t, n, false, false) })
|
||||
}
|
||||
}
|
||||
@ -124,7 +120,7 @@ func TestDealsWithSealingAndRPC(t *testing.T) {
|
||||
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.WithAllSubsystems()) // no mock proofs.
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
t.Run("stdretrieval", func(t *testing.T) {
|
||||
runConcurrentDeals(t, dh, fullDealCyclesOpts{n: 1})
|
||||
@ -164,7 +160,7 @@ func TestQuotePriceForUnsealedRetrieval(t *testing.T) {
|
||||
err = miner.MarketSetRetrievalAsk(ctx, ask)
|
||||
require.NoError(t, err)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
deal1, res1, _ := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{Rseed: 6})
|
||||
|
||||
@ -255,7 +251,7 @@ func TestPublishDealsBatching(t *testing.T) {
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ConstructorOpts(opts))
|
||||
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
// Starts a deal and waits until it's published
|
||||
runDealTillPublish := func(rseed int) {
|
||||
@ -346,7 +342,7 @@ func TestFirstDealEnablesMining(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
dh := kit.NewDealHarness(t, &client, &provider)
|
||||
dh := kit.NewDealHarness(t, &client, &provider, &provider)
|
||||
|
||||
ref, _ := client.CreateImportFile(ctx, 5, 0)
|
||||
|
||||
@ -395,7 +391,7 @@ func TestOfflineDealFlow(t *testing.T) {
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
|
||||
// Create a random file and import on the client.
|
||||
res, inFile := client.CreateImportFile(ctx, 1, 0)
|
||||
@ -497,7 +493,7 @@ func TestZeroPricePerByteRetrieval(t *testing.T) {
|
||||
err = miner.MarketSetRetrievalAsk(ctx, ask)
|
||||
require.NoError(t, err)
|
||||
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh := kit.NewDealHarness(t, client, miner, miner)
|
||||
runConcurrentDeals(t, dh, fullDealCyclesOpts{
|
||||
n: 1,
|
||||
startEpoch: startEpoch,
|
||||
|
@ -192,7 +192,7 @@ func TestGatewayDealFlow(t *testing.T) {
|
||||
// so that the deal starts sealing in time
|
||||
dealStartEpoch := abi.ChainEpoch(2 << 12)
|
||||
|
||||
dh := kit.NewDealHarness(t, nodes.lite, nodes.miner)
|
||||
dh := kit.NewDealHarness(t, nodes.lite, nodes.miner, nodes.miner)
|
||||
dealCid, res, _ := dh.MakeOnlineDeal(context.Background(), kit.MakeFullDealParams{
|
||||
Rseed: 6,
|
||||
StartEpoch: dealStartEpoch,
|
||||
|
@ -27,7 +27,8 @@ import (
|
||||
type DealHarness struct {
|
||||
t *testing.T
|
||||
client *TestFullNode
|
||||
miner *TestMiner
|
||||
main *TestMiner
|
||||
market *TestMiner
|
||||
}
|
||||
|
||||
type MakeFullDealParams struct {
|
||||
@ -37,11 +38,12 @@ type MakeFullDealParams struct {
|
||||
}
|
||||
|
||||
// NewDealHarness creates a test harness that contains testing utilities for deals.
|
||||
func NewDealHarness(t *testing.T, client *TestFullNode, miner *TestMiner) *DealHarness {
|
||||
func NewDealHarness(t *testing.T, client *TestFullNode, main *TestMiner, market *TestMiner) *DealHarness {
|
||||
return &DealHarness{
|
||||
t: t,
|
||||
client: client,
|
||||
miner: miner,
|
||||
main: main,
|
||||
market: market,
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ func (dh *DealHarness) MakeOnlineDeal(ctx context.Context, params MakeFullDealPa
|
||||
|
||||
// StartDeal starts a storage deal between the client and the miner.
|
||||
func (dh *DealHarness) StartDeal(ctx context.Context, fcid cid.Cid, fastRet bool, startEpoch abi.ChainEpoch) *cid.Cid {
|
||||
maddr, err := dh.miner.ActorAddress(ctx)
|
||||
maddr, err := dh.main.ActorAddress(ctx)
|
||||
require.NoError(dh.t, err)
|
||||
|
||||
addr, err := dh.client.WalletDefaultAddress(ctx)
|
||||
@ -115,7 +117,7 @@ loop:
|
||||
break loop
|
||||
}
|
||||
|
||||
mds, err := dh.miner.MarketListIncompleteDeals(ctx)
|
||||
mds, err := dh.market.MarketListIncompleteDeals(ctx)
|
||||
require.NoError(dh.t, err)
|
||||
|
||||
var minerState storagemarket.StorageDealStatus
|
||||
@ -139,7 +141,7 @@ func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid) {
|
||||
subCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
updates, err := dh.miner.MarketGetDealUpdates(subCtx)
|
||||
updates, err := dh.market.MarketGetDealUpdates(subCtx)
|
||||
require.NoError(dh.t, err)
|
||||
|
||||
for {
|
||||
@ -166,19 +168,19 @@ func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid) {
|
||||
}
|
||||
|
||||
func (dh *DealHarness) StartSealingWaiting(ctx context.Context) {
|
||||
snums, err := dh.miner.SectorsList(ctx)
|
||||
snums, err := dh.main.SectorsList(ctx)
|
||||
require.NoError(dh.t, err)
|
||||
|
||||
for _, snum := range snums {
|
||||
si, err := dh.miner.SectorsStatus(ctx, snum, false)
|
||||
si, err := dh.main.SectorsStatus(ctx, snum, false)
|
||||
require.NoError(dh.t, err)
|
||||
|
||||
dh.t.Logf("Sector state: %s", si.State)
|
||||
if si.State == api.SectorState(sealing.WaitDeals) {
|
||||
require.NoError(dh.t, dh.miner.SectorStartSealing(ctx, snum))
|
||||
require.NoError(dh.t, dh.main.SectorStartSealing(ctx, snum))
|
||||
}
|
||||
|
||||
dh.miner.FlushSealingBatches(ctx)
|
||||
dh.main.FlushSealingBatches(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user