Skip to content

Commit

Permalink
Merge remote-tracking branch 'sdf/develop' into softserve-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Sep 6, 2023
2 parents 24abfe6 + 4aa31af commit 943f85f
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 52 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/sub_gradle_test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,7 +56,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/[email protected]
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 17 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
java
alias(libs.plugins.spotless)
alias(libs.plugins.kotlin.jvm) apply false
jacoco
}

tasks {
Expand All @@ -25,12 +26,13 @@ tasks {
subprojects {
apply(plugin = "java")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "jacoco")

repositories {
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") }
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -159,7 +170,7 @@ subprojects {

allprojects {
group = "org.stellar.anchor-sdk"
version = "2.2.0"
version = "2.2.1"

tasks.jar {
manifest {
Expand All @@ -169,3 +180,7 @@ allprojects {
}
}
}

tasks.register("printVersionName") {
println(rootProject.version.toString())
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public static GetTransactionResponse toGetTransactionResponse(
.externalTransactionId(txn.getExternalTransactionId())
.memo(txn.getMemo())
.memoType(txn.getMemoType())
.refundMemo(txn.getRefundMemo())
.refundMemoType(txn.getRefundMemoType())
.build();
}

Expand Down
11 changes: 8 additions & 3 deletions core/src/test/kotlin/org/stellar/anchor/sep1/Sep1ServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -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=2.2.1)
![Develop Branch](https://github.com/stellar/java-stellar-anchor-sdk/actions/workflows/wk_push_to_develop.yml/badge.svg?branch=develop)

<div style="text-align: center">
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
jacoco = { id = "jacoco", version.ref = "jacoco" }
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public interface JdbcSep24TransactionRepo

JdbcSep24Transaction findOneByStellarTransactionId(String stellarTransactionId);

JdbcSep24Transaction findOneByToAccountAndMemo(String accountId, String memo);
JdbcSep24Transaction findOneByToAccountAndMemoAndStatus(
String toAccount, String memo, String status);

List<Sep24Transaction> findBySep10AccountAndRequestAssetCodeOrderByStartedAtDesc(
String stellarAccount, String assetCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public Sep24Transaction findByExternalTransactionId(String externalTransactionId
return txnRepo.findOneByExternalTransactionId(externalTransactionId);
}

public JdbcSep24Transaction findByToAccountAndMemo(String toAccount, String memo) {
public JdbcSep24Transaction findOneByToAccountAndMemoAndStatus(
String toAccount, String memo, String status) {
Optional<JdbcSep24Transaction> optTxn =
Optional.ofNullable(txnRepo.findOneByToAccountAndMemo(toAccount, memo));
Optional.ofNullable(txnRepo.findOneByToAccountAndMemoAndStatus(toAccount, memo, status));
return optTxn.orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JdbcSep31Transaction> findByStellarAccountIdAndStellarMemo(
@Param("stellar_account_id") String stellarAccountId,
@Param("stellar_memo") String stellarMemo);
Optional<JdbcSep31Transaction> findByStellarAccountIdAndStellarMemoAndStatus(
@Param("stellar_account_id") String accountId,
@Param("stellar_memo") String memo,
String status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<JdbcSep31Transaction> optTxn =
transactionRepo.findByStellarAccountIdAndStellarMemo(accountId, memo);
transactionRepo.findByStellarAccountIdAndStellarMemoAndStatus(accountId, memo, status);
return optTxn.orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ public void onReceived(ObservedPayment payment) throws IOException {
// Find a transaction matching the memo, assumes transactions are unique to account+memo
JdbcSep31Transaction sep31Txn = null;
try {
<<<<<<< HEAD
sep31Txn = sep31TransactionStore.findByStellarAccountIdAndMemo(payment.getTo(), memo);
=======
sep31Txn =
sep31TransactionStore.findByStellarAccountIdAndMemoAndStatus(
payment.getTo(), memo, SepTransactionStatus.PENDING_SENDER.toString());
>>>>>>> sdf/develop
} catch (Exception ex) {
errorEx(ex);
}
Expand All @@ -94,7 +100,13 @@ public void onReceived(ObservedPayment payment) throws IOException {
// Find a transaction matching the memo, assumes transactions are unique to account+memo
JdbcSep24Transaction sep24Txn;
try {
<<<<<<< HEAD
sep24Txn = sep24TransactionStore.findByToAccountAndMemo(payment.getTo(), memo);
=======
sep24Txn =
sep24TransactionStore.findOneByToAccountAndMemoAndStatus(
payment.getTo(), memo, SepTransactionStatus.PENDING_USR_TRANSFER_START.toString());
>>>>>>> sdf/develop
} catch (Exception ex) {
errorEx(ex);
return;
Expand Down
Loading

0 comments on commit 943f85f

Please sign in to comment.