Fix sorting bug to deflake test

This commit is contained in:
zenground0 2022-04-13 22:06:38 -04:00
parent 563dc8e59a
commit db5082552d
4 changed files with 14 additions and 14 deletions

View File

@ -245,7 +245,6 @@ type publishStorageDealsReturn6 struct {
}
func (r *publishStorageDealsReturn6) IsDealValid(index uint64) (bool, int, error) {
set, err := r.ValidDeals.IsSet(index)
if err != nil || !set {
return false, -1, err

View File

@ -2,7 +2,6 @@ package market
import (
"bytes"
"fmt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
@ -246,9 +245,7 @@ type publishStorageDealsReturn7 struct {
}
func (r *publishStorageDealsReturn7) IsDealValid(index uint64) (bool, int, error) {
set, err := r.ValidDeals.IsSet(index)
fmt.Printf("set: %t\n", set)
if err != nil || !set {
return false, -1, err
}
@ -265,7 +262,6 @@ func (r *publishStorageDealsReturn7) IsDealValid(index uint64) (bool, int, error
if err != nil {
return false, -1, err
}
fmt.Printf("outIdx: %t\n")
return set, int(outIdx), nil
}

View File

@ -85,7 +85,6 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context
if err != nil {
return dealID, nil, xerrors.Errorf("getting network version: %w", err)
}
fmt.Printf("nv: %d\n", nv)
retval, err := market.DecodePublishStorageDealsReturn(lookup.Receipt.Return, nv)
if err != nil {
@ -96,7 +95,6 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context
if err != nil {
return dealID, nil, xerrors.Errorf("looking for publish deal message %s: getting dealIDs: %w", publishCid, err)
}
fmt.Printf("unserialized deal ids: %v\n", dealIDs)
// TODO: Can we delete this? We're well past the point when we first introduced the proposals into sealing deal info
// Previously, publish deals messages contained a single deal, and the
@ -141,6 +139,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context
break
}
}
fmt.Printf("found dealIdx %d\n", dealIdx)
if dealIdx == -1 {
return dealID, nil, xerrors.Errorf("could not find deal in publish deals message %s", publishCid)

View File

@ -195,9 +195,9 @@ func TestGetCurrentDealInfo(t *testing.T) {
},
},
marketDeals: map[abi.DealID]*api.MarketDeal{
anotherDealID: anotherDeal,
earlierDealID: earlierDeal,
successDealID: successDeal,
anotherDealID: anotherDeal,
},
targetProposal: &proposal,
expectedDealID: successDealID,
@ -320,10 +320,17 @@ type CurrentDealInfoMockAPI struct {
}
func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*types.Message, error) {
var dealIDs []abi.DealID
var keys []marketDealKey
for k := range mapi.MarketDeals {
keys = append(keys, k)
}
sort.SliceStable(keys, func(i, j int) bool {
return keys[i].DealID < keys[j].DealID
})
var deals []market2.ClientDealProposal
for k, dl := range mapi.MarketDeals {
dealIDs = append(dealIDs, k.DealID)
for _, k := range keys {
dl := mapi.MarketDeals[k]
deals = append(deals, market2.ClientDealProposal{
Proposal: market2.DealProposal(dl.Proposal),
ClientSignature: crypto.Signature{
@ -332,15 +339,14 @@ func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.C
},
})
}
sort.SliceStable(deals, func(i, j int) bool {
return dealIDs[i] < dealIDs[j]
})
buf := new(bytes.Buffer)
params := market2.PublishStorageDealsParams{Deals: deals}
err := params.MarshalCBOR(buf)
if err != nil {
panic(err)
}
return &types.Message{
Params: buf.Bytes(),
}, nil