Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tíghearnán Carroll committed Apr 4, 2022
1 parent be5c977 commit 5b93356
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
19 changes: 6 additions & 13 deletions data/payd/payd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/libsv/dpp-proxy/data/payd"
"github.com/libsv/dpp-proxy/data/payd/models"
"github.com/libsv/dpp-proxy/mocks"
"github.com/libsv/go-bc/spv"
"github.com/libsv/go-bt/v2"
"github.com/libsv/go-bt/v2/bscript"
"github.com/libsv/go-dpp"
Expand All @@ -36,15 +35,13 @@ func TestPayd_PaymentCreate(t *testing.T) {
PaymentID: "qwe123",
},
req: dpp.Payment{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
},
expReq: models.PayDPaymentRequest{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
Expand All @@ -63,15 +60,13 @@ func TestPayd_PaymentCreate(t *testing.T) {
PaymentID: "qwe123",
},
req: dpp.Payment{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
},
expReq: models.PayDPaymentRequest{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
Expand All @@ -91,15 +86,13 @@ func TestPayd_PaymentCreate(t *testing.T) {
PaymentID: "qwe123",
},
req: dpp.Payment{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
},
expReq: models.PayDPaymentRequest{
RawTX: func() *string { s := "rawrawraw"; return &s }(),
Ancestors: &spv.Envelope{},
RawTx: func() *string { s := "rawrawraw"; return &s }(),
ProofCallbacks: map[string]dpp.ProofCallback{
"abc.com": {Token: "mYtOkEn"},
},
Expand Down
24 changes: 11 additions & 13 deletions service/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service_test

import (
"context"
"encoding/hex"
"errors"
"testing"

Expand All @@ -25,10 +26,13 @@ func TestPayment_Create(t *testing.T) {
return &dpp.PaymentACK{}, nil
},
req: dpp.Payment{
Ancestors: &spv.Envelope{
RawTx: "01000000000000000000",
TxID: "d21633ba23f70118185227be58a63527675641ad37967e2aa461559f577aec43",
},
Ancestry: func() *string {
s := &spv.Envelope{}
bb, _ := s.Bytes()
ss := hex.EncodeToString(bb)
return &ss
}(),
RawTx: func() *string { s := "01000000000000000000"; return &s }(),
MerchantData: dpp.Merchant{
ExtendedData: map[string]interface{}{"paymentReference": "omgwow"},
},
Expand All @@ -43,10 +47,7 @@ func TestPayment_Create(t *testing.T) {
},
args: dpp.PaymentCreateArgs{},
req: dpp.Payment{
Ancestors: &spv.Envelope{
RawTx: "01000000000000000000",
TxID: "d21633ba23f70118185227be58a63527675641ad37967e2aa461559f577aec43",
},
RawTx: func() *string { s := "01000000000000000000"; return &s }(),
MerchantData: dpp.Merchant{
ExtendedData: map[string]interface{}{"paymentReference": "omgwow"},
},
Expand All @@ -65,7 +66,7 @@ func TestPayment_Create(t *testing.T) {
ExtendedData: map[string]interface{}{"paymentReference": "omgwow"},
},
},
expErr: errors.New("[ancestors/rawTx: either ancestors or a rawTX are required]"),
expErr: errors.New("[ancestry/rawTx: either ancestry or a rawTX are required]"),
},
"error on payment create is handled": {
paymentCreateFn: func(context.Context, dpp.PaymentCreateArgs, dpp.Payment) (*dpp.PaymentACK, error) {
Expand All @@ -75,10 +76,7 @@ func TestPayment_Create(t *testing.T) {
PaymentID: "abc123",
},
req: dpp.Payment{
Ancestors: &spv.Envelope{
RawTx: "01000000000000000000",
TxID: "d21633ba23f70118185227be58a63527675641ad37967e2aa461559f577aec43",
},
RawTx: func() *string { s := "01000000000000000000"; return &s }(),
MerchantData: dpp.Merchant{
ExtendedData: map[string]interface{}{"paymentReference": "omgwow"},
},
Expand Down

0 comments on commit 5b93356

Please sign in to comment.