Fix tests
This commit is contained in:
parent
eee50caaf1
commit
e8f28d7b9f
@ -96,8 +96,8 @@ func NewWorkerRPCV0(ctx context.Context, addr string, requestHeader http.Header)
|
|||||||
return &res, closer, err
|
return &res, closer, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayRPCV0 creates a new http jsonrpc client for a gateway node.
|
// NewGatewayRPCV1 creates a new http jsonrpc client for a gateway node.
|
||||||
func NewGatewayRPCV0(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.Gateway, jsonrpc.ClientCloser, error) {
|
func NewGatewayRPCV1(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.Gateway, jsonrpc.ClientCloser, error) {
|
||||||
var res api.GatewayStruct
|
var res api.GatewayStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
|
@ -235,7 +235,7 @@ func TestPaymentChannels(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
res, err = paymentReceiver.StateWaitMsg(ctx, collectMsg, 3)
|
res, err = paymentReceiver.StateWaitMsg(ctx, collectMsg, 3, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ func waitForBlocks(ctx context.Context, t *testing.T, bm *BlockMiner, paymentRec
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = paymentReceiver.StateWaitMsg(ctx, m.Cid(), 1)
|
_, err = paymentReceiver.StateWaitMsg(ctx, m.Cid(), 1, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ func waitForMessage(ctx context.Context, t *testing.T, paymentCreator TestNode,
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
fmt.Println("Waiting for", desc)
|
fmt.Println("Waiting for", desc)
|
||||||
res, err := paymentCreator.StateWaitMsg(ctx, msgCid, 1)
|
res, err := paymentCreator.StateWaitMsg(ctx, msgCid, 1, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error waiting for", desc, err)
|
fmt.Println("Error waiting for", desc, err)
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/filecoin-project/lotus/api"
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
@ -44,7 +44,7 @@ type TestNode struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TestStorageNode struct {
|
type TestStorageNode struct {
|
||||||
api.StorageMiner
|
lapi.StorageMiner
|
||||||
// ListenAddr is the address on which an API server is listening, if an
|
// ListenAddr is the address on which an API server is listening, if an
|
||||||
// API server is created for this Node
|
// API server is created for this Node
|
||||||
ListenAddr multiaddr.Multiaddr
|
ListenAddr multiaddr.Multiaddr
|
||||||
@ -156,7 +156,7 @@ var MineNext = miner.MineReq{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *testSuite) testVersion(t *testing.T) {
|
func (ts *testSuite) testVersion(t *testing.T) {
|
||||||
api.RunningNodeType = api.NodeFull
|
lapi.RunningNodeType = lapi.NodeFull
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
apis, _ := ts.makeNodes(t, OneFull, OneMiner)
|
apis, _ := ts.makeNodes(t, OneFull, OneMiner)
|
||||||
@ -197,7 +197,7 @@ func (ts *testSuite) testSearchMsg(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1)
|
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ func (ts *testSuite) testSearchMsg(t *testing.T) {
|
|||||||
t.Fatal("did not successfully send message")
|
t.Fatal("did not successfully send message")
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRes, err := api.StateSearchMsg(ctx, sm.Cid())
|
searchRes, err := api.StateSearchMsg(ctx, types.EmptyTSK, sm.Cid(), lapi.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
)
|
)
|
||||||
@ -28,7 +29,7 @@ func SendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 1)
|
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,7 @@ func TestWindowPostDispute(t *testing.T, b APIBuilder, blocktime time.Duration)
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
fmt.Println("waiting dispute")
|
fmt.Println("waiting dispute")
|
||||||
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence)
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, rec.Receipt.ExitCode, "dispute not accepted: %s", rec.Receipt.ExitCode.Error())
|
require.Zero(t, rec.Receipt.ExitCode, "dispute not accepted: %s", rec.Receipt.ExitCode.Error())
|
||||||
}
|
}
|
||||||
@ -807,7 +807,7 @@ func TestWindowPostDispute(t *testing.T, b APIBuilder, blocktime time.Duration)
|
|||||||
sm, err := client.MpoolPushMessage(ctx, msg, nil)
|
sm, err := client.MpoolPushMessage(ctx, msg, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence)
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, rec.Receipt.ExitCode, "recovery not accepted: %s", rec.Receipt.ExitCode.Error())
|
require.Zero(t, rec.Receipt.ExitCode, "recovery not accepted: %s", rec.Receipt.ExitCode.Error())
|
||||||
}
|
}
|
||||||
@ -886,7 +886,7 @@ func submitBadProof(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence)
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WrapperV1Full struct {
|
type WrapperV1Full struct {
|
||||||
@ -19,7 +18,7 @@ type WrapperV1Full struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
func (w *WrapperV1Full) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
||||||
return w.FullNode.StateSearchMsg(ctx, types.EmptyTSK, msg, stmgr.LookbackNoLimit, true)
|
return w.FullNode.StateSearchMsg(ctx, types.EmptyTSK, msg, api.LookbackNoLimit, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateSearchMsgLimited(ctx context.Context, msg cid.Cid, limit abi.ChainEpoch) (*api.MsgLookup, error) {
|
func (w *WrapperV1Full) StateSearchMsgLimited(ctx context.Context, msg cid.Cid, limit abi.ChainEpoch) (*api.MsgLookup, error) {
|
||||||
@ -27,7 +26,7 @@ func (w *WrapperV1Full) StateSearchMsgLimited(ctx context.Context, msg cid.Cid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
func (w *WrapperV1Full) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
||||||
return w.FullNode.StateWaitMsg(ctx, msg, confidence, stmgr.LookbackNoLimit, true)
|
return w.FullNode.StateWaitMsg(ctx, msg, confidence, api.LookbackNoLimit, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateWaitMsgLimited(ctx context.Context, msg cid.Cid, confidence uint64, limit abi.ChainEpoch) (*api.MsgLookup, error) {
|
func (w *WrapperV1Full) StateWaitMsgLimited(ctx context.Context, msg cid.Cid, confidence uint64, limit abi.ChainEpoch) (*api.MsgLookup, error) {
|
||||||
@ -35,7 +34,7 @@ func (w *WrapperV1Full) StateWaitMsgLimited(ctx context.Context, msg cid.Cid, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateGetReceipt(ctx context.Context, msg cid.Cid, from types.TipSetKey) (*types.MessageReceipt, error) {
|
func (w *WrapperV1Full) StateGetReceipt(ctx context.Context, msg cid.Cid, from types.TipSetKey) (*types.MessageReceipt, error) {
|
||||||
ml, err := w.FullNode.StateSearchMsg(ctx, from, msg, stmgr.LookbackNoLimit, true)
|
ml, err := w.FullNode.StateSearchMsg(ctx, from, msg, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func Wrap(proxyT, wrapperT, impl interface{}) interface{} {
|
|||||||
|
|
||||||
for i := 0; i < ri.NumMethod(); i++ {
|
for i := 0; i < ri.NumMethod(); i++ {
|
||||||
mt := ri.Type().Method(i)
|
mt := ri.Type().Method(i)
|
||||||
if proxyMethods.FieldByName(mt.Name).IsZero() {
|
if proxyMethods.FieldByName(mt.Name).Kind() == reflect.Invalid {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ func (mapi *mockFundManagerAPI) publish(addr address.Address, amt abi.TokenAmoun
|
|||||||
mapi.escrow[addr] = escrow
|
mapi.escrow[addr] = escrow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mapi *mockFundManagerAPI) StateWaitMsg(ctx context.Context, c cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
func (mapi *mockFundManagerAPI) StateWaitMsg(ctx context.Context, c cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||||
res := &api.MsgLookup{
|
res := &api.MsgLookup{
|
||||||
Message: c,
|
Message: c,
|
||||||
Receipt: types.MessageReceipt{
|
Receipt: types.MessageReceipt{
|
||||||
|
@ -622,17 +622,17 @@ func TestDuplicateNonce(t *testing.T) {
|
|||||||
|
|
||||||
var includedMsg cid.Cid
|
var includedMsg cid.Cid
|
||||||
var skippedMsg cid.Cid
|
var skippedMsg cid.Cid
|
||||||
r0, err0 := tu.nds[0].StateGetReceipt(context.TODO(), msgs[0][0].Cid(), ts2.TipSet().Key())
|
r0, err0 := tu.nds[0].StateSearchMsg(context.TODO(), ts2.TipSet().Key(), msgs[0][0].Cid(), api.LookbackNoLimit, true)
|
||||||
r1, err1 := tu.nds[0].StateGetReceipt(context.TODO(), msgs[1][0].Cid(), ts2.TipSet().Key())
|
r1, err1 := tu.nds[0].StateSearchMsg(context.TODO(), ts2.TipSet().Key(), msgs[1][0].Cid(), api.LookbackNoLimit, true)
|
||||||
|
|
||||||
if err0 == nil {
|
if err0 == nil {
|
||||||
require.Error(t, err1, "at least one of the StateGetReceipt calls should fail")
|
require.Error(t, err1, "at least one of the StateGetReceipt calls should fail")
|
||||||
require.True(t, r0.ExitCode.IsSuccess())
|
require.True(t, r0.Receipt.ExitCode.IsSuccess())
|
||||||
includedMsg = msgs[0][0].Message.Cid()
|
includedMsg = msgs[0][0].Message.Cid()
|
||||||
skippedMsg = msgs[1][0].Message.Cid()
|
skippedMsg = msgs[1][0].Message.Cid()
|
||||||
} else {
|
} else {
|
||||||
require.NoError(t, err1, "both the StateGetReceipt calls should not fail")
|
require.NoError(t, err1, "both the StateGetReceipt calls should not fail")
|
||||||
require.True(t, r1.ExitCode.IsSuccess())
|
require.True(t, r1.Receipt.ExitCode.IsSuccess())
|
||||||
includedMsg = msgs[1][0].Message.Cid()
|
includedMsg = msgs[1][0].Message.Cid()
|
||||||
skippedMsg = msgs[0][0].Message.Cid()
|
skippedMsg = msgs[0][0].Message.Cid()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/mocks"
|
mocks "github.com/filecoin-project/lotus/api/v0api/v0mocks"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
|
@ -177,7 +177,7 @@ func GetAPI(ctx *cli.Context) (api.Common, jsonrpc.ClientCloser, error) {
|
|||||||
|
|
||||||
func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, error) {
|
func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, error) {
|
||||||
if tn, ok := ctx.App.Metadata["testnode-full"]; ok {
|
if tn, ok := ctx.App.Metadata["testnode-full"]; ok {
|
||||||
return tn.(v0api.FullNode), func() {}, nil
|
return &v0api.WrapperV1Full{FullNode: tn.(v1api.FullNode)}, func() {}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
||||||
@ -260,7 +260,7 @@ func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error)
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.NewGatewayRPCV0(ctx.Context, addr, headers)
|
return client.NewGatewayRPCV1(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DaemonContext(cctx *cli.Context) context.Context {
|
func DaemonContext(cctx *cli.Context) context.Context {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api/v0api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
@ -72,7 +72,7 @@ var runCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Address, rate, limit int) error {
|
func sendSmallFundsTxs(ctx context.Context, api v0api.FullNode, from address.Address, rate, limit int) error {
|
||||||
var sendSet []address.Address
|
var sendSet []address.Address
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
naddr, err := api.WalletNew(ctx, types.KTSecp256k1)
|
naddr, err := api.WalletNew(ctx, types.KTSecp256k1)
|
||||||
|
@ -24,6 +24,8 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/client"
|
"github.com/filecoin-project/lotus/api/client"
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
"github.com/filecoin-project/lotus/api/test"
|
||||||
|
"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/actors/policy"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -103,7 +105,7 @@ func TestWalletMsig(t *testing.T) {
|
|||||||
addProposal, err := lite.MsigCreate(ctx, 2, msigAddrs, abi.ChainEpoch(50), amt, liteWalletAddr, types.NewInt(0))
|
addProposal, err := lite.MsigCreate(ctx, 2, msigAddrs, abi.ChainEpoch(50), amt, liteWalletAddr, types.NewInt(0))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
res, err := lite.StateWaitMsg(ctx, addProposal, 1)
|
res, err := lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
||||||
|
|
||||||
@ -123,7 +125,7 @@ func TestWalletMsig(t *testing.T) {
|
|||||||
addProposal, err = lite.MsigAddPropose(ctx, msig, walletAddrs[0], walletAddrs[3], false)
|
addProposal, err = lite.MsigAddPropose(ctx, msig, walletAddrs[0], walletAddrs[3], false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
res, err = lite.StateWaitMsg(ctx, addProposal, 1)
|
res, err = lite.StateWaitMsg(ctx, addProposal, 1, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
||||||
|
|
||||||
@ -137,7 +139,7 @@ func TestWalletMsig(t *testing.T) {
|
|||||||
approval1, err := lite.MsigAddApprove(ctx, msig, walletAddrs[1], txnID, walletAddrs[0], walletAddrs[3], false)
|
approval1, err := lite.MsigAddApprove(ctx, msig, walletAddrs[1], txnID, walletAddrs[0], walletAddrs[3], false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
res, err = lite.StateWaitMsg(ctx, approval1, 1)
|
res, err = lite.StateWaitMsg(ctx, approval1, 1, api.LookbackNoLimit, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
require.EqualValues(t, 0, res.Receipt.ExitCode)
|
||||||
|
|
||||||
@ -245,12 +247,15 @@ func startNodes(
|
|||||||
|
|
||||||
// Create a gateway server in front of the full node
|
// Create a gateway server in front of the full node
|
||||||
gapiImpl := newGatewayAPI(fullNode, lookbackCap, stateWaitLookbackLimit)
|
gapiImpl := newGatewayAPI(fullNode, lookbackCap, stateWaitLookbackLimit)
|
||||||
_, addr, err := builder.CreateRPCServer(t, gapiImpl)
|
_, addr, err := builder.CreateRPCServer(t, map[string]interface{}{
|
||||||
|
"/rpc/v1": gapiImpl,
|
||||||
|
"/rpc/v0": api.Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), gapiImpl),
|
||||||
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Create a gateway client API that connects to the gateway server
|
// Create a gateway client API that connects to the gateway server
|
||||||
var gapi api.Gateway
|
var gapi api.Gateway
|
||||||
gapi, closer, err = client.NewGatewayRPCV0(ctx, addr, nil)
|
gapi, closer, err = client.NewGatewayRPCV1(ctx, addr+"/rpc/v1", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Provide the gateway API to dependency injection
|
// Provide the gateway API to dependency injection
|
||||||
@ -299,7 +304,7 @@ func sendFunds(ctx context.Context, fromNode test.TestNode, fromAddr address.Add
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := fromNode.StateWaitMsg(ctx, sm.Cid(), 1)
|
res, err := fromNode.StateWaitMsg(ctx, sm.Cid(), 1, api.LookbackNoLimit, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -22,6 +23,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/client"
|
"github.com/filecoin-project/lotus/api/client"
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
"github.com/filecoin-project/lotus/api/test"
|
||||||
|
"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/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain"
|
"github.com/filecoin-project/lotus/chain"
|
||||||
@ -501,12 +503,15 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
||||||
ma, listenAddr, err := CreateRPCServer(t, nd)
|
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
||||||
|
"/rpc/v1": nd,
|
||||||
|
"/rpc/v0": &v0api.WrapperV1Full{FullNode: nd},
|
||||||
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var stop func()
|
var stop func()
|
||||||
var full test.TestNode
|
var full test.TestNode
|
||||||
full.FullNode, stop, err = client.NewFullNodeRPCV1(context.Background(), listenAddr, nil)
|
full.FullNode, stop, err = client.NewFullNodeRPCV1(context.Background(), listenAddr+"/rpc/v1", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(stop)
|
t.Cleanup(stop)
|
||||||
|
|
||||||
@ -515,12 +520,14 @@ func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func storerRpc(t *testing.T, nd test.TestStorageNode) test.TestStorageNode {
|
func storerRpc(t *testing.T, nd test.TestStorageNode) test.TestStorageNode {
|
||||||
ma, listenAddr, err := CreateRPCServer(t, nd)
|
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
||||||
|
"/rpc/v0": nd,
|
||||||
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var stop func()
|
var stop func()
|
||||||
var storer test.TestStorageNode
|
var storer test.TestStorageNode
|
||||||
storer.StorageMiner, stop, err = client.NewStorageMinerRPCV0(context.Background(), listenAddr, nil)
|
storer.StorageMiner, stop, err = client.NewStorageMinerRPCV0(context.Background(), listenAddr+"/rpc/v0", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(stop)
|
t.Cleanup(stop)
|
||||||
|
|
||||||
@ -529,10 +536,14 @@ func storerRpc(t *testing.T, nd test.TestStorageNode) test.TestStorageNode {
|
|||||||
return storer
|
return storer
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateRPCServer(t *testing.T, handler interface{}) (multiaddr.Multiaddr, string, error) {
|
func CreateRPCServer(t *testing.T, handlers map[string]interface{}) (multiaddr.Multiaddr, string, error) {
|
||||||
rpcServer := jsonrpc.NewServer()
|
m := mux.NewRouter()
|
||||||
rpcServer.Register("Filecoin", handler)
|
for path, handler := range handlers {
|
||||||
testServ := httptest.NewServer(rpcServer) // todo: close
|
rpcServer := jsonrpc.NewServer()
|
||||||
|
rpcServer.Register("Filecoin", handler)
|
||||||
|
m.Handle(path, rpcServer)
|
||||||
|
}
|
||||||
|
testServ := httptest.NewServer(m) // todo: close
|
||||||
t.Cleanup(testServ.Close)
|
t.Cleanup(testServ.Close)
|
||||||
t.Cleanup(testServ.CloseClientConnections)
|
t.Cleanup(testServ.CloseClientConnections)
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"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/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ func newMockPaychAPI() *mockPaychAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pchapi *mockPaychAPI) StateWaitMsg(ctx context.Context, mcid cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
func (pchapi *mockPaychAPI) StateWaitMsg(ctx context.Context, mcid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||||
pchapi.lk.Lock()
|
pchapi.lk.Lock()
|
||||||
|
|
||||||
response := make(chan types.MessageReceipt)
|
response := make(chan types.MessageReceipt)
|
||||||
|
@ -92,7 +92,7 @@ func (m *mockStorageMinerAPI) MpoolPushMessage(ctx context.Context, message *typ
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockStorageMinerAPI) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
func (m *mockStorageMinerAPI) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||||
return &api.MsgLookup{
|
return &api.MsgLookup{
|
||||||
Receipt: types.MessageReceipt{
|
Receipt: types.MessageReceipt{
|
||||||
ExitCode: 0,
|
ExitCode: 0,
|
||||||
@ -311,7 +311,7 @@ func (m *mockStorageMinerAPI) StateMinerInitialPledgeCollateral(ctx context.Cont
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockStorageMinerAPI) StateSearchMsg(ctx context.Context, cid cid.Cid) (*api.MsgLookup, error) {
|
func (m *mockStorageMinerAPI) StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user