097d82535d
* wip * commit with fewer error messages * reduce headlag from 3 to 1 * fixes for params * add composition for local:docker * revert drand-halt plan * initial monitor of miner power and chain epochs * revert params to be same as filecoin mainnet * increase timeout for drand resuming from 30sec to 120sec. * increase log level * upgrade lotus to v0.6.1 * upgrade drand to v1.1.1 * increase prepare node timeout from 1 min to 3 min * upgrade drand to master. increase timeouts for prepare drand node * nil the stmgr.ForksAtHeight map * modify starting/stopping of drand within testplan * increase drand outage to 45min. so that we miss windows * upgrade proof parameters in docker images * revert in-complete changes * use correct runtime debug image
74 lines
1.8 KiB
Go
74 lines
1.8 KiB
Go
package testkit
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/filecoin-project/go-address"
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"github.com/filecoin-project/lotus/api"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
"github.com/ipfs/go-cid"
|
|
|
|
tstats "github.com/filecoin-project/lotus/tools/stats"
|
|
)
|
|
|
|
func StartDeal(ctx context.Context, minerActorAddr address.Address, client api.FullNode, fcid cid.Cid, fastRetrieval bool) *cid.Cid {
|
|
addr, err := client.WalletDefaultAddress(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
deal, err := client.ClientStartDeal(ctx, &api.StartDealParams{
|
|
Data: &storagemarket.DataRef{
|
|
TransferType: storagemarket.TTGraphsync,
|
|
Root: fcid,
|
|
},
|
|
Wallet: addr,
|
|
Miner: minerActorAddr,
|
|
EpochPrice: types.NewInt(1000),
|
|
MinBlocksDuration: 640000,
|
|
FastRetrieval: fastRetrieval,
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return deal
|
|
}
|
|
|
|
func WaitDealSealed(t *TestEnvironment, ctx context.Context, client api.FullNode, deal *cid.Cid) {
|
|
height := 0
|
|
headlag := 3
|
|
|
|
cctx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
|
|
tipsetsCh, err := tstats.GetTips(cctx, client, abi.ChainEpoch(height), headlag)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for tipset := range tipsetsCh {
|
|
t.RecordMessage("got tipset: height %d", tipset.Height())
|
|
|
|
di, err := client.ClientGetDealInfo(ctx, *deal)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
switch di.State {
|
|
case storagemarket.StorageDealProposalRejected:
|
|
panic("deal rejected")
|
|
case storagemarket.StorageDealFailing:
|
|
panic("deal failed")
|
|
case storagemarket.StorageDealError:
|
|
panic(fmt.Sprintf("deal errored %s", di.Message))
|
|
case storagemarket.StorageDealActive:
|
|
t.RecordMessage("completed deal: %s", di)
|
|
return
|
|
}
|
|
|
|
t.RecordMessage("deal state: %s", storagemarket.DealStates[di.State])
|
|
}
|
|
}
|