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

[ANCHOR-464] SEP-6: Enable client status callback #1126

Merged

Conversation

philipliu
Copy link
Contributor

@philipliu philipliu commented Sep 26, 2023

Description

This enables client status callback for SEP-6.

Context

Status callback should be supported by the SEP-6 implement.

Testing

./gradlew test

Known limitations

The SEP-24 end-to-end was previously not asserting on the wallet status callbacks. This was caused by the signature verification failing in the wallet reference server, causing the GET /callback to always return null. The test previously only asserted when the result was not null. These tests have been disabled in this PR due to flakiness but will be re-enabled again when develop is merged in.

@philipliu philipliu force-pushed the feature/anchor-464-sep-6-status-callback branch 3 times, most recently from 7907ffc to d62052f Compare September 26, 2023 23:50
@philipliu philipliu force-pushed the feature/anchor-464-sep-6-status-callback branch from d62052f to 8d8e7a9 Compare September 26, 2023 23:52
@philipliu philipliu marked this pull request as ready for review September 27, 2023 00:12
* @param txn the SEP-6 database transaction object
* @return the SEP-6 API transaction object
*/
public static org.stellar.anchor.api.sep.sep6.Sep6Transaction fromTxn(Sep6Transaction txn) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public static org.stellar.anchor.api.sep.sep6.Sep6Transaction fromTxn(Sep6Transaction txn) {
public static Sep6Transaction fromTxn(Sep6Transaction txn) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, we have two classes with the same name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need org.stellar.anchor.api.sep.sep6.Sep6Transaction?

That pattern does not seem to exist for Sep24 and Sep31.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it's because SEP-24/31 call the platform transaction class something else. https://github.com/stellar/java-stellar-anchor-sdk/blob/625e469bb7c55ffa77d7cf0906b1b926da967fa0/core/src/main/java/org/stellar/anchor/sep24/Sep24Helper.java#L81.

I will rename the class too.

}
val actualCallbacks =
walletServerClient.pollCallbacks(response.id, 4).map {
gson.fromJson(it, Sep24GetTransactionResponse::class.java)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some comments of why removing assertEquals(4, it.size) would fix the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't fix the problem. The assertion was required before because waitForWalletServerCallbacks returned a null if the response size is not 4. I changed the API of waitForWalletServerCallbacks / pollCallbacks so that it will always return a list, so the assertion can be removed.

@@ -11,7 +11,6 @@ import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.delay
Copy link
Collaborator

Choose a reason for hiding this comment

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

💡 Can we separate the fix to a different PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to add tests for SEP-6 client status callbacks which ended up requiring touching the SEP-24 tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes will be thrown away once I merge in develop, anyway. I've only modified these tests so the CI passes.

var retries = 5
var callbacks: List<String> = listOf()
while (retries > 0) {
// TODO: remove when callbacks are de-duped
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where and when the callbacks should be de-duped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure.... Apparently this was fixed in the develop branch. When I pull that in, I'll remove this TODO and see if everything works.

Copy link
Collaborator

@lijamie98 lijamie98 left a comment

Choose a reason for hiding this comment

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

LGTM

@philipliu philipliu merged commit ae24110 into stellar:sep-6 Oct 3, 2023
@philipliu philipliu deleted the feature/anchor-464-sep-6-status-callback branch October 3, 2023 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants