-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
663/mk/create outgoing payment #807
Conversation
@@ -419,10 +419,10 @@ async function addSentAmount( | |||
): Promise<OutgoingPayment> { | |||
const fundingZeroOrUndefined = | |||
payment.state === OutgoingPaymentState.Funding ? BigInt(0) : undefined | |||
let sent = value || (await deps.accountingService.getTotalSent(payment.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a guess about the desired behaviour
the main issue here was using ||
instead of ??
. When we call this function just above:
return await addSentAmount(deps, payment, BigInt(0)) |
we pass in value: BigInt(0)
. BigInt(0)
is falsy, so we end up calling deps.accountingService.getTotalSent(payment.id))
even though we actually just wanted to set sent
to be 0.
} | ||
} | ||
|
||
export const createOutgoingPayment = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the only other validation I could think of doing on a newly created outgoing payment (that wasn't already covered in validateOutgoingPayment
) was checking whether sentAmount.value === 0
. Feels like a weird behaviour to already start processing a payment before returning it, but does the caller care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that does somehow seem less concerning than a non-zero receivedAmount
on a new incoming payment.
headers: accessToken | ||
? { | ||
Authorization: `GNAP ${accessToken}` | ||
} | ||
: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was missing previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The properly POSTs request
test is failing with the addition of headers: {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, saw that, fixing.
@@ -91,6 +91,8 @@ export const mockOutgoingPayment = ( | |||
}, | |||
quoteId: uuid(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quoteId
and id
are supposed to be uri
s
https://github.com/interledger/open-payments/blob/02a6d505d79124cce776054df89e28f02c8e5d59/openapi/resource-server.yaml#L1072-L1084
Am I correct that we shouldn't be concerned about the quality of our OpenAPI validation because this package is only testing against successfulValidator
/failedValidator
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll make the test case a bit more realistic. But yes, in general, IMO the actual OpenAPI spec validation is a bit out of scope of the package, that responsibility is openapi
s
headers: accessToken | ||
? { | ||
Authorization: `GNAP ${accessToken}` | ||
} | ||
: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The properly POSTs request
test is failing with the addition of headers: {}
} | ||
} | ||
|
||
export const createOutgoingPayment = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that does somehow seem less concerning than a non-zero receivedAmount
on a new incoming payment.
Changes proposed in this pull request
outgoingPayment.create
to open payments clientContext
Checklist
fixes #number