Slow down pledgeSectors test

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-07-20 20:33:15 +02:00
parent 7da629d03b
commit e6b3ba0178
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
5 changed files with 27 additions and 22 deletions

View File

@ -156,6 +156,7 @@ jobs:
- download-params - download-params
- go/install-gotestsum: - go/install-gotestsum:
gobin: $HOME/.local/bin gobin: $HOME/.local/bin
version: 0.5.2
- run: - run:
name: go test name: go test
environment: environment:

View File

@ -54,7 +54,7 @@ func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) {
CC := abi.SectorNumber(GenesisPreseals + 1) CC := abi.SectorNumber(GenesisPreseals + 1)
Upgraded := CC + 1 Upgraded := CC + 1
pledgeSectors(t, ctx, miner, 1) pledgeSectors(t, ctx, miner, 1, nil)
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsList(ctx)
if err != nil { if err != nil {

View File

@ -3,6 +3,7 @@ package test
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
@ -41,26 +42,36 @@ func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSect
mine := true mine := true
done := make(chan struct{}) done := make(chan struct{})
blockNotif := make(chan struct{}, 1)
go func() { go func() {
defer close(done) defer close(done)
for mine { for mine {
build.Clock.Sleep(blocktime) build.Clock.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool, error) {}); err != nil { if err := sn[0].MineOne(ctx, func(bool, error) {
select {
case blockNotif <- struct{}{}:
default:
}
}); err != nil {
t.Error(err) t.Error(err)
} }
} }
}() }()
pledgeSectors(t, ctx, miner, nSectors) pledgeSectors(t, ctx, miner, nSectors, blockNotif)
mine = false mine = false
<-done <-done
} }
func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int) { func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int, blockNotif <-chan struct{}) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
err := miner.PledgeSector(ctx) err := miner.PledgeSector(ctx)
require.NoError(t, err) require.NoError(t, err)
if i%3 == 0 && blockNotif != nil {
<-blockNotif
}
} }
for { for {
@ -131,7 +142,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
} }
}() }()
pledgeSectors(t, ctx, miner, nSectors) pledgeSectors(t, ctx, miner, nSectors, nil)
maddr, err := miner.ActorAddress(ctx) maddr, err := miner.ActorAddress(ctx)
require.NoError(t, err) require.NoError(t, err)

View File

@ -22,13 +22,6 @@ var rewardsCmd = &cli.Command{
var rewardsRedeemCmd = &cli.Command{ var rewardsRedeemCmd = &cli.Command{
Name: "redeem", Name: "redeem",
Usage: "Redeem block rewards", Usage: "Redeem block rewards",
Flags: []cli.Flag{
&cli.Int64Flag{
Name: "gas-limit",
Usage: "set gas limit",
Value: 100000,
},
},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil { if err != nil {
@ -66,14 +59,10 @@ var rewardsRedeemCmd = &cli.Command{
return err return err
} }
gasLimit := cctx.Int64("gas-limit")
smsg, err := api.MpoolPushMessage(ctx, &types.Message{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{
To: maddr, To: maddr,
From: mi.Owner, From: mi.Owner,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: types.NewInt(1),
GasLimit: gasLimit,
Method: builtin.MethodsMiner.WithdrawBalance, Method: builtin.MethodsMiner.WithdrawBalance,
Params: params, Params: params,
}) })

View File

@ -40,6 +40,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
msg := &(*msgIn) msg := &(*msgIn)
msg.GasLimit = build.BlockGasLimit msg.GasLimit = build.BlockGasLimit
msg.GasPrice = types.NewInt(1)
ts, err := a.Cs.GetTipSetFromKey(tsk) ts, err := a.Cs.GetTipSetFromKey(tsk)
if err != nil { if err != nil {
@ -47,8 +48,11 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
} }
res, err := a.Stmgr.CallWithGas(ctx, msg, ts) res, err := a.Stmgr.CallWithGas(ctx, msg, ts)
if err != nil {
return -1, xerrors.Errorf("CallWithGas failed: %w", err)
}
if res.MsgRct.ExitCode != exitcode.Ok { if res.MsgRct.ExitCode != exitcode.Ok {
return -1, xerrors.Errorf("could not apply message: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error) return -1, xerrors.Errorf("message execution failed: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error)
} }
return res.MsgRct.GasUsed, nil return res.MsgRct.GasUsed, nil