Use MpoolPushMessage
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
46b7546d51
commit
dc35f2f40c
@ -125,7 +125,7 @@ func TestPaymentChannels(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res = waitForMessage(ctx, t, paymentCreator, settleMsgCid, time.Second, "settle")
|
res = waitForMessage(ctx, t, paymentCreator, settleMsgCid, time.Second*10, "settle")
|
||||||
if res.Receipt.ExitCode != 0 {
|
if res.Receipt.ExitCode != 0 {
|
||||||
t.Fatal("Unable to settle payment channel")
|
t.Fatal("Unable to settle payment channel")
|
||||||
}
|
}
|
||||||
|
@ -114,32 +114,18 @@ func (a *PaychAPI) PaychSettle(ctx context.Context, addr address.Address) (cid.C
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, err := a.MpoolGetNonce(ctx, ci.Control)
|
|
||||||
if err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: addr,
|
To: addr,
|
||||||
From: ci.Control,
|
From: ci.Control,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
Method: builtin.MethodsPaych.Settle,
|
Method: builtin.MethodsPaych.Settle,
|
||||||
Nonce: nonce,
|
|
||||||
|
|
||||||
GasLimit: 0,
|
|
||||||
GasPrice: types.NewInt(0),
|
|
||||||
}
|
}
|
||||||
|
smgs, err := a.MpoolPushMessage(ctx, msg)
|
||||||
|
|
||||||
smsg, err := a.WalletSignMessage(ctx, ci.Control, msg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
return smgs.Cid(), nil
|
||||||
if _, err := a.MpoolPush(ctx, smsg); err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return smsg.Cid(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) {
|
func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) {
|
||||||
@ -149,31 +135,18 @@ func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid.
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, err := a.MpoolGetNonce(ctx, ci.Control)
|
|
||||||
if err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: addr,
|
To: addr,
|
||||||
From: ci.Control,
|
From: ci.Control,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
Method: builtin.MethodsPaych.Collect,
|
Method: builtin.MethodsPaych.Collect,
|
||||||
Nonce: nonce,
|
|
||||||
|
|
||||||
GasLimit: 0,
|
|
||||||
GasPrice: types.NewInt(0),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
smsg, err := a.WalletSignMessage(ctx, ci.Control, msg)
|
smsg, err := a.MpoolPushMessage(ctx, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := a.MpoolPush(ctx, smsg); err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return smsg.Cid(), nil
|
return smsg.Cid(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,11 +226,6 @@ func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, s
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, err := a.MpoolGetNonce(ctx, ci.Control)
|
|
||||||
if err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if sv.Extra != nil || len(sv.SecretPreimage) > 0 {
|
if sv.Extra != nil || len(sv.SecretPreimage) > 0 {
|
||||||
return cid.Undef, fmt.Errorf("cant handle more advanced payment channel stuff yet")
|
return cid.Undef, fmt.Errorf("cant handle more advanced payment channel stuff yet")
|
||||||
}
|
}
|
||||||
@ -270,25 +238,17 @@ func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
From: ci.Control,
|
From: ci.Control,
|
||||||
To: ch,
|
To: ch,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
Nonce: nonce,
|
Method: builtin.MethodsPaych.UpdateChannelState,
|
||||||
Method: builtin.MethodsPaych.UpdateChannelState,
|
Params: enc,
|
||||||
Params: enc,
|
|
||||||
GasLimit: 0,
|
|
||||||
GasPrice: types.NewInt(0),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
smsg, err := a.WalletSignMessage(ctx, ci.Control, msg)
|
smsg, err := a.MpoolPushMessage(ctx, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := a.MpoolPush(ctx, smsg); err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: should we wait for it...?
|
|
||||||
return smsg.Cid(), nil
|
return smsg.Cid(), nil
|
||||||
}
|
}
|
||||||
|
@ -552,6 +552,7 @@ func TestPaymentChannels(t *testing.T) {
|
|||||||
logging.SetLogLevel("chainstore", "ERROR")
|
logging.SetLogLevel("chainstore", "ERROR")
|
||||||
logging.SetLogLevel("chain", "ERROR")
|
logging.SetLogLevel("chain", "ERROR")
|
||||||
logging.SetLogLevel("sub", "ERROR")
|
logging.SetLogLevel("sub", "ERROR")
|
||||||
|
logging.SetLogLevel("pubsub", "ERROR")
|
||||||
logging.SetLogLevel("storageminer", "ERROR")
|
logging.SetLogLevel("storageminer", "ERROR")
|
||||||
|
|
||||||
test.TestPaymentChannels(t, mockSbBuilder, 5*time.Millisecond)
|
test.TestPaymentChannels(t, mockSbBuilder, 5*time.Millisecond)
|
||||||
|
Loading…
Reference in New Issue
Block a user