Fixed billing fees unreachable error propagation. Added USDT ledger creation. Fixed ledger boundaries operation types
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
accountrolev1 "github.com/tech/sendico/pkg/proto/common/account_role/v1"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
connectorv1 "github.com/tech/sendico/pkg/proto/connector/v1"
|
||||
ledgerv1 "github.com/tech/sendico/pkg/proto/ledger/v1"
|
||||
@@ -92,3 +94,65 @@ func TestTransferInternal_SubmitsTransferOperation(t *testing.T) {
|
||||
assert.Equal(t, "op-1", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_TRANSFER, resp.GetEntryType())
|
||||
}
|
||||
|
||||
func TestPostExternalCreditWithCharges_SubmitsExternalOperation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
var captured *connectorv1.Operation
|
||||
stub := &stubConnector{
|
||||
submitFn: func(ctx context.Context, req *connectorv1.SubmitOperationRequest) (*connectorv1.SubmitOperationResponse, error) {
|
||||
captured = req.GetOperation()
|
||||
return &connectorv1.SubmitOperationResponse{Receipt: &connectorv1.OperationReceipt{OperationId: "op-ext-credit"}}, nil
|
||||
},
|
||||
}
|
||||
|
||||
client := NewWithClient(Config{}, stub)
|
||||
resp, err := client.PostExternalCreditWithCharges(ctx, &ledgerv1.PostCreditRequest{
|
||||
IdempotencyKey: "id-ext-credit",
|
||||
OrganizationRef: "org-1",
|
||||
Money: &moneyv1.Money{Currency: "USDT", Amount: "1.0"},
|
||||
Role: ledgerv1.AccountRole_ACCOUNT_ROLE_OPERATING,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
require.NotNil(t, captured)
|
||||
|
||||
assert.Equal(t, connectorv1.OperationType_CREDIT, captured.GetType())
|
||||
assert.Equal(t, "", captured.GetTo().GetAccount().GetAccountId())
|
||||
assert.Equal(t, accountrolev1.AccountRole_OPERATING, captured.GetToRole())
|
||||
assert.Equal(t, discovery.OperationExternalCredit, captured.GetParams().AsMap()["operation"])
|
||||
assert.Equal(t, "op-ext-credit", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_CREDIT, resp.GetEntryType())
|
||||
}
|
||||
|
||||
func TestPostExternalDebitWithCharges_SubmitsExternalOperation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
var captured *connectorv1.Operation
|
||||
stub := &stubConnector{
|
||||
submitFn: func(ctx context.Context, req *connectorv1.SubmitOperationRequest) (*connectorv1.SubmitOperationResponse, error) {
|
||||
captured = req.GetOperation()
|
||||
return &connectorv1.SubmitOperationResponse{Receipt: &connectorv1.OperationReceipt{OperationId: "op-ext-debit"}}, nil
|
||||
},
|
||||
}
|
||||
|
||||
client := NewWithClient(Config{}, stub)
|
||||
resp, err := client.PostExternalDebitWithCharges(ctx, &ledgerv1.PostDebitRequest{
|
||||
IdempotencyKey: "id-ext-debit",
|
||||
OrganizationRef: "org-1",
|
||||
Money: &moneyv1.Money{Currency: "RUB", Amount: "77.14"},
|
||||
Role: ledgerv1.AccountRole_ACCOUNT_ROLE_HOLD,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
require.NotNil(t, captured)
|
||||
|
||||
assert.Equal(t, connectorv1.OperationType_DEBIT, captured.GetType())
|
||||
assert.Equal(t, "", captured.GetFrom().GetAccount().GetAccountId())
|
||||
assert.Equal(t, accountrolev1.AccountRole_HOLD, captured.GetFromRole())
|
||||
assert.Equal(t, discovery.OperationExternalDebit, captured.GetParams().AsMap()["operation"])
|
||||
assert.Equal(t, "op-ext-debit", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_DEBIT, resp.GetEntryType())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user