79453663b3
* Annotate api,proxy_util,blockstore_badger, policy tests * Annotate splitstore: bsbadger / markset * Annotate splitstore feature * Annotate union/timed blockstore tests * Annotate openrpc, diff_adt tests * Annotate error,drand,events tests * Annotate predicates_test * Fix annotations * Annotate tscache, gen tests * Annotate fundmanager test * Annotate repub and selection tests * Annotate statetree_test * Annotate forks_test * Annotate searchwait_test.go * Fix duplicated @@ symbols * Annotate chain stmgr/store tests * Annotate more (types) tests * More tests annotated * Annotate conformance chaos actor tests * Annotate more integration tests * Annotate journal system tests * Annotate more tests. * Annotate gas,head buffer behaviors * Fix markset annotations * doc: test annotations for the markets dagstore wrapper * Annotate miner_api test in dagstore * Annotate more test files * Remove bad annotations from fsrepo * Annotate wdpost system * Remove bad annotations * Renamce "conformance" to "chaos_actor" tests * doc: stm annotations for blockheader & election proof tests * Annotate remaining "A" tests * annotate: stm for error_test * memrepo_test.go * Annotate "b" file tests * message_test.go * doc: stm annotate for fsrepo_test * Annotate "c" file tests * Annotate "D" test files * message_test.go * doc: stm annotate for chain, node/config & client * docs: stm annotate node_test * Annotate u,v,wl tests * doc: stm annotations for various test files * Annotate "T" test files * doc: stm annotate for proxy_util_test & policy_test * doc: stm annotate for various tests * doc: final few stm annotations * Add mempool unit tests * Add two more memPool Add tests * Update submodules * Add check function tests * Add stm annotations, refactor test helper * Annotate api,proxy_util,blockstore_badger, policy tests * Annotate splitstore: bsbadger / markset solving merge conflicts * Annotate splitstore feature * Annotate union/timed blockstore tests * Annotate openrpc, diff_adt tests * Annotate error,drand,events tests * Annotate predicates_test * Fix annotations * Annotate tscache, gen tests * Annotate fundmanager test * Annotate statetree_test * Annotate forks_test * Annotate searchwait_test.go * Fix duplicated @@ symbols * Annotate chain stmgr/store tests * Annotate more (types) tests * More tests annotated * Annotate conformance chaos actor tests * Annotate more integration tests * Annotate journal system tests * Annotate more tests. * Annotate gas,head buffer behaviors solve merge conflict * Fix markset annotations * Annotate miner_api test in dagstore * Annotate more test files * doc: test annotations for the markets dagstore wrapper * Annotate wdpost system * Renamce "conformance" to "chaos_actor" tests * Annotate remaining "A" tests * doc: stm annotations for blockheader & election proof tests * annotate: stm for error_test * Annotate "b" file tests * memrepo_test.go * Annotate "c" file tests * message_test.go * Annotate "D" test files * doc: stm annotate for fsrepo_test * Annotate u,v,wl tests * message_test.go * doc: stm annotate for chain, node/config & client * docs: stm annotate node_test * Annotate "T" test files * doc: stm annotations for various test files * Add mempool unit tests solve merge conflict * doc: stm annotate for proxy_util_test & policy_test * doc: stm annotate for various tests * doc: final few stm annotations * Add two more memPool Add tests * Update submodules * Add check function tests solve conflict * Add stm annotations, refactor test helper solve merge conflict * Change CLI test kinds to "unit" * Fix double merged test * Fix ccupgrade_test merge * Fix lint issues * Add stm annotation to types_Test * Test vectors submodule * Add file annotation to burn_test Co-authored-by: Nikola Divic <divicnikola@gmail.com> Co-authored-by: TheMenko <themenkoprojects@gmail.com>
157 lines
4.0 KiB
Go
157 lines
4.0 KiB
Go
//stm: #integration
|
|
package dagstore
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"testing"
|
|
|
|
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/filecoin-project/dagstore"
|
|
"github.com/filecoin-project/dagstore/mount"
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket/impl/testnodes"
|
|
tut "github.com/filecoin-project/go-fil-markets/shared_testutil"
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
|
|
|
"github.com/filecoin-project/lotus/node/config"
|
|
|
|
"github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
|
)
|
|
|
|
func TestShardRegistration(t *testing.T) {
|
|
ps := tut.NewTestPieceStore()
|
|
sa := testnodes.NewTestSectorAccessor()
|
|
|
|
ctx := context.Background()
|
|
cids := tut.GenerateCids(4)
|
|
pieceCidUnsealed := cids[0]
|
|
pieceCidSealed := cids[1]
|
|
pieceCidUnsealed2 := cids[2]
|
|
pieceCidUnsealed3 := cids[3]
|
|
|
|
sealedSector := abi.SectorNumber(1)
|
|
unsealedSector1 := abi.SectorNumber(2)
|
|
unsealedSector2 := abi.SectorNumber(3)
|
|
unsealedSector3 := abi.SectorNumber(4)
|
|
|
|
// ps.ExpectPiece(pieceCidUnsealed, piecestore.PieceInfo{
|
|
// PieceCID: pieceCidUnsealed,
|
|
// Deals: []piecestore.DealInfo{
|
|
// {
|
|
// SectorID: unsealedSector1,
|
|
// },
|
|
// },
|
|
// })
|
|
//
|
|
// ps.ExpectPiece(pieceCidSealed, piecestore.PieceInfo{
|
|
// PieceCID: pieceCidSealed,
|
|
// Deals: []piecestore.DealInfo{
|
|
// {
|
|
// SectorID: sealedSector,
|
|
// },
|
|
// },
|
|
// })
|
|
|
|
deals := []storagemarket.MinerDeal{{
|
|
// Should be registered
|
|
//stm: @MARKET_DAGSTORE_MIGRATE_DEALS_001
|
|
State: storagemarket.StorageDealSealing,
|
|
SectorNumber: unsealedSector1,
|
|
ClientDealProposal: market.ClientDealProposal{
|
|
Proposal: market.DealProposal{
|
|
PieceCID: pieceCidUnsealed,
|
|
},
|
|
},
|
|
}, {
|
|
// Should be registered with lazy registration (because sector is sealed)
|
|
State: storagemarket.StorageDealSealing,
|
|
SectorNumber: sealedSector,
|
|
ClientDealProposal: market.ClientDealProposal{
|
|
Proposal: market.DealProposal{
|
|
PieceCID: pieceCidSealed,
|
|
},
|
|
},
|
|
}, {
|
|
// Should be ignored because deal is no longer active
|
|
//stm: @MARKET_DAGSTORE_MIGRATE_DEALS_003
|
|
State: storagemarket.StorageDealError,
|
|
SectorNumber: unsealedSector2,
|
|
ClientDealProposal: market.ClientDealProposal{
|
|
Proposal: market.DealProposal{
|
|
PieceCID: pieceCidUnsealed2,
|
|
},
|
|
},
|
|
}, {
|
|
// Should be ignored because deal is not yet sealing
|
|
State: storagemarket.StorageDealFundsReserved,
|
|
SectorNumber: unsealedSector3,
|
|
ClientDealProposal: market.ClientDealProposal{
|
|
Proposal: market.DealProposal{
|
|
PieceCID: pieceCidUnsealed3,
|
|
},
|
|
},
|
|
}}
|
|
|
|
cfg := config.DefaultStorageMiner().DAGStore
|
|
cfg.RootDir = t.TempDir()
|
|
|
|
h, err := mocknet.New().GenPeer()
|
|
require.NoError(t, err)
|
|
|
|
mapi := NewMinerAPI(ps, &wrappedSA{sa}, 10, 5)
|
|
dagst, w, err := NewDAGStore(cfg, mapi, h)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, dagst)
|
|
require.NotNil(t, w)
|
|
|
|
err = dagst.Start(context.Background())
|
|
require.NoError(t, err)
|
|
|
|
migrated, err := w.MigrateDeals(ctx, deals)
|
|
require.True(t, migrated)
|
|
require.NoError(t, err)
|
|
|
|
//stm: @MARKET_DAGSTORE_GET_ALL_SHARDS_001
|
|
info := dagst.AllShardsInfo()
|
|
require.Len(t, info, 2)
|
|
for _, i := range info {
|
|
require.Equal(t, dagstore.ShardStateNew, i.ShardState)
|
|
}
|
|
|
|
// Run register shard migration again
|
|
//stm: @MARKET_DAGSTORE_MIGRATE_DEALS_002
|
|
migrated, err = w.MigrateDeals(ctx, deals)
|
|
require.False(t, migrated)
|
|
require.NoError(t, err)
|
|
|
|
// ps.VerifyExpectations(t)
|
|
}
|
|
|
|
type wrappedSA struct {
|
|
retrievalmarket.SectorAccessor
|
|
}
|
|
|
|
func (w *wrappedSA) UnsealSectorAt(ctx context.Context, sectorID abi.SectorNumber, pieceOffset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (mount.Reader, error) {
|
|
r, err := w.UnsealSector(ctx, sectorID, pieceOffset, length)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return struct {
|
|
io.ReadCloser
|
|
io.Seeker
|
|
io.ReaderAt
|
|
}{
|
|
ReadCloser: r,
|
|
Seeker: nil,
|
|
ReaderAt: nil,
|
|
}, err
|
|
}
|
|
|
|
var _ SectorAccessor = &wrappedSA{}
|