From b36f2b2e66954a999ed06d067de6491599f805af Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Wed, 30 Aug 2023 12:36:44 -0700 Subject: [PATCH 1/8] Fix the mistakenly removed pritnVersionName Gradle task --- build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 0be9257caf..b10e6b4b96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -152,3 +152,7 @@ allprojects { } } } + +tasks.register("printVersionName") { + println(rootProject.version.toString()) +} \ No newline at end of file From d9e136a6bfb59f548e2bd2caa79d4f68825aca5a Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Wed, 30 Aug 2023 14:08:03 -0700 Subject: [PATCH 2/8] Increase version to 2.2.1 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b10e6b4b96..0f804f47e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -142,7 +142,7 @@ subprojects { allprojects { group = "org.stellar.anchor-sdk" - version = "2.2.0" + version = "2.2.1" tasks.jar { manifest { From 33160d8e07a29a875e17e05da214110cf32e0d5e Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Thu, 31 Aug 2023 10:02:00 -0700 Subject: [PATCH 3/8] Fixed README version --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index b7a9e3b4dd..d24b72b3a3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ [![License](https://badgen.net/badge/license/Apache%202/blue?icon=github&label=License)](https://github.com/stellar/java-stellar-anchor-sdk/blob/develop/LICENSE) [![GitHub Version](https://badgen.net/github/release/stellar/java-stellar-anchor-sdk?icon=github&label=Latest%20release)](https://github.com/stellar/java-stellar-anchor-sdk/releases) -[![Docker](https://badgen.net/badge/Latest%20Release/v2.2.0/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=release-2.2.0) +[![Docker](https://badgen.net/badge/Latest%20Release/v2.2.1/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=release-2.2.1) ![Develop Branch](https://github.com/stellar/java-stellar-anchor-sdk/actions/workflows/wk_push_to_develop.yml/badge.svg?branch=develop)
From a38e1c985c37dc502db17c916d8b3efe32d72e68 Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Thu, 31 Aug 2023 10:42:08 -0700 Subject: [PATCH 4/8] Fixed the dockerhub link --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index d24b72b3a3..7d3885aebe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ [![License](https://badgen.net/badge/license/Apache%202/blue?icon=github&label=License)](https://github.com/stellar/java-stellar-anchor-sdk/blob/develop/LICENSE) [![GitHub Version](https://badgen.net/github/release/stellar/java-stellar-anchor-sdk?icon=github&label=Latest%20release)](https://github.com/stellar/java-stellar-anchor-sdk/releases) -[![Docker](https://badgen.net/badge/Latest%20Release/v2.2.1/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=release-2.2.1) +[![Docker](https://badgen.net/badge/Latest%20Release/v2.2.1/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=2.2.1) ![Develop Branch](https://github.com/stellar/java-stellar-anchor-sdk/actions/workflows/wk_push_to_develop.yml/badge.svg?branch=develop)
From 9934a30bf979094535da0960db605ab392ade0d3 Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Tue, 5 Sep 2023 09:30:35 -0700 Subject: [PATCH 5/8] Add tear down process for the uncleared static mocks in SepServiceTest --- .../kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/test/kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt index da4a84a433..1609020941 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt @@ -2,11 +2,10 @@ package org.stellar.anchor.sep1 -import io.mockk.MockKAnnotations -import io.mockk.every +import io.mockk.* import io.mockk.impl.annotations.MockK -import io.mockk.mockkStatic import java.nio.file.Files +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -25,6 +24,12 @@ internal class Sep1ServiceTest { MockKAnnotations.init(this, relaxUnitFun = true) } + @AfterEach + fun tearDown() { + clearAllMocks() + unmockkAll() + } + @Test fun `disabled Sep1Service should return null string as toml value`() { every { sep1Config.isEnabled } returns false From 8463b4b604e6298f489814976c09eb4b6eeb1229 Mon Sep 17 00:00:00 2001 From: Jiahui Hu Date: Tue, 5 Sep 2023 14:34:17 -0400 Subject: [PATCH 6/8] [ANCHOR-413] Add jacoco test report to PR workflow (#1062) ### Description This is to add jacococ test report to PR workflow, to monitor test coverage change ### Testing After PR being published, there should be a github-action bot comment in your PR with test coverage. Please see https://github.com/stellar/java-stellar-anchor-sdk/pull/1081#issuecomment-1703260373 for example. Note that this PR is published from a branch on original repo instead of a forked repo. ### Known limitations 1. For now Github only grant apps write permission (which is needed to make comment) to original repo, and read permission to forked repo, that mean this action will only works on PR created from original repo. I have created a ticket https://stellarorg.atlassian.net/browse/ANCHOR-433 to follow up on this and try to find a work around for forked repo For more info about github permission please refer to https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token 2. Currently the min-coverage-overall is set to 40 and min-coverage-changed-files is 60, this is just for testing, will be changed accordingly. --------- Co-authored-by: Reece Markowsky Co-authored-by: Philip Liu <12836897+philipliu@users.noreply.github.com> --- .github/workflows/sub_gradle_test_and_build.yml | 17 ++++++++++++++++- build.gradle.kts | 11 +++++++++++ gradle/libs.versions.toml | 4 +++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sub_gradle_test_and_build.yml b/.github/workflows/sub_gradle_test_and_build.yml index 124e5af5d1..4cf50c035c 100644 --- a/.github/workflows/sub_gradle_test_and_build.yml +++ b/.github/workflows/sub_gradle_test_and_build.yml @@ -9,6 +9,10 @@ jobs: gradle_test_and_build: name: Gradle Test and Build runs-on: ubuntu-22.04 + # write to PR permission is required for jacocoTestReport Action to update comment + permissions: + contents: read + pull-requests: write steps: # Checkout the code - uses: actions/checkout@v3 @@ -51,7 +55,18 @@ jobs: - name: Gradle test and build. (unit tests, integration tests, end-2-end tests and build) env: run_docker: false - run: ./gradlew clean build --no-daemon --stacktrace -x spotlessApply -x spotlessKotlinApply -x javadoc -x javadocJar -x sourcesJar + run: ./gradlew clean build jacocoTestReport --no-daemon --stacktrace -x spotlessApply -x spotlessKotlinApply -x javadoc -x javadocJar -x sourcesJar + + - name: Add coverage to PR + id: jacoco + uses: madrapps/jacoco-report@v1.6.1 + with: + paths: ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 40 + min-coverage-changed-files: 60 + title: Code Coverage + update-comment: true - name: Stop docker containers env: diff --git a/build.gradle.kts b/build.gradle.kts index 0f804f47e6..f7f0b13177 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { java alias(libs.plugins.spotless) alias(libs.plugins.kotlin.jvm) apply false + jacoco } tasks { @@ -25,6 +26,7 @@ tasks { subprojects { apply(plugin = "java") apply(plugin = "com.diffplug.spotless") + apply(plugin = "jacoco") repositories { mavenLocal() @@ -62,6 +64,15 @@ subprojects { } kotlin { ktfmt("0.42").googleStyle() } + + tasks.jacocoTestReport { + dependsOn(tasks.test) // tests are required to run before generating the report + reports { + xml.required.set(true) + csv.required.set(false) + html.required.set(true) + } + } } dependencies { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2daa9db1a5..e1113ed4ed 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -61,6 +61,7 @@ toml4j = "0.7.2" spotless = "6.9.1" spring-boot = "2.7.9" spring-dependency-management = "1.1.0" +jacoco = "0.8.10" [libraries] abdera = { module = "org.apache.abdera:abdera-i18n", version.ref = "abdera" } @@ -158,4 +159,5 @@ spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "spring-dependency-management" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -ktor = { id = "io.ktor.plugin", version.ref = "ktor" } \ No newline at end of file +ktor = { id = "io.ktor.plugin", version.ref = "ktor" } +jacoco = { id = "jacoco", version.ref = "jacoco" } \ No newline at end of file From 6a63186bf8b0483fc11c39dcacb66a285ade2684 Mon Sep 17 00:00:00 2001 From: Jake Urban <10968980+JakeUrban@users.noreply.github.com> Date: Tue, 5 Sep 2023 15:45:14 -0700 Subject: [PATCH 7/8] ANCHOR-427: add status filter and use destination accounts for matching transactions in observer (#1090) --- build.gradle.kts | 2 +- .../data/JdbcSep24TransactionRepo.java | 3 +- .../data/JdbcSep24TransactionStore.java | 5 +- .../data/JdbcSep31TransactionRepo.java | 7 +- .../data/JdbcSep31TransactionStore.java | 5 +- .../PaymentOperationToEventListener.java | 6 +- .../PaymentOperationToEventListenerTest.kt | 100 ++++++++++++------ 7 files changed, 84 insertions(+), 44 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f7f0b13177..f2951ee700 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ subprojects { mavenLocal() mavenCentral() maven { url = uri("https://packages.confluent.io/maven") } - maven { url = uri("https://reposdeitory.mulesoft.org/nexus/content/repositories/public/") } + maven { url = uri("https://repository.mulesoft.org/nexus/content/repositories/public/") } maven { url = uri("https://jitpack.io") } } diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionRepo.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionRepo.java index c5a484161c..a03a8f88c9 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionRepo.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionRepo.java @@ -19,7 +19,8 @@ public interface JdbcSep24TransactionRepo JdbcSep24Transaction findOneByStellarTransactionId(String stellarTransactionId); - JdbcSep24Transaction findOneBySep10AccountAndMemo(String accountId, String memo); + JdbcSep24Transaction findOneByToAccountAndMemoAndStatus( + String toAccount, String memo, String status); List findBySep10AccountAndRequestAssetCodeOrderByStartedAtDesc( String stellarAccount, String assetCode); diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionStore.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionStore.java index 42a0de88b6..d7da0abca3 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionStore.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24TransactionStore.java @@ -53,9 +53,10 @@ public Sep24Transaction findByExternalTransactionId(String externalTransactionId return txnRepo.findOneByExternalTransactionId(externalTransactionId); } - public JdbcSep24Transaction findByStellarAccountIdAndMemo(String accountId, String memo) { + public JdbcSep24Transaction findOneByToAccountAndMemoAndStatus( + String toAccount, String memo, String status) { Optional optTxn = - Optional.ofNullable(txnRepo.findOneBySep10AccountAndMemo(accountId, memo)); + Optional.ofNullable(txnRepo.findOneByToAccountAndMemoAndStatus(toAccount, memo, status)); return optTxn.orElse(null); } diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionRepo.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionRepo.java index 60c4da9a5f..8bc674c24b 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionRepo.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionRepo.java @@ -24,7 +24,8 @@ public interface JdbcSep31TransactionRepo @Query(value = "SELECT COUNT(t) FROM JdbcSep31Transaction t WHERE t.status = :status") Integer findByStatusCount(@Param("status") String status); - Optional findByStellarAccountIdAndStellarMemo( - @Param("stellar_account_id") String stellarAccountId, - @Param("stellar_memo") String stellarMemo); + Optional findByStellarAccountIdAndStellarMemoAndStatus( + @Param("stellar_account_id") String accountId, + @Param("stellar_memo") String memo, + String status); } diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionStore.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionStore.java index 1bc190518c..7c03e75456 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionStore.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31TransactionStore.java @@ -71,9 +71,10 @@ public Sep31Transaction findByStellarAccountId(String accountId) { return optTxn.orElse(null); } - public JdbcSep31Transaction findByStellarAccountIdAndMemo(String accountId, String memo) { + public JdbcSep31Transaction findByStellarAccountIdAndMemoAndStatus( + String accountId, String memo, String status) { Optional optTxn = - transactionRepo.findByStellarAccountIdAndStellarMemo(accountId, memo); + transactionRepo.findByStellarAccountIdAndStellarMemoAndStatus(accountId, memo, status); return optTxn.orElse(null); } diff --git a/platform/src/main/java/org/stellar/anchor/platform/service/PaymentOperationToEventListener.java b/platform/src/main/java/org/stellar/anchor/platform/service/PaymentOperationToEventListener.java index 3a48ac3eff..a2b7250856 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/service/PaymentOperationToEventListener.java +++ b/platform/src/main/java/org/stellar/anchor/platform/service/PaymentOperationToEventListener.java @@ -78,7 +78,8 @@ public void onReceived(ObservedPayment payment) throws IOException { JdbcSep31Transaction sep31Txn = null; try { sep31Txn = - sep31TransactionStore.findByStellarAccountIdAndMemo(payment.getSourceAccount(), memo); + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + payment.getTo(), memo, SepTransactionStatus.PENDING_SENDER.toString()); } catch (Exception ex) { errorEx(ex); } @@ -97,7 +98,8 @@ public void onReceived(ObservedPayment payment) throws IOException { JdbcSep24Transaction sep24Txn; try { sep24Txn = - sep24TransactionStore.findByStellarAccountIdAndMemo(payment.getSourceAccount(), memo); + sep24TransactionStore.findOneByToAccountAndMemoAndStatus( + payment.getTo(), memo, SepTransactionStatus.PENDING_USR_TRANSFER_START.toString()); } catch (Exception ex) { errorEx(ex); return; diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt index d97eacdc32..352aeade90 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt @@ -83,36 +83,50 @@ class PaymentOperationToEventListenerTest { p.transactionMemo = "my_memo_2" p.assetType = "credit_alphanum4" p.sourceAccount = "GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5" + p.to = "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364" var slotMemo = slot() val slotAccount = slot() + val slotStatus = slot() every { - sep31TransactionStore.findByStellarAccountIdAndMemo(capture(slotAccount), capture(slotMemo)) + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + capture(slotAccount), + capture(slotMemo), + capture(slotStatus) + ) } returns null paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", - "my_memo_2" + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "my_memo_2", + "pending_sender" ) } assertEquals("my_memo_2", slotMemo.captured) - assertEquals("GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", slotAccount.captured) + assertEquals("GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", slotAccount.captured) + assertEquals("pending_sender", slotStatus.captured) - // If findByStellarAccountIdAndMemo throws an exception, we shouldn't trigger an event + // If findByStellarAccountIdAndMemoAndStatus throws an exception, we shouldn't trigger an event slotMemo = slot() p.transactionMemo = "my_memo_3" every { - sep31TransactionStore.findByStellarAccountIdAndMemo(capture(slotAccount), capture(slotMemo)) + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + capture(slotAccount), + capture(slotMemo), + capture(slotStatus) + ) } throws SepException("Something went wrong") paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", - "my_memo_3" + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "my_memo_3", + "pending_sender" ) } assertEquals("my_memo_3", slotMemo.captured) - assertEquals("GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", slotAccount.captured) + assertEquals("GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", slotAccount.captured) + assertEquals("pending_sender", slotStatus.captured) // If asset code from the fetched tx is different, don't trigger event slotMemo = slot() @@ -121,17 +135,23 @@ class PaymentOperationToEventListenerTest { val sep31TxMock = JdbcSep31Transaction() sep31TxMock.amountInAsset = "BAR" every { - sep31TransactionStore.findByStellarAccountIdAndMemo(capture(slotAccount), capture(slotMemo)) + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + capture(slotAccount), + capture(slotMemo), + capture(slotStatus) + ) } returns sep31TxMock paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", - "my_memo_4" + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "my_memo_4", + "pending_sender" ) } assertEquals("my_memo_4", slotMemo.captured) - assertEquals("GBT7YF22QEVUDUTBUIS2OWLTZMP7Z4J4ON6DCSHR3JXYTZRKCPXVV5J5", slotAccount.captured) + assertEquals("GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", slotAccount.captured) + assertEquals("pending_sender", slotStatus.captured) } @ParameterizedTest @@ -182,6 +202,7 @@ class PaymentOperationToEventListenerTest { val slotAccountId = slot() val slotMemo = slot() + val slotStatus = slot() val sep31TxMock = JdbcSep31Transaction() sep31TxMock.id = "ceaa7677-a5a7-434e-b02a-8e0801b3e7bd" sep31TxMock.amountExpected = "10" @@ -207,7 +228,11 @@ class PaymentOperationToEventListenerTest { val sep31TxCopy = gson.fromJson(gson.toJson(sep31TxMock), JdbcSep31Transaction::class.java) every { - sep31TransactionStore.findByStellarAccountIdAndMemo(capture(slotAccountId), capture(slotMemo)) + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + capture(slotAccountId), + capture(slotMemo), + capture(slotStatus) + ) } returns sep31TxCopy val patchTxnRequestSlot = slot() @@ -240,9 +265,10 @@ class PaymentOperationToEventListenerTest { paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GCJKWN7ELKOXLDHJTOU4TZOEJQL7TYVVTQFR676MPHHUIUDAHUA7QGJ4", - "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=" + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=", + "pending_sender" ) } @@ -290,6 +316,7 @@ class PaymentOperationToEventListenerTest { val receiverId = "137938d4-43a7-4252-a452-842adcee474c" val slotMemo = slot() + val slotStatus = slot() val sep31TxMock = JdbcSep31Transaction() sep31TxMock.id = "ceaa7677-a5a7-434e-b02a-8e0801b3e7bd" sep31TxMock.amountExpected = "10" @@ -315,9 +342,10 @@ class PaymentOperationToEventListenerTest { val sep31TxCopy = gson.fromJson(gson.toJson(sep31TxMock), JdbcSep31Transaction::class.java) every { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GCJKWN7ELKOXLDHJTOU4TZOEJQL7TYVVTQFR676MPHHUIUDAHUA7QGJ4", - capture(slotMemo) + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + capture(slotMemo), + capture(slotStatus) ) } returns sep31TxCopy @@ -353,9 +381,10 @@ class PaymentOperationToEventListenerTest { paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep31TransactionStore.findByStellarAccountIdAndMemo( - "GCJKWN7ELKOXLDHJTOU4TZOEJQL7TYVVTQFR676MPHHUIUDAHUA7QGJ4", - "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=" + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=", + "pending_sender" ) } @@ -409,6 +438,7 @@ class PaymentOperationToEventListenerTest { .build() val slotMemo = slot() + val slotStatus = slot() val sep24TxMock = JdbcSep24Transaction() sep24TxMock.id = "ceaa7677-a5a7-434e-b02a-8e0801b3e7bd" sep24TxMock.requestAssetCode = assetCode @@ -418,13 +448,16 @@ class PaymentOperationToEventListenerTest { sep24TxMock.memoType = "hash" // TODO: this shouldn't be necessary - every { sep31TransactionStore.findByStellarAccountIdAndMemo(any(), any()) } returns null + every { + sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus(any(), any(), any()) + } returns null val sep24TxnCopy = gson.fromJson(gson.toJson(sep24TxMock), JdbcSep24Transaction::class.java) every { - sep24TransactionStore.findByStellarAccountIdAndMemo( - "GCJKWN7ELKOXLDHJTOU4TZOEJQL7TYVVTQFR676MPHHUIUDAHUA7QGJ4", - capture(slotMemo) + sep24TransactionStore.findOneByToAccountAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + capture(slotMemo), + capture(slotStatus) ) } returns sep24TxnCopy @@ -458,9 +491,10 @@ class PaymentOperationToEventListenerTest { paymentOperationToEventListener.onReceived(p) verify(exactly = 1) { - sep24TransactionStore.findByStellarAccountIdAndMemo( - "GCJKWN7ELKOXLDHJTOU4TZOEJQL7TYVVTQFR676MPHHUIUDAHUA7QGJ4", - "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=" + sep24TransactionStore.findOneByToAccountAndMemoAndStatus( + "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", + "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=", + "pending_user_transfer_start" ) } From 4aa31aff206117a2dcaeba9c13cd9d576e2c0296 Mon Sep 17 00:00:00 2001 From: Gleb Date: Tue, 5 Sep 2023 16:58:38 -0700 Subject: [PATCH 8/8] [Anchor-428] Add refund memo to platform transaction (#1091) ### Description Add missing refund memo to the platform trasaction ### Context ### Testing ### Known limitations N/A --- .../anchor/api/platform/PlatformTransactionData.java | 6 ++++++ .../java/org/stellar/anchor/util/TransactionHelper.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java index 2b326976d2..b1cff97e3a 100644 --- a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java +++ b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java @@ -77,6 +77,12 @@ public class PlatformTransactionData { @SerializedName("memo_type") String memoType; + @SerializedName("refund_memo") + String refundMemo; + + @SerializedName("refund_memo_type") + String refundMemoType; + Customers customers; StellarId creator; diff --git a/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java b/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java index 9b22cc20dc..cec0baf088 100644 --- a/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java +++ b/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java @@ -81,6 +81,8 @@ public static GetTransactionResponse toGetTransactionResponse( .externalTransactionId(txn.getExternalTransactionId()) .memo(txn.getMemo()) .memoType(txn.getMemoType()) + .refundMemo(txn.getRefundMemo()) + .refundMemoType(txn.getRefundMemoType()) .build(); }