test: (kinda) fix flaky test
deals_retry_deal_no_funds_test.go:TestDealsRetryLackOfFunds seems to be flaky, sometimes it passes and sometimes it doesn't. The first suspect for me was time.Sleep(), which I replaced with waiting until a deal state where you can restart is reached.
This commit is contained in:
parent
94374aa93d
commit
baee4a1576
@ -95,12 +95,11 @@ func TestDealsRetryLackOfFunds(t *testing.T) {
|
|||||||
dp.FastRetrieval = true
|
dp.FastRetrieval = true
|
||||||
dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price.
|
dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price.
|
||||||
deal := dh.StartDeal(ctx, dp)
|
deal := dh.StartDeal(ctx, dp)
|
||||||
|
dh.WaitUntilDataTransfer(ctx, deal)
|
||||||
|
|
||||||
propcid := *deal
|
propcid := *deal
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
|
|
||||||
kit.SendFunds(ctx, t, minerFullNode, publishStorageDealKey.Address, types.FromFil(1))
|
kit.SendFunds(ctx, t, minerFullNode, publishStorageDealKey.Address, types.FromFil(1))
|
||||||
|
|
||||||
err := miner.MarketRetryPublishDeal(ctx, propcid)
|
err := miner.MarketRetryPublishDeal(ctx, propcid)
|
||||||
|
@ -134,6 +134,29 @@ func (dh *DealHarness) StartDeal(ctx context.Context, dealParams api.StartDealPa
|
|||||||
return dealProposalCid
|
return dealProposalCid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dh *DealHarness) WaitUntilDataTransfer(ctx context.Context, deal *cid.Cid) {
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
di, err := dh.client.ClientGetDealInfo(ctx, *deal)
|
||||||
|
if err != nil {
|
||||||
|
dh.t.Fatal("can't fetch deal info")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch di.State {
|
||||||
|
case storagemarket.StorageDealProposalRejected:
|
||||||
|
dh.t.Fatal("deal rejected")
|
||||||
|
case storagemarket.StorageDealFailing:
|
||||||
|
dh.t.Fatal("deal failed")
|
||||||
|
case storagemarket.StorageDealError:
|
||||||
|
dh.t.Fatal("deal errored")
|
||||||
|
case storagemarket.StorageDealStartDataTransfer:
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WaitDealSealed waits until the deal is sealed.
|
// WaitDealSealed waits until the deal is sealed.
|
||||||
func (dh *DealHarness) WaitDealSealed(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func()) {
|
func (dh *DealHarness) WaitDealSealed(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func()) {
|
||||||
loop:
|
loop:
|
||||||
|
Loading…
Reference in New Issue
Block a user