From 2c23fcdbbf2909b448745acd4901de63ff8db43e Mon Sep 17 00:00:00 2001 From: Gleb Date: Tue, 7 May 2024 09:02:03 -0700 Subject: [PATCH 1/5] Add withdrawal support for notify_refund_pending RPC method --- .../method/NotifyRefundPendingRequest.java | 2 +- .../stellar/anchor/api/shared/Refunds.java | 7 +- .../stellar/anchor/api/shared/SepRefunds.java | 5 + .../stellar/anchor/sep24/Sep24Refunds.java | 3 +- .../platform/data/JdbcSep24Refunds.java | 5 + .../rpc/NotifyRefundPendingHandler.java | 161 ++++++++-------- .../anchor/platform/rpc/RpcMethodHandler.java | 5 + .../rpc/NotifyRefundPendingHandlerTest.kt | 182 ++++++++++++++++++ 8 files changed, 292 insertions(+), 78 deletions(-) create mode 100644 api-schema/src/main/java/org/stellar/anchor/api/shared/SepRefunds.java diff --git a/api-schema/src/main/java/org/stellar/anchor/api/rpc/method/NotifyRefundPendingRequest.java b/api-schema/src/main/java/org/stellar/anchor/api/rpc/method/NotifyRefundPendingRequest.java index dc0a5b45e8..b5437c09a8 100644 --- a/api-schema/src/main/java/org/stellar/anchor/api/rpc/method/NotifyRefundPendingRequest.java +++ b/api-schema/src/main/java/org/stellar/anchor/api/rpc/method/NotifyRefundPendingRequest.java @@ -14,7 +14,7 @@ @EqualsAndHashCode(callSuper = false) public class NotifyRefundPendingRequest extends RpcMethodParamsRequest { - @NotNull private Refund refund; + private Refund refund; @Data @Builder diff --git a/api-schema/src/main/java/org/stellar/anchor/api/shared/Refunds.java b/api-schema/src/main/java/org/stellar/anchor/api/shared/Refunds.java index d8db67a1f2..acdc37fc09 100644 --- a/api-schema/src/main/java/org/stellar/anchor/api/shared/Refunds.java +++ b/api-schema/src/main/java/org/stellar/anchor/api/shared/Refunds.java @@ -9,7 +9,7 @@ @Data @Builder @AllArgsConstructor -public class Refunds { +public class Refunds implements SepRefunds { @JsonProperty("amount_refunded") @SerializedName("amount_refunded") @@ -22,4 +22,9 @@ public class Refunds { RefundPayment[] payments; public Refunds() {} + + @Override + public boolean hasRefundPayments() { + return payments != null; + } } diff --git a/api-schema/src/main/java/org/stellar/anchor/api/shared/SepRefunds.java b/api-schema/src/main/java/org/stellar/anchor/api/shared/SepRefunds.java new file mode 100644 index 0000000000..b3efe12cc8 --- /dev/null +++ b/api-schema/src/main/java/org/stellar/anchor/api/shared/SepRefunds.java @@ -0,0 +1,5 @@ +package org.stellar.anchor.api.shared; + +public interface SepRefunds { + boolean hasRefundPayments(); +} diff --git a/core/src/main/java/org/stellar/anchor/sep24/Sep24Refunds.java b/core/src/main/java/org/stellar/anchor/sep24/Sep24Refunds.java index 4bd0da66ce..59263ab38a 100644 --- a/core/src/main/java/org/stellar/anchor/sep24/Sep24Refunds.java +++ b/core/src/main/java/org/stellar/anchor/sep24/Sep24Refunds.java @@ -12,9 +12,10 @@ import java.util.stream.Collectors; import org.stellar.anchor.api.sep.AssetInfo; import org.stellar.anchor.api.shared.Refunds; +import org.stellar.anchor.api.shared.SepRefunds; @SuppressWarnings("unused") -public interface Sep24Refunds { +public interface Sep24Refunds extends SepRefunds { String getAmountRefunded(); void setAmountRefunded(String amountRefunded); diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Refunds.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Refunds.java index 65fa749657..8ed7adfde7 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Refunds.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Refunds.java @@ -41,4 +41,9 @@ public void setRefundPayments(List refundPayments) { String.format("Error casting %s to JdbcSep24RefundPayment", rp.getClass())); } } + + @Override + public boolean hasRefundPayments() { + return payments != null; + } } diff --git a/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java b/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java index fe92bbd7dc..a8e58182c5 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java +++ b/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java @@ -1,13 +1,11 @@ package org.stellar.anchor.platform.rpc; import static java.util.Collections.emptySet; -import static org.stellar.anchor.api.platform.PlatformTransactionData.Kind.DEPOSIT; -import static org.stellar.anchor.api.platform.PlatformTransactionData.Kind.DEPOSIT_EXCHANGE; +import static org.stellar.anchor.api.platform.PlatformTransactionData.Kind.*; import static org.stellar.anchor.api.platform.PlatformTransactionData.Sep.SEP_24; import static org.stellar.anchor.api.platform.PlatformTransactionData.Sep.SEP_6; import static org.stellar.anchor.api.rpc.method.RpcMethod.NOTIFY_REFUND_PENDING; -import static org.stellar.anchor.api.sep.SepTransactionStatus.PENDING_ANCHOR; -import static org.stellar.anchor.api.sep.SepTransactionStatus.PENDING_EXTERNAL; +import static org.stellar.anchor.api.sep.SepTransactionStatus.*; import static org.stellar.anchor.util.AssetHelper.getAssetCode; import static org.stellar.anchor.util.MathHelper.*; @@ -31,6 +29,7 @@ import org.stellar.anchor.api.shared.Amount; import org.stellar.anchor.api.shared.RefundPayment; import org.stellar.anchor.api.shared.Refunds; +import org.stellar.anchor.api.shared.SepRefunds; import org.stellar.anchor.asset.AssetService; import org.stellar.anchor.event.EventService; import org.stellar.anchor.metrics.MetricsService; @@ -69,29 +68,72 @@ protected void validate(JdbcSepTransaction txn, NotifyRefundPendingRequest reque throws InvalidParamsException, InvalidRequestException, BadRequestException { super.validate(txn, request); - AssetValidationUtils.validateAsset( - "refund.amount", - AmountAssetRequest.builder() - .amount(request.getRefund().getAmount().getAmount()) - .asset(txn.getAmountInAsset()) - .build(), - assetService); - AssetValidationUtils.validateAsset( - "refund.amountFee", - AmountAssetRequest.builder() - .amount(request.getRefund().getAmountFee().getAmount()) - .asset(txn.getAmountInAsset()) - .build(), - true, - assetService); - - if (!txn.getAmountInAsset().equals(request.getRefund().getAmount().getAsset())) { - throw new InvalidParamsException( - "refund.amount.asset does not match transaction amount_in_asset"); + Sep sep = Sep.from(txn.getProtocol()); + SepRefunds refunds; + PlatformTransactionData.Kind kind; + if (sep == SEP_6) { + kind = Kind.from(((JdbcSep6Transaction) txn).getKind()); + refunds = ((JdbcSep6Transaction) txn).getRefunds(); + } else if (sep == SEP_24) { + kind = Kind.from(((JdbcSep24Transaction) txn).getKind()); + refunds = ((JdbcSep24Transaction) txn).getRefunds(); + } else { + throw new InvalidRequestException( + String.format( + "RPC method[%s] is not supported for protocol[%s]", + getRpcMethod(), txn.getProtocol())); } - if (!txn.getAmountFeeAsset().equals(request.getRefund().getAmountFee().getAsset())) { - throw new InvalidParamsException( - "refund.amount_fee.asset does not match match transaction amount_fee_asset"); + + if (ImmutableSet.of(DEPOSIT, DEPOSIT_EXCHANGE).contains(kind)) { + if (request.getRefund() == null) { + throw new InvalidParamsException("refund must not be null"); + } + + AssetValidationUtils.validateAsset( + "refund.amount", + AmountAssetRequest.builder() + .amount(request.getRefund().getAmount().getAmount()) + .asset(txn.getAmountInAsset()) + .build(), + assetService); + AssetValidationUtils.validateAsset( + "refund.amountFee", + AmountAssetRequest.builder() + .amount(request.getRefund().getAmountFee().getAmount()) + .asset(txn.getAmountInAsset()) + .build(), + true, + assetService); + + if (!txn.getAmountInAsset().equals(request.getRefund().getAmount().getAsset())) { + throw new InvalidParamsException( + "refund.amount.asset does not match transaction amount_in_asset"); + } + if (!txn.getAmountFeeAsset().equals(request.getRefund().getAmountFee().getAsset())) { + throw new InvalidParamsException( + "refund.amount_fee.asset does not match match transaction amount_fee_asset"); + } + + AssetInfo assetInfo = assetService.getAsset(getAssetCode(txn.getAmountInAsset())); + + var amount = request.getRefund().getAmount().getAmount(); + var amountFee = request.getRefund().getAmountFee().getAmount(); + + BigDecimal totalRefunded; + if (refunds == null || !refunds.hasRefundPayments()) { + totalRefunded = sum(assetInfo, amount, amountFee); + } else { + var amountRefunded = + refunds instanceof Refunds + ? ((Refunds) refunds).getAmountRefunded().getAmount() + : ((Sep24Refunds) refunds).getAmountRefunded(); + totalRefunded = sum(assetInfo, amountRefunded, amount, amountFee); + } + + BigDecimal amountIn = decimal(txn.getAmountIn(), assetInfo); + if (totalRefunded.compareTo(amountIn) > 0) { + throw new InvalidParamsException("Refund amount exceeds amount_in"); + } } } @@ -104,56 +146,16 @@ public RpcMethod getRpcMethod() { protected SepTransactionStatus getNextStatus( JdbcSepTransaction txn, NotifyRefundPendingRequest request) throws InvalidParamsException, InvalidRequestException { - String amount; - String amountFee; - switch (PlatformTransactionData.Sep.from(txn.getProtocol())) { - case SEP_6: - JdbcSep6Transaction txn6 = (JdbcSep6Transaction) txn; - AssetInfo assetInfo6 = assetService.getAsset(getAssetCode(txn.getAmountInAsset())); + var kind = + txn instanceof JdbcSep6Transaction + ? Kind.from(((JdbcSep6Transaction) txn).getKind()) + : Kind.from(((JdbcSep24Transaction) txn).getKind()); - Refunds refunds = txn6.getRefunds(); - amount = request.getRefund().getAmount().getAmount(); - amountFee = request.getRefund().getAmountFee().getAmount(); - - BigDecimal totalRefunded6; - if (refunds == null || refunds.getPayments() == null) { - totalRefunded6 = sum(assetInfo6, amount, amountFee); - } else { - totalRefunded6 = - sum(assetInfo6, refunds.getAmountRefunded().getAmount(), amount, amountFee); - } - - BigDecimal amountIn6 = decimal(txn.getAmountIn(), assetInfo6); - if (totalRefunded6.compareTo(amountIn6) > 0) { - throw new InvalidParamsException("Refund amount exceeds amount_in"); - } - - return PENDING_EXTERNAL; - case SEP_24: - JdbcSep24Transaction txn24 = (JdbcSep24Transaction) txn; - AssetInfo assetInfo = assetService.getAsset(getAssetCode(txn.getAmountInAsset())); - - Sep24Refunds sep24Refunds = txn24.getRefunds(); - amount = request.getRefund().getAmount().getAmount(); - amountFee = request.getRefund().getAmountFee().getAmount(); - - BigDecimal totalRefunded; - if (sep24Refunds == null || sep24Refunds.getRefundPayments() == null) { - totalRefunded = sum(assetInfo, amount, amountFee); - } else { - totalRefunded = sum(assetInfo, sep24Refunds.getAmountRefunded(), amount, amountFee); - } - - BigDecimal amountIn = decimal(txn.getAmountIn(), assetInfo); - if (totalRefunded.compareTo(amountIn) > 0) { - throw new InvalidParamsException("Refund amount exceeds amount_in"); - } - - return PENDING_EXTERNAL; + if (ImmutableSet.of(WITHDRAWAL, WITHDRAWAL_EXCHANGE).contains(kind)) { + return PENDING_ANCHOR; } - throw new InvalidRequestException( - String.format( - "RPC method[%s] is not supported for protocol[%s]", getRpcMethod(), txn.getProtocol())); + + return PENDING_EXTERNAL; } @Override @@ -163,7 +165,7 @@ protected Set getSupportedStatuses(JdbcSepTransaction txn) if (ImmutableSet.of(DEPOSIT, DEPOSIT_EXCHANGE).contains(Kind.from(txn6.getKind()))) { return Set.of(PENDING_ANCHOR); } - return emptySet(); + return Set.of(PENDING_USR_TRANSFER_COMPLETE, PENDING_EXTERNAL); } if (SEP_24 == Sep.from(txn.getProtocol())) { @@ -171,6 +173,7 @@ protected Set getSupportedStatuses(JdbcSepTransaction txn) if (DEPOSIT == Kind.from(txn24.getKind())) { return Set.of(PENDING_ANCHOR); } + return Set.of(PENDING_USR_TRANSFER_COMPLETE, PENDING_EXTERNAL); } return emptySet(); } @@ -185,6 +188,10 @@ protected void updateTransactionWithRpcRequest( case SEP_6: JdbcSep6Transaction txn6 = (JdbcSep6Transaction) txn; + if (ImmutableSet.of(WITHDRAWAL, WITHDRAWAL_EXCHANGE).contains(Kind.from(txn6.getKind()))) { + return; + } + RefundPayment requestPayment = RefundPayment.builder() .id(requestRefund.getId()) @@ -243,6 +250,10 @@ protected void updateTransactionWithRpcRequest( case SEP_24: JdbcSep24Transaction txn24 = (JdbcSep24Transaction) txn; + if (WITHDRAWAL == Kind.from(txn24.getKind())) { + return; + } + Sep24RefundPayment refundPayment = JdbcSep24RefundPayment.builder() .id(requestRefund.getId()) diff --git a/platform/src/main/java/org/stellar/anchor/platform/rpc/RpcMethodHandler.java b/platform/src/main/java/org/stellar/anchor/platform/rpc/RpcMethodHandler.java index 02a25e50f2..84cbb81ae6 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/rpc/RpcMethodHandler.java +++ b/platform/src/main/java/org/stellar/anchor/platform/rpc/RpcMethodHandler.java @@ -40,6 +40,7 @@ import org.stellar.anchor.sep31.Sep31TransactionStore; import org.stellar.anchor.sep6.Sep6TransactionStore; import org.stellar.anchor.util.GsonUtils; +import org.stellar.anchor.util.Log; public abstract class RpcMethodHandler { @@ -75,7 +76,9 @@ public RpcMethodHandler( public GetTransactionResponse handle(Object requestParams) throws AnchorException { T request = gson.fromJson(gson.toJson(requestParams), requestType); + Log.infoF("Processing RPC request {}", request); JdbcSepTransaction txn = getTransaction(request.getTransactionId()); + Log.debugF("SEP transaction before request is executed {}", txn); if (txn == null) { throw new InvalidRequestException( @@ -106,6 +109,8 @@ public GetTransactionResponse handle(Object requestParams) throws AnchorExceptio updateTransaction(txn, request); + Log.debugF("Transaction after update is executed {}", txn); + GetTransactionResponse txResponse = toGetTransactionResponse(txn, assetService); eventSession.publish( diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandlerTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandlerTest.kt index 5fb246817d..25f863e6fc 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandlerTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandlerTest.kt @@ -495,6 +495,91 @@ class NotifyRefundPendingHandlerTest { assertTrue(sep24TxnCapture.captured.updatedAt <= endDate) } + @Test + fun test_handle_sep24_ok_withdrawal() { + val transferReceivedAt = Instant.now() + val request = NotifyRefundPendingRequest.builder().transactionId(TX_ID).build() + val txn24 = JdbcSep24Transaction() + txn24.status = PENDING_USR_TRANSFER_COMPLETE.toString() + txn24.kind = WITHDRAWAL.kind + txn24.transferReceivedAt = transferReceivedAt + txn24.amountInAsset = STELLAR_USDC + txn24.requestAssetCode = FIAT_USD_CODE + txn24.amountIn = "1" + txn24.amountInAsset = STELLAR_USDC + txn24.amountFee = "0.1" + txn24.amountFeeAsset = FIAT_USD + + val sep24TxnCapture = slot() + val anchorEventCapture = slot() + + every { txn6Store.findByTransactionId(any()) } returns null + every { txn24Store.findByTransactionId(TX_ID) } returns txn24 + every { txn31Store.findByTransactionId(any()) } returns null + every { txn24Store.save(capture(sep24TxnCapture)) } returns null + every { eventSession.publish(capture(anchorEventCapture)) } just Runs + every { metricsService.counter(PLATFORM_RPC_TRANSACTION, "SEP", "sep24") } returns + sepTransactionCounter + + val startDate = Instant.now() + val response = handler.handle(request) + val endDate = Instant.now() + + verify(exactly = 0) { txn6Store.save(any()) } + verify(exactly = 0) { txn31Store.save(any()) } + verify(exactly = 1) { sepTransactionCounter.increment() } + + val expectedSep24Txn = JdbcSep24Transaction() + expectedSep24Txn.kind = WITHDRAWAL.kind + expectedSep24Txn.status = PENDING_ANCHOR.toString() + expectedSep24Txn.updatedAt = sep24TxnCapture.captured.updatedAt + expectedSep24Txn.requestAssetCode = FIAT_USD_CODE + expectedSep24Txn.amountIn = "1" + expectedSep24Txn.amountInAsset = STELLAR_USDC + expectedSep24Txn.amountFee = "0.1" + expectedSep24Txn.amountFeeAsset = FIAT_USD + expectedSep24Txn.transferReceivedAt = transferReceivedAt + + JSONAssert.assertEquals( + gson.toJson(expectedSep24Txn), + gson.toJson(sep24TxnCapture.captured), + JSONCompareMode.STRICT + ) + + val expectedResponse = GetTransactionResponse() + expectedResponse.sep = SEP_24 + expectedResponse.kind = WITHDRAWAL + expectedResponse.status = PENDING_ANCHOR + expectedResponse.amountExpected = Amount(null, FIAT_USD) + expectedResponse.amountIn = Amount("1", STELLAR_USDC) + expectedResponse.amountFee = Amount("0.1", FIAT_USD) + expectedResponse.feeDetails = Amount("0.1", FIAT_USD).toRate() + expectedResponse.updatedAt = sep24TxnCapture.captured.updatedAt + + JSONAssert.assertEquals( + gson.toJson(expectedResponse), + gson.toJson(response), + JSONCompareMode.STRICT + ) + + val expectedEvent = + AnchorEvent.builder() + .id(anchorEventCapture.captured.id) + .sep(SEP_24.sep.toString()) + .type(TRANSACTION_STATUS_CHANGED) + .transaction(expectedResponse) + .build() + + JSONAssert.assertEquals( + gson.toJson(expectedEvent), + gson.toJson(anchorEventCapture.captured), + JSONCompareMode.STRICT + ) + + assertTrue(sep24TxnCapture.captured.updatedAt >= startDate) + assertTrue(sep24TxnCapture.captured.updatedAt <= endDate) + } + @Test fun test_handle_sep24_more_then_amount_in() { val transferReceivedAt = Instant.now() @@ -818,6 +903,103 @@ class NotifyRefundPendingHandlerTest { assertTrue(sep6TxnCapture.captured.updatedAt <= endDate) } + @CsvSource(value = ["withdrawal", "withdrawal-exchange"]) + @ParameterizedTest + fun test_handle_sep6_ok_withdrawal(kind: String) { + val transferReceivedAt = Instant.now() + val request = + NotifyRefundPendingRequest.builder() + .transactionId(TX_ID) + .refund( + NotifyRefundPendingRequest.Refund.builder() + .amount(AmountAssetRequest("1", STELLAR_USDC)) + .amountFee(AmountAssetRequest("0", FIAT_USD)) + .id("1") + .build() + ) + .build() + val txn6 = JdbcSep6Transaction() + txn6.status = PENDING_USR_TRANSFER_COMPLETE.toString() + txn6.kind = kind + txn6.transferReceivedAt = transferReceivedAt + txn6.requestAssetCode = FIAT_USD_CODE + txn6.amountIn = "1" + txn6.amountInAsset = STELLAR_USDC + txn6.amountFee = "0.1" + txn6.amountFeeAsset = FIAT_USD + + val sep6TxnCapture = slot() + val anchorEventCapture = slot() + + every { txn6Store.findByTransactionId(TX_ID) } returns txn6 + every { txn24Store.findByTransactionId(any()) } returns null + every { txn31Store.findByTransactionId(any()) } returns null + every { txn6Store.save(capture(sep6TxnCapture)) } returns null + every { eventSession.publish(capture(anchorEventCapture)) } just Runs + every { metricsService.counter(PLATFORM_RPC_TRANSACTION, "SEP", "sep6") } returns + sepTransactionCounter + + val startDate = Instant.now() + val response = handler.handle(request) + val endDate = Instant.now() + + verify(exactly = 0) { txn24Store.save(any()) } + verify(exactly = 0) { txn31Store.save(any()) } + verify(exactly = 1) { sepTransactionCounter.increment() } + + val expectedSep6Txn = JdbcSep6Transaction() + expectedSep6Txn.kind = kind + expectedSep6Txn.status = PENDING_ANCHOR.toString() + expectedSep6Txn.updatedAt = sep6TxnCapture.captured.updatedAt + expectedSep6Txn.requestAssetCode = FIAT_USD_CODE + expectedSep6Txn.amountIn = "1" + expectedSep6Txn.amountInAsset = STELLAR_USDC + expectedSep6Txn.amountFee = "0.1" + expectedSep6Txn.amountFeeAsset = FIAT_USD + expectedSep6Txn.transferReceivedAt = transferReceivedAt + + JSONAssert.assertEquals( + gson.toJson(expectedSep6Txn), + gson.toJson(sep6TxnCapture.captured), + JSONCompareMode.STRICT + ) + + val expectedResponse = GetTransactionResponse() + expectedResponse.sep = SEP_6 + expectedResponse.kind = PlatformTransactionData.Kind.from(kind) + expectedResponse.status = PENDING_ANCHOR + expectedResponse.amountExpected = Amount(null, FIAT_USD) + expectedResponse.amountIn = Amount("1", STELLAR_USDC) + expectedResponse.amountFee = Amount("0.1", FIAT_USD) + expectedResponse.feeDetails = Amount("0.1", FIAT_USD).toRate() + expectedResponse.updatedAt = sep6TxnCapture.captured.updatedAt + expectedResponse.transferReceivedAt = transferReceivedAt + expectedResponse.customers = Customers(StellarId(null, null, null), StellarId(null, null, null)) + + JSONAssert.assertEquals( + gson.toJson(expectedResponse), + gson.toJson(response), + JSONCompareMode.STRICT + ) + + val expectedEvent = + AnchorEvent.builder() + .id(anchorEventCapture.captured.id) + .sep(SEP_6.sep.toString()) + .type(TRANSACTION_STATUS_CHANGED) + .transaction(expectedResponse) + .build() + + JSONAssert.assertEquals( + gson.toJson(expectedEvent), + gson.toJson(anchorEventCapture.captured), + JSONCompareMode.STRICT + ) + + assertTrue(sep6TxnCapture.captured.updatedAt >= startDate) + assertTrue(sep6TxnCapture.captured.updatedAt <= endDate) + } + @CsvSource(value = ["deposit", "deposit-exchange"]) @ParameterizedTest fun test_handle_sep6_more_then_amount_in(kind: String) { From e6d9721595ca754f7dbbc2aa79372fb49c2f1881 Mon Sep 17 00:00:00 2001 From: Gleb Date: Tue, 7 May 2024 13:29:54 -0700 Subject: [PATCH 2/5] Compile fix --- .../test/java/org/stellar/anchor/sep24/PojoSep24Refunds.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/test/java/org/stellar/anchor/sep24/PojoSep24Refunds.java b/core/src/test/java/org/stellar/anchor/sep24/PojoSep24Refunds.java index 9db8492e5a..8cfcda8f6d 100644 --- a/core/src/test/java/org/stellar/anchor/sep24/PojoSep24Refunds.java +++ b/core/src/test/java/org/stellar/anchor/sep24/PojoSep24Refunds.java @@ -8,4 +8,9 @@ public class PojoSep24Refunds implements Sep24Refunds { String amountRefunded; String amountFee; List refundPayments; + + @Override + public boolean hasRefundPayments() { + return refundPayments != null; + } } From e224ffcac364011a0bfbb193b0242dc0b68e8e09 Mon Sep 17 00:00:00 2001 From: Gleb Date: Wed, 8 May 2024 13:57:00 -0700 Subject: [PATCH 3/5] Add comment --- .../anchor/platform/rpc/NotifyRefundPendingHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java b/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java index a8e58182c5..2e189ccc64 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java +++ b/platform/src/main/java/org/stellar/anchor/platform/rpc/NotifyRefundPendingHandler.java @@ -188,6 +188,9 @@ protected void updateTransactionWithRpcRequest( case SEP_6: JdbcSep6Transaction txn6 = (JdbcSep6Transaction) txn; + // For withdrawals only update status to pending_anchor to mark that refund has been + // initiated . Actual Refund + // object will be passed in the next update (notify_refund_sent), as it's not yet known. if (ImmutableSet.of(WITHDRAWAL, WITHDRAWAL_EXCHANGE).contains(Kind.from(txn6.getKind()))) { return; } From 218794fc6dd3d694d3486ecc69ddd1610368c116 Mon Sep 17 00:00:00 2001 From: Gleb Date: Wed, 8 May 2024 13:59:21 -0700 Subject: [PATCH 4/5] Add TODOs --- .../anchor/platform/integrationtest/PlatformApiTests.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt index 5a4e98e49f..65901480d5 100644 --- a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt +++ b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt @@ -27,7 +27,8 @@ import org.stellar.anchor.platform.AbstractIntegrationTests import org.stellar.anchor.platform.TestConfig import org.stellar.anchor.util.GsonUtils -@Disabled +@Disabled // TODO: https://stellarorg.atlassian.net/browse/ANCHOR-693 +// TODO: https://stellarorg.atlassian.net/browse/ANCHOR-694 class PlatformApiTests : AbstractIntegrationTests(TestConfig()) { private val gson = GsonUtils.getInstance() From 2c0be23cec66367c6151cc989db2f590d65bcf6f Mon Sep 17 00:00:00 2001 From: Gleb Date: Wed, 8 May 2024 14:05:44 -0700 Subject: [PATCH 5/5] TODO comments --- .../anchor/platform/integrationtest/PlatformApiTests.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt index 65901480d5..5c7bd66a2b 100644 --- a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt +++ b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt @@ -27,8 +27,8 @@ import org.stellar.anchor.platform.AbstractIntegrationTests import org.stellar.anchor.platform.TestConfig import org.stellar.anchor.util.GsonUtils -@Disabled // TODO: https://stellarorg.atlassian.net/browse/ANCHOR-693 -// TODO: https://stellarorg.atlassian.net/browse/ANCHOR-694 +@Disabled // TODO re-enable tests: https://stellarorg.atlassian.net/browse/ANCHOR-693 +// TODO add refund flow test for withdrawal: https://stellarorg.atlassian.net/browse/ANCHOR-694 class PlatformApiTests : AbstractIntegrationTests(TestConfig()) { private val gson = GsonUtils.getInstance()