Skip to content
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

feat(backend): track if receiver is local #2862

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

BlairCurrey
Copy link
Contributor

@BlairCurrey BlairCurrey commented Aug 15, 2024

Changes proposed in this pull request

  • adds isLocal boolean to Receiver constructor

Context

This will be utilized to determine if we should use the local or ilp payment methods. I made this a separate PR since it's not dependent on any of the other changes and should help keep the other PR for that task (a bit) more manageable.

fixes #2853

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Documentation added
  • Make sure that all checks pass
  • Bruno collection updated

@github-actions github-actions bot added type: tests Testing related pkg: backend Changes in the backend package. type: source Changes business logic labels Aug 15, 2024
Copy link

netlify bot commented Aug 15, 2024

Deploy Preview for brilliant-pasca-3e80ec ready!

Name Link
🔨 Latest commit cf241ad
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/66bf7882e228ca00089c97db
😎 Deploy Preview https://deploy-preview-2862--brilliant-pasca-3e80ec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +151 to +171
try {
const localIncomingPayment = await getLocalIncomingPayment({
deps,
url
})
if (localIncomingPayment) {
return new Receiver(localIncomingPayment, true)
}

const remoteIncomingPayment = await getRemoteIncomingPayment(deps, url)
if (remoteIncomingPayment) {
return new Receiver(remoteIncomingPayment, false)
}
} catch (error) {
deps.logger.error(
{ errorMessage: error instanceof Error && error.message },
'Could not get incoming payment'
)
}

return undefined
Copy link
Contributor Author

@BlairCurrey BlairCurrey Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real change here in getReceiver is that we create the receiver with isLocal. The other changes in the receiverService.get are a little refactor in support of this. Just moves the attempt to get the local incoming payment into this main getReceiver function so I dont have to return more stuff from getIncomingPayment (now getRemoteIncomingPayment, since thats all it does).

@BlairCurrey BlairCurrey marked this pull request as ready for review August 15, 2024 15:57
@BlairCurrey BlairCurrey requested review from sabineschaller and removed request for koekiebox August 15, 2024 18:15
Copy link
Member

@sabineschaller sabineschaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. Makes code cleaner. Just a question regarding the tests. You updated them by always setting isLocal = false. Should we also test a true case?

@BlairCurrey
Copy link
Contributor Author

BlairCurrey commented Aug 16, 2024

Generally looks good. Makes code cleaner. Just a question regarding the tests. You updated them by always setting isLocal = false. Should we also test a true case?

@sabineschaller I changed the receiver model test to true for the sake of this (although it probably doesnt matter much - we're already asserting that its false when we set to false in constructor). There's really just not much to test here since we're only adding a new property and not controlling anything with it.

I dont want to change any of the other tests since everything up until this point was implicitly non-local. I think designating as local might not make sense there and could cause them to fail unexpectedly when we make isLocal control which method is used. I'll add tests for the new local payment method and controlling the payment method with isLocal when I make these changes in a subsequent PR. Those will be much more substantive.

@mkurapov mkurapov self-requested a review August 19, 2024 16:24
@BlairCurrey BlairCurrey merged commit b08a157 into main Aug 21, 2024
42 checks passed
@BlairCurrey BlairCurrey deleted the bc/2853/track-local-receiver branch August 21, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Be able to differentiate local vs remote receivers
3 participants