remove duplicated vars.
This commit is contained in:
parent
88c6642330
commit
ac4f3ab684
@ -9,6 +9,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/cli"
|
"github.com/filecoin-project/lotus/cli"
|
||||||
clitest "github.com/filecoin-project/lotus/cli/test"
|
clitest "github.com/filecoin-project/lotus/cli/test"
|
||||||
"github.com/filecoin-project/lotus/gateway"
|
"github.com/filecoin-project/lotus/gateway"
|
||||||
@ -30,14 +31,15 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api/v0api"
|
"github.com/filecoin-project/lotus/api/v0api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
"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/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
builder "github.com/filecoin-project/lotus/node/test"
|
builder "github.com/filecoin-project/lotus/node/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxLookbackCap = time.Duration(math.MaxInt64)
|
const (
|
||||||
const maxStateWaitLookbackLimit = stmgr.LookbackNoLimit
|
maxLookbackCap = time.Duration(math.MaxInt64)
|
||||||
|
maxStateWaitLookbackLimit = stmgr.LookbackNoLimit
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"contrib.go.opencensus.io/exporter/prometheus"
|
"contrib.go.opencensus.io/exporter/prometheus"
|
||||||
"github.com/filecoin-project/go-jsonrpc"
|
"github.com/filecoin-project/go-jsonrpc"
|
||||||
@ -31,11 +30,6 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("gateway")
|
var log = logging.Logger("gateway")
|
||||||
|
|
||||||
const (
|
|
||||||
LookbackCap = time.Hour * 24
|
|
||||||
StateWaitLookbackLimit = abi.ChainEpoch(20)
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
lotuslog.SetupLogLevels()
|
lotuslog.SetupLogLevels()
|
||||||
|
|
||||||
@ -81,12 +75,12 @@ var runCmd = &cli.Command{
|
|||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
Name: "api-max-lookback",
|
Name: "api-max-lookback",
|
||||||
Usage: "maximum duration allowable for tipset lookbacks",
|
Usage: "maximum duration allowable for tipset lookbacks",
|
||||||
Value: LookbackCap,
|
Value: gateway.DefaultLookbackCap,
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "api-wait-lookback-limit",
|
Name: "api-wait-lookback-limit",
|
||||||
Usage: "maximum number of blocks to search back through for message inclusion",
|
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 {
|
Action: func(cctx *cli.Context) error {
|
||||||
|
@ -22,6 +22,11 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultLookbackCap = time.Hour * 24
|
||||||
|
DefaultStateWaitLookbackLimit = abi.ChainEpoch(20)
|
||||||
|
)
|
||||||
|
|
||||||
// TargetAPI defines the API methods that the Node depends on
|
// TargetAPI defines the API methods that the Node depends on
|
||||||
// (to make it easy to mock for tests)
|
// (to make it easy to mock for tests)
|
||||||
type TargetAPI interface {
|
type TargetAPI interface {
|
||||||
|
@ -6,31 +6,24 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/filecoin-project/lotus/api"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types/mock"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
"github.com/filecoin-project/lotus/api"
|
||||||
lookbackCap = time.Hour * 24
|
"github.com/filecoin-project/lotus/build"
|
||||||
stateWaitLookbackLimit = abi.ChainEpoch(20)
|
"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) {
|
func TestGatewayAPIChainGetTipSetByHeight(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
lookbackTimestamp := uint64(time.Now().Unix()) - uint64(lookbackCap.Seconds())
|
lookbackTimestamp := uint64(time.Now().Unix()) - uint64(DefaultLookbackCap.Seconds())
|
||||||
type args struct {
|
type args struct {
|
||||||
h abi.ChainEpoch
|
h abi.ChainEpoch
|
||||||
tskh abi.ChainEpoch
|
tskh abi.ChainEpoch
|
||||||
@ -96,7 +89,7 @@ func TestGatewayAPIChainGetTipSetByHeight(t *testing.T) {
|
|||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
mock := &mockGatewayDepsAPI{}
|
mock := &mockGatewayDepsAPI{}
|
||||||
a := NewNode(mock, lookbackCap, stateWaitLookbackLimit)
|
a := NewNode(mock, DefaultLookbackCap, DefaultStateWaitLookbackLimit)
|
||||||
|
|
||||||
// Create tipsets from genesis up to tskh and return the highest
|
// Create tipsets from genesis up to tskh and return the highest
|
||||||
ts := mock.createTipSets(tt.args.tskh, tt.args.genesisTS)
|
ts := mock.createTipSets(tt.args.tskh, tt.args.genesisTS)
|
||||||
|
Loading…
Reference in New Issue
Block a user