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)
|
||||
channelInfo, err := paymentCreator.PaychGet(ctx, createrAddr, receiverAddr, abi.NewTokenAmount(channelAmt), api.PaychGetOpts{
|
||||
Reserve: true,
|
||||
OffChain: false,
|
||||
})
|
||||
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) {
|
||||
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 {
|
||||
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) {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -101,17 +101,12 @@ func (pm *Manager) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type getOpts struct {
|
||||
type GetOpts struct {
|
||||
Reserve 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) {
|
||||
opts := getOpts{
|
||||
Reserve: reserve,
|
||||
OffChain: o.OffChain,
|
||||
}
|
||||
|
||||
func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error) {
|
||||
if !opts.Reserve && opts.OffChain {
|
||||
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"
|
||||
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"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||
paychmock "github.com/filecoin-project/lotus/chain/actors/builtin/paych/mock"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var onChainReserve = api.PaychGetOpts{
|
||||
var onChainReserve = GetOpts{
|
||||
Reserve: true,
|
||||
OffChain: false,
|
||||
}
|
||||
var onChainNoReserve = api.PaychGetOpts{
|
||||
var onChainNoReserve = GetOpts{
|
||||
Reserve: false,
|
||||
OffChain: false,
|
||||
}
|
||||
var offChainReserve = api.PaychGetOpts{
|
||||
var offChainReserve = GetOpts{
|
||||
Reserve: true,
|
||||
OffChain: true,
|
||||
}
|
||||
var offChainNoReserve = api.PaychGetOpts{
|
||||
var offChainNoReserve = GetOpts{
|
||||
Reserve: false,
|
||||
OffChain: true,
|
||||
}
|
||||
|
@ -33,14 +33,14 @@ type fundsReq struct {
|
||||
ctx context.Context
|
||||
promise chan *paychFundsRes
|
||||
amt types.BigInt
|
||||
opts getOpts
|
||||
opts GetOpts
|
||||
|
||||
lk sync.Mutex
|
||||
// merge parent, if this req is part of a merge
|
||||
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)
|
||||
return &fundsReq{
|
||||
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.
|
||||
// If an operation returns an error, subsequent waiting operations will still
|
||||
// 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
|
||||
freq := newFundsReq(ctx, amt, opts)
|
||||
ca.enqueue(ctx, freq)
|
||||
|
Loading…
Reference in New Issue
Block a user