From 3e32aa896c80a63525d8d9573906b83460db27d3 Mon Sep 17 00:00:00 2001 From: Darko Brdareski Date: Thu, 16 Dec 2021 14:36:02 +0100 Subject: [PATCH] Annotate client storage deals feature --- itests/deals_512mb_test.go | 1 + itests/deals_max_staging_deals_test.go | 1 + itests/deals_offline_test.go | 2 ++ itests/deals_padding_test.go | 2 ++ itests/deals_partial_retrieval_test.go | 5 +++++ itests/deals_pricing_test.go | 4 ++++ itests/deals_retry_deal_no_funds_test.go | 3 +++ node/impl/client/client_test.go | 4 ++++ 8 files changed, 22 insertions(+) diff --git a/itests/deals_512mb_test.go b/itests/deals_512mb_test.go index 2c3d59dbe..967e33da4 100644 --- a/itests/deals_512mb_test.go +++ b/itests/deals_512mb_test.go @@ -19,6 +19,7 @@ func TestStorageDealMissingBlock(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() // enable 512MiB proofs so we can conduct larger transfers. diff --git a/itests/deals_max_staging_deals_test.go b/itests/deals_max_staging_deals_test.go index 66285ace3..6a4234e02 100644 --- a/itests/deals_max_staging_deals_test.go +++ b/itests/deals_max_staging_deals_test.go @@ -19,6 +19,7 @@ func TestMaxStagingDeals(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() // enable 512MiB proofs so we can conduct larger transfers. diff --git a/itests/deals_offline_test.go b/itests/deals_offline_test.go index 92121b339..bb2549026 100644 --- a/itests/deals_offline_test.go +++ b/itests/deals_offline_test.go @@ -23,6 +23,7 @@ func TestOfflineDealFlow(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_DATA_CALCULATE_COMMP_001, @CLIENT_DATA_GENERATE_CAR_001, @CLIENT_DATA_GET_DEAL_PIECE_CID_001, @CLIENT_DATA_GET_DEAL_PIECE_CID_001 runTest := func(t *testing.T, fastRet bool, upscale abi.PaddedPieceSize) { ctx := context.Background() client, miner, ens := kit.EnsembleMinimal(t, kit.WithAllSubsystems()) // no mock proofs @@ -66,6 +67,7 @@ func TestOfflineDealFlow(t *testing.T) { proposalCid := dh.StartDeal(ctx, dp) + //stm: @CLIENT_STORAGE_DEALS_GET_001 // Wait for the deal to reach StorageDealCheckForAcceptance on the client cd, err := client.ClientGetDealInfo(ctx, *proposalCid) require.NoError(t, err) diff --git a/itests/deals_padding_test.go b/itests/deals_padding_test.go index e7881e888..c79b6a7db 100644 --- a/itests/deals_padding_test.go +++ b/itests/deals_padding_test.go @@ -21,6 +21,7 @@ func TestDealPadding(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_DATA_GET_DEAL_PIECE_CID_001 kit.QuietMiningLogs() var blockTime = 250 * time.Millisecond @@ -64,6 +65,7 @@ func TestDealPadding(t *testing.T) { // TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this time.Sleep(time.Second) + //stm: @CLIENT_STORAGE_DEALS_GET_001 di, err := client.ClientGetDealInfo(ctx, *proposalCid) require.NoError(t, err) require.True(t, di.PieceCID.Equals(pcid)) diff --git a/itests/deals_partial_retrieval_test.go b/itests/deals_partial_retrieval_test.go index 9285d3c2b..4a92db034 100644 --- a/itests/deals_partial_retrieval_test.go +++ b/itests/deals_partial_retrieval_test.go @@ -1,3 +1,4 @@ +//stm: #integration package itests import ( @@ -42,6 +43,7 @@ func TestPartialRetrieval(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_RETRIEVAL_RETRIEVE_001 ctx := context.Background() policy.SetPreCommitChallengeDelay(2) @@ -79,6 +81,7 @@ func TestPartialRetrieval(t *testing.T) { } proposalCid := dh.StartDeal(ctx, dp) + //stm: @CLIENT_STORAGE_DEALS_GET_001 // Wait for the deal to reach StorageDealCheckForAcceptance on the client cd, err := client.ClientGetDealInfo(ctx, *proposalCid) require.NoError(t, err) @@ -87,12 +90,14 @@ func TestPartialRetrieval(t *testing.T) { return cd.State == storagemarket.StorageDealCheckForAcceptance }, 30*time.Second, 1*time.Second, "actual deal status is %s", storagemarket.DealStates[cd.State]) + //stm: @MINER_IMPORT_DEAL_DATA_001 err = miner.DealsImportData(ctx, *proposalCid, sourceCar) require.NoError(t, err) // Wait for the deal to be published, we should be able to start retrieval right away dh.WaitDealPublished(ctx, proposalCid) + //stm: @CLIENT_RETRIEVAL_FIND_001 offers, err := client.ClientFindData(ctx, carRoot, nil) require.NoError(t, err) require.NotEmpty(t, offers, "no offers") diff --git a/itests/deals_pricing_test.go b/itests/deals_pricing_test.go index a3e5f55bc..b1f1d7e5d 100644 --- a/itests/deals_pricing_test.go +++ b/itests/deals_pricing_test.go @@ -50,10 +50,12 @@ func TestQuotePriceForUnsealedRetrieval(t *testing.T) { _, res2, _ := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{Rseed: 6}) require.Equal(t, res1.Root, res2.Root) + //stm: @CLIENT_STORAGE_DEALS_GET_001 // Retrieval dealInfo, err := client.ClientGetDealInfo(ctx, *deal1) require.NoError(t, err) + //stm: @CLIENT_RETRIEVAL_FIND_001 // fetch quote -> zero for unsealed price since unsealed file already exists. offers, err := client.ClientFindData(ctx, res1.Root, &dealInfo.PieceCID) require.NoError(t, err) @@ -79,6 +81,7 @@ iLoop: } } + //stm: @CLIENT_RETRIEVAL_FIND_001 // get retrieval quote -> zero for unsealed price as unsealed file exists. offers, err = client.ClientFindData(ctx, res1.Root, &dealInfo.PieceCID) require.NoError(t, err) @@ -98,6 +101,7 @@ iLoop: } } + //stm: @CLIENT_RETRIEVAL_FIND_001 // fetch quote -> non-zero for unseal price as we no more unsealed files. offers, err = client.ClientFindData(ctx, res1.Root, &dealInfo.PieceCID) require.NoError(t, err) diff --git a/itests/deals_retry_deal_no_funds_test.go b/itests/deals_retry_deal_no_funds_test.go index 8cfece175..a14a0d085 100644 --- a/itests/deals_retry_deal_no_funds_test.go +++ b/itests/deals_retry_deal_no_funds_test.go @@ -33,6 +33,7 @@ func TestDealsRetryLackOfFunds(t *testing.T) { //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 //stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001 + //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() policy.SetPreCommitChallengeDelay(5) @@ -116,6 +117,7 @@ func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) { //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 + //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() policy.SetPreCommitChallengeDelay(5) @@ -196,6 +198,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) { //stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01 //stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001 //stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001 + //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() policy.SetPreCommitChallengeDelay(5) diff --git a/node/impl/client/client_test.go b/node/impl/client/client_test.go index 8e3c3cbff..2be87a659 100644 --- a/node/impl/client/client_test.go +++ b/node/impl/client/client_test.go @@ -32,6 +32,7 @@ import ( var testdata embed.FS func TestImportLocal(t *testing.T) { + //stm: @CLIENT_STORAGE_DEALS_IMPORT_LOCAL_001, @CLIENT_RETRIEVAL_FIND_001 ds := dssync.MutexWrap(datastore.NewMapDatastore()) dir := t.TempDir() im := imports.NewManager(ds, dir) @@ -45,6 +46,7 @@ func TestImportLocal(t *testing.T) { b, err := testdata.ReadFile("testdata/payload.txt") require.NoError(t, err) + //stm @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 root, err := a.ClientImportLocal(ctx, bytes.NewReader(b)) require.NoError(t, err) require.NotEqual(t, cid.Undef, root) @@ -57,6 +59,7 @@ func TestImportLocal(t *testing.T) { require.Equal(t, root, *it.Root) require.True(t, strings.HasPrefix(it.CARPath, dir)) + //stm @CLIENT_DATA_HAS_LOCAL_001 local, err := a.ClientHasLocal(ctx, root) require.NoError(t, err) require.True(t, local) @@ -69,6 +72,7 @@ func TestImportLocal(t *testing.T) { // retrieve as UnixFS. out1 := filepath.Join(dir, "retrieval1.data") // as unixfs out2 := filepath.Join(dir, "retrieval2.data") // as car + //stm: @CLIENT_RETRIEVAL_RETRIEVE_001 err = a.ClientRetrieve(ctx, order, &api.FileRef{ Path: out1, })