remove duplicated vars.

This commit is contained in:
Raúl Kripalani 2021-05-19 17:30:06 +01:00
parent 88c6642330
commit ac4f3ab684
4 changed files with 21 additions and 27 deletions

View File

@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/cli"
clitest "github.com/filecoin-project/lotus/cli/test"
"github.com/filecoin-project/lotus/gateway"
@ -30,14 +31,15 @@ import (
"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/api/v1api"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node"
builder "github.com/filecoin-project/lotus/node/test"
)
const maxLookbackCap = time.Duration(math.MaxInt64)
const maxStateWaitLookbackLimit = stmgr.LookbackNoLimit
const (
maxLookbackCap = time.Duration(math.MaxInt64)
maxStateWaitLookbackLimit = stmgr.LookbackNoLimit
)
func init() {
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)

View File

@ -5,7 +5,6 @@ import (
"net"
"net/http"
"os"
"time"
"contrib.go.opencensus.io/exporter/prometheus"
"github.com/filecoin-project/go-jsonrpc"
@ -31,11 +30,6 @@ import (
var log = logging.Logger("gateway")
const (
LookbackCap = time.Hour * 24
StateWaitLookbackLimit = abi.ChainEpoch(20)
)
func main() {
lotuslog.SetupLogLevels()
@ -81,12 +75,12 @@ var runCmd = &cli.Command{
&cli.DurationFlag{
Name: "api-max-lookback",
Usage: "maximum duration allowable for tipset lookbacks",
Value: LookbackCap,
Value: gateway.DefaultLookbackCap,
},
&cli.Int64Flag{
Name: "api-wait-lookback-limit",
Usage: "maximum number of blocks to search back through for message inclusion",
Value: int64(StateWaitLookbackLimit),
Value: int64(gateway.DefaultStateWaitLookbackLimit),
},
},
Action: func(cctx *cli.Context) error {

View File

@ -22,6 +22,11 @@ import (
"github.com/ipfs/go-cid"
)
const (
DefaultLookbackCap = time.Hour * 24
DefaultStateWaitLookbackLimit = abi.ChainEpoch(20)
)
// TargetAPI defines the API methods that the Node depends on
// (to make it easy to mock for tests)
type TargetAPI interface {

View File

@ -6,31 +6,24 @@ import (
"testing"
"time"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/build"
"github.com/ipfs/go-cid"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/chain/types/mock"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
)
"github.com/filecoin-project/go-state-types/network"
const (
lookbackCap = time.Hour * 24
stateWaitLookbackLimit = abi.ChainEpoch(20)
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/mock"
)
func TestGatewayAPIChainGetTipSetByHeight(t *testing.T) {
ctx := context.Background()
lookbackTimestamp := uint64(time.Now().Unix()) - uint64(lookbackCap.Seconds())
lookbackTimestamp := uint64(time.Now().Unix()) - uint64(DefaultLookbackCap.Seconds())
type args struct {
h abi.ChainEpoch
tskh abi.ChainEpoch
@ -96,7 +89,7 @@ func TestGatewayAPIChainGetTipSetByHeight(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
mock := &mockGatewayDepsAPI{}
a := NewNode(mock, lookbackCap, stateWaitLookbackLimit)
a := NewNode(mock, DefaultLookbackCap, DefaultStateWaitLookbackLimit)
// Create tipsets from genesis up to tskh and return the highest
ts := mock.createTipSets(tt.args.tskh, tt.args.genesisTS)