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
- go/install-gotestsum:
gobin: $HOME/.local/bin
version: 0.5.2
- run:
name: go test
environment:

View File

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

View File

@ -3,6 +3,7 @@ package test
import (
"context"
"fmt"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
@ -41,26 +42,36 @@ func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSect
mine := true
done := make(chan struct{})
blockNotif := make(chan struct{}, 1)
go func() {
defer close(done)
for mine {
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)
}
}
}()
pledgeSectors(t, ctx, miner, nSectors)
pledgeSectors(t, ctx, miner, nSectors, blockNotif)
mine = false
<-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++ {
err := miner.PledgeSector(ctx)
require.NoError(t, err)
if i%3 == 0 && blockNotif != nil {
<-blockNotif
}
}
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)
require.NoError(t, err)

View File

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

View File

@ -40,6 +40,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
msg := &(*msgIn)
msg.GasLimit = build.BlockGasLimit
msg.GasPrice = types.NewInt(1)
ts, err := a.Cs.GetTipSetFromKey(tsk)
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)
if err != nil {
return -1, xerrors.Errorf("CallWithGas failed: %w", err)
}
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