paychmgr: Fix tests after api changes
This commit is contained in:
parent
df5bd147fa
commit
36a1934845
@ -66,7 +66,6 @@ func TestPaymentChannelsAPI(t *testing.T) {
|
|||||||
|
|
||||||
channelAmt := int64(7000)
|
channelAmt := int64(7000)
|
||||||
channelInfo, err := paymentCreator.PaychGet(ctx, createrAddr, receiverAddr, abi.NewTokenAmount(channelAmt), api.PaychGetOpts{
|
channelInfo, err := paymentCreator.PaychGet(ctx, createrAddr, receiverAddr, abi.NewTokenAmount(channelAmt), api.PaychGetOpts{
|
||||||
Reserve: true,
|
|
||||||
OffChain: false,
|
OffChain: false,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -23,7 +23,10 @@ type PaychAPI struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt, opts api.PaychGetOpts) (*api.ChannelInfo, error) {
|
func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt, opts api.PaychGetOpts) (*api.ChannelInfo, error) {
|
||||||
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, true, opts)
|
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, paychmgr.GetOpts{
|
||||||
|
Reserve: true,
|
||||||
|
OffChain: opts.OffChain,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -35,7 +38,10 @@ func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt t
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *PaychAPI) PaychFund(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) {
|
func (a *PaychAPI) PaychFund(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) {
|
||||||
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, false, api.PaychGetOpts{OffChain: false})
|
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, paychmgr.GetOpts{
|
||||||
|
Reserve: false,
|
||||||
|
OffChain: false,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -101,17 +101,12 @@ func (pm *Manager) Stop() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type getOpts struct {
|
type GetOpts struct {
|
||||||
Reserve bool
|
Reserve bool
|
||||||
OffChain bool
|
OffChain bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, reserve bool, o api.PaychGetOpts) (address.Address, cid.Cid, error) {
|
func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error) {
|
||||||
opts := getOpts{
|
|
||||||
Reserve: reserve,
|
|
||||||
OffChain: o.OffChain,
|
|
||||||
}
|
|
||||||
|
|
||||||
if !opts.Reserve && opts.OffChain {
|
if !opts.Reserve && opts.OffChain {
|
||||||
return address.Undef, cid.Undef, xerrors.Errorf("can't fund payment channels without on-chain operations")
|
return address.Undef, cid.Undef, xerrors.Errorf("can't fund payment channels without on-chain operations")
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,25 @@ import (
|
|||||||
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
||||||
tutils "github.com/filecoin-project/specs-actors/v2/support/testing"
|
tutils "github.com/filecoin-project/specs-actors/v2/support/testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
|
||||||
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
paychmock "github.com/filecoin-project/lotus/chain/actors/builtin/paych/mock"
|
paychmock "github.com/filecoin-project/lotus/chain/actors/builtin/paych/mock"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var onChainReserve = api.PaychGetOpts{
|
var onChainReserve = GetOpts{
|
||||||
Reserve: true,
|
Reserve: true,
|
||||||
OffChain: false,
|
OffChain: false,
|
||||||
}
|
}
|
||||||
var onChainNoReserve = api.PaychGetOpts{
|
var onChainNoReserve = GetOpts{
|
||||||
Reserve: false,
|
Reserve: false,
|
||||||
OffChain: false,
|
OffChain: false,
|
||||||
}
|
}
|
||||||
var offChainReserve = api.PaychGetOpts{
|
var offChainReserve = GetOpts{
|
||||||
Reserve: true,
|
Reserve: true,
|
||||||
OffChain: true,
|
OffChain: true,
|
||||||
}
|
}
|
||||||
var offChainNoReserve = api.PaychGetOpts{
|
var offChainNoReserve = GetOpts{
|
||||||
Reserve: false,
|
Reserve: false,
|
||||||
OffChain: true,
|
OffChain: true,
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,14 @@ type fundsReq struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
promise chan *paychFundsRes
|
promise chan *paychFundsRes
|
||||||
amt types.BigInt
|
amt types.BigInt
|
||||||
opts getOpts
|
opts GetOpts
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
// merge parent, if this req is part of a merge
|
// merge parent, if this req is part of a merge
|
||||||
merge *mergedFundsReq
|
merge *mergedFundsReq
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFundsReq(ctx context.Context, amt types.BigInt, opts getOpts) *fundsReq {
|
func newFundsReq(ctx context.Context, amt types.BigInt, opts GetOpts) *fundsReq {
|
||||||
promise := make(chan *paychFundsRes, 1)
|
promise := make(chan *paychFundsRes, 1)
|
||||||
return &fundsReq{
|
return &fundsReq{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
@ -251,7 +251,7 @@ func (m *mergedFundsReq) failOffChainNoChannel(from, to address.Address) (*paych
|
|||||||
// address and the CID of the new add funds message.
|
// address and the CID of the new add funds message.
|
||||||
// If an operation returns an error, subsequent waiting operations will still
|
// If an operation returns an error, subsequent waiting operations will still
|
||||||
// be attempted.
|
// be attempted.
|
||||||
func (ca *channelAccessor) getPaych(ctx context.Context, amt types.BigInt, opts getOpts) (address.Address, cid.Cid, error) {
|
func (ca *channelAccessor) getPaych(ctx context.Context, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error) {
|
||||||
// Add the request to add funds to a queue and wait for the result
|
// Add the request to add funds to a queue and wait for the result
|
||||||
freq := newFundsReq(ctx, amt, opts)
|
freq := newFundsReq(ctx, amt, opts)
|
||||||
ca.enqueue(ctx, freq)
|
ca.enqueue(ctx, freq)
|
||||||
|
Loading…
Reference in New Issue
Block a user