test unsealing prices for default pricing strategy
This commit is contained in:
parent
dc6dbc9a11
commit
78255eac54
@ -11,6 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||
"github.com/ipfs/go-cid"
|
||||
files "github.com/ipfs/go-ipfs-files"
|
||||
"github.com/ipld/go-car"
|
||||
@ -51,6 +52,13 @@ func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, sta
|
||||
}
|
||||
|
||||
func MakeDeal(t *testing.T, ctx context.Context, rseed int, client api.FullNode, miner TestStorageNode, carExport, fastRet bool, startEpoch abi.ChainEpoch) {
|
||||
data, info, fcid := mkStorageDeal(t, ctx, rseed, client, miner, carExport, fastRet, startEpoch)
|
||||
|
||||
testRetrieval(t, ctx, client, fcid, &info.PieceCID, carExport, data)
|
||||
}
|
||||
|
||||
func mkStorageDeal(t *testing.T, ctx context.Context, rseed int, client api.FullNode, miner TestStorageNode, carExport, fastRet bool, startEpoch abi.ChainEpoch) ([]byte,
|
||||
*api.DealInfo, cid.Cid) {
|
||||
res, data, err := CreateClientFile(ctx, client, rseed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -69,7 +77,7 @@ func MakeDeal(t *testing.T, ctx context.Context, rseed int, client api.FullNode,
|
||||
info, err := client.ClientGetDealInfo(ctx, *deal)
|
||||
require.NoError(t, err)
|
||||
|
||||
testRetrieval(t, ctx, client, fcid, &info.PieceCID, carExport, data)
|
||||
return data, info, fcid
|
||||
}
|
||||
|
||||
func CreateClientFile(ctx context.Context, client api.FullNode, rseed int) (*api.ImportRes, []byte, error) {
|
||||
@ -321,6 +329,53 @@ func TestSecondDealRetrieval(t *testing.T, b APIBuilder, blocktime time.Duration
|
||||
}
|
||||
}
|
||||
|
||||
func TestNonUnsealedRetrievalQuoteForDefaultPricing(t *testing.T, b APIBuilder, blocktime time.Duration, startEpoch abi.ChainEpoch) {
|
||||
ppb := int64(1)
|
||||
unsealPrice := int64(77)
|
||||
|
||||
s := setupOneClientOneMiner(t, b, blocktime)
|
||||
defer s.blockMiner.Stop()
|
||||
|
||||
// Set unsealed price to non-zero
|
||||
ask, err := s.miner.MarketGetRetrievalAsk(s.ctx)
|
||||
require.NoError(t, err)
|
||||
ask.PricePerByte = abi.NewTokenAmount(ppb)
|
||||
ask.UnsealPrice = abi.NewTokenAmount(unsealPrice)
|
||||
err = s.miner.MarketSetRetrievalAsk(s.ctx, ask)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, info, fcid := mkStorageDeal(t, s.ctx, 6, s.client, s.miner, false, false, startEpoch)
|
||||
|
||||
// fetch quote -> zero for unsealed price since unsealed file already exists.
|
||||
offers, err := s.client.ClientFindData(s.ctx, fcid, &info.PieceCID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, offers, 1)
|
||||
require.Equal(t, uint64(0), offers[0].UnsealPrice.Uint64())
|
||||
require.Equal(t, info.Size*uint64(ppb), offers[0].MinPrice.Uint64())
|
||||
|
||||
// remove unsealed file
|
||||
ss, err := s.miner.StorageList(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = s.miner.SectorsList(s.ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
for storeID, sd := range ss {
|
||||
for _, sector := range sd {
|
||||
require.NoError(t, s.miner.StorageDropSector(s.ctx, storeID, sector.SectorID, storiface.FTUnsealed))
|
||||
}
|
||||
}
|
||||
|
||||
// get retrieval quote -> non-zero for unsealed price as unsealed file does NOT exist.
|
||||
offers, err = s.client.ClientFindData(s.ctx, fcid, &info.PieceCID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, offers, 1)
|
||||
|
||||
require.Equal(t, uint64(unsealPrice), offers[0].UnsealPrice.Uint64())
|
||||
total := (info.Size * uint64(ppb)) + uint64(unsealPrice)
|
||||
require.Equal(t, total, offers[0].MinPrice.Uint64())
|
||||
}
|
||||
|
||||
func TestZeroPricePerByteRetrievalDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, startEpoch abi.ChainEpoch) {
|
||||
s := setupOneClientOneMiner(t, b, blocktime)
|
||||
defer s.blockMiner.Stop()
|
||||
|
2
go.mod
2
go.mod
@ -35,7 +35,7 @@ require (
|
||||
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
||||
github.com/filecoin-project/go-data-transfer v1.5.0
|
||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210522045113-7d33a6e5f793
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210523051904-6c1159720a9b
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.4-0.20210217175800-45ea43ac2bec
|
||||
github.com/filecoin-project/go-multistore v0.0.3
|
||||
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20
|
||||
|
2
go.sum
2
go.sum
@ -279,6 +279,8 @@ github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a/go
|
||||
github.com/filecoin-project/go-fil-markets v1.0.5-0.20201113164554-c5eba40d5335/go.mod h1:AJySOJC00JRWEZzRG2KsfUnqEf5ITXxeX09BE9N4f9c=
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210522045113-7d33a6e5f793 h1:t2u3m3cQM4MFxtQ2EZQkPGtUNUW/NAADbtmTAL44WSw=
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210522045113-7d33a6e5f793/go.mod h1:v8QjFAGf5h2wKH3saYjGOu3pOFUoVQ1Uhow4gIcUR3I=
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210523051904-6c1159720a9b h1:u8tryTQFrtZ4I2kHR4Ep0mbRIu0ZCNZBr+5gA6TB+qs=
|
||||
github.com/filecoin-project/go-fil-markets v1.2.6-0.20210523051904-6c1159720a9b/go.mod h1:v8QjFAGf5h2wKH3saYjGOu3pOFUoVQ1Uhow4gIcUR3I=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24=
|
||||
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM=
|
||||
|
@ -106,6 +106,14 @@ func TestAPIDealFlowReal(t *testing.T) {
|
||||
t.Run("retrieval-second", func(t *testing.T) {
|
||||
test.TestSecondDealRetrieval(t, builder.Builder, time.Second)
|
||||
})
|
||||
|
||||
t.Run("zeroppb-retrieval", func(t *testing.T) {
|
||||
test.TestZeroPricePerByteRetrievalDealFlow(t, builder.Builder, time.Second, 0)
|
||||
})
|
||||
|
||||
t.Run("quote-price-for-non-unsealed-retrieval", func(t *testing.T) {
|
||||
test.TestNonUnsealedRetrievalQuoteForDefaultPricing(t, builder.Builder, time.Second, 0)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDealMining(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user