Skip to content

Commit

Permalink
remove cli test
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 authored and rjan90 committed Mar 21, 2024
1 parent efb3185 commit 722418a
Showing 1 changed file with 0 additions and 122 deletions.
122 changes: 0 additions & 122 deletions itests/direct_data_onboard_verified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/lib/must"
"github.com/filecoin-project/lotus/storage/pipeline/piece"
Expand Down Expand Up @@ -763,124 +762,3 @@ func epochPtr(ei int64) *abi.ChainEpoch {
ep := abi.ChainEpoch(ei)
return &ep
}

func TestVerifiedDDOExtendClaim(t *testing.T) {
kit.QuietMiningLogs()

var (
blocktime = 2 * time.Millisecond
ctx = context.Background()
)

rootKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)

verifierKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)

verifiedClientKey1, err := key.GenerateKey(types.KTBLS)
require.NoError(t, err)

verifiedClientKey2, err := key.GenerateKey(types.KTBLS)
require.NoError(t, err)

unverifiedClient, err := key.GenerateKey(types.KTBLS)
require.NoError(t, err)

bal, err := types.ParseFIL("100fil")
require.NoError(t, err)

client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(),
kit.RootVerifier(rootKey, abi.NewTokenAmount(bal.Int64())),
kit.Account(verifierKey, abi.NewTokenAmount(bal.Int64())),
kit.Account(verifiedClientKey1, abi.NewTokenAmount(bal.Int64())),
kit.Account(verifiedClientKey2, abi.NewTokenAmount(bal.Int64())),
kit.Account(unverifiedClient, abi.NewTokenAmount(bal.Int64())),
)

/* --- Start mining --- */

ens.InterconnectAll().BeginMiningMustPost(blocktime)

minerId, err := address.IDFromAddress(miner.ActorAddr)
require.NoError(t, err)

/* --- Setup verified registry and clients and allocate datacap to client */

_, verifiedClientAddrses := ddoVerifiedSetupVerifiedClient(ctx, t, client, rootKey, verifierKey, []*key.Key{verifiedClientKey1, verifiedClientKey2})
verifiedClientAddr1 := verifiedClientAddrses[0]
verifiedClientAddr2 := verifiedClientAddrses[1]

/* --- Prepare piece for onboarding --- */

pieceSize := abi.PaddedPieceSize(2048).Unpadded()
pieceData := make([]byte, pieceSize)
_, _ = rand.Read(pieceData)

dc, err := miner.ComputeDataCid(ctx, pieceSize, bytes.NewReader(pieceData))
require.NoError(t, err)

/* --- Allocate datacap for the piece by the verified client --- */
clientId, allocationId := ddoVerifiedSetupAllocations(ctx, t, client, minerId, dc, verifiedClientAddr1, 0, builtin.EpochsInYear*3)

/* --- Onboard the piece --- */

_, _ = ddoVerifiedOnboardPiece(ctx, t, miner, clientId, allocationId, dc, pieceData)

oldclaim, err := client.StateGetClaim(ctx, miner.ActorAddr, verifreg.ClaimId(allocationId), types.EmptyTSK)
require.NoError(t, err)
require.NotNil(t, oldclaim)

prov := cli.ProvInfo{
Addr: miner.ActorAddr,
ID: abi.ActorID(minerId),
}

pcm := make(map[verifregtypes13.ClaimId]cli.ProvInfo)
pcm[verifregtypes13.ClaimId(allocationId)] = prov

// Extend claim with same client
msgs, err := cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr1, (builtin.EpochsInYear*3)+3000, false, true)
require.NoError(t, err)
require.NotNil(t, msgs)
require.Len(t, msgs, 1)

// MpoolBatchPushMessage method will take care of gas estimation and funds check
smsg, err := client.MpoolPushMessage(ctx, msgs[0], nil)
require.NoError(t, err)

wait, err := client.StateWaitMsg(ctx, smsg.Cid(), 1, 2000, true)
require.NoError(t, err)
require.True(t, wait.Receipt.ExitCode.IsSuccess())

newclaim, err := client.StateGetClaim(ctx, miner.ActorAddr, verifreg.ClaimId(allocationId), types.EmptyTSK)
require.NoError(t, err)
require.NotNil(t, newclaim)
require.EqualValues(t, newclaim.TermMax-oldclaim.TermMax, 3000)

// Extend claim with non-verified client | should fail
_, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, unverifiedClient.Address, verifregtypes13.MaximumVerifiedAllocationTerm, false, true)
require.ErrorContains(t, err, "does not have any datacap")

// Extend all claim with verified client
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, nil, []string{miner.ActorAddr.String()}, verifiedClientAddr2, verifregtypes13.MaximumVerifiedAllocationTerm, true, true)
require.NoError(t, err)
require.Len(t, msgs, 1)
smsg, err = client.MpoolPushMessage(ctx, msgs[0], nil)
require.NoError(t, err)
wait, err = client.StateWaitMsg(ctx, smsg.Cid(), 1, 2000, true)
require.NoError(t, err)
require.True(t, wait.Receipt.ExitCode.IsSuccess())

// Extend all claims with lower TermMax
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr2, builtin.EpochsInYear*4, false, true)
require.NoError(t, err)
require.Nil(t, msgs)

newclaim, err = client.StateGetClaim(ctx, miner.ActorAddr, verifreg.ClaimId(allocationId), types.EmptyTSK)
require.NoError(t, err)
require.NotNil(t, newclaim)
require.EqualValues(t, newclaim.TermMax, verifregtypes13.MaximumVerifiedAllocationTerm)

// TODO: check "claim-updated" message
}

0 comments on commit 722418a

Please sign in to comment.