Skip to content

Commit

Permalink
Merge branch 'main' of github.com:XRPLF/XRPL4j into nft-support
Browse files Browse the repository at this point in the history
Signed-off-by: David Fuelling <[email protected]>

# Conflicts:
#	xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java
#	xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/XrplEnvironment.java
  • Loading branch information
sappenin committed Aug 5, 2022
2 parents 30fe6ff + 4ef7e7c commit 691fed8
Show file tree
Hide file tree
Showing 25 changed files with 399 additions and 229 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,45 @@ jobs:
# Maven install with JVM locale = de_DE
- name: Build
run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -DargLine="-Duser.language=de -Duser.country=DE"

build_devnet_its:
runs-on: ubuntu-latest
steps:
# Checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
# Set up Java 8
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache mvn dependencies
uses: actions/cache@v2
env:
cache-name: mvn-deps
with:
path: ~/.m2
key: ${{ env.cache-name }}-${{ hashFiles('pom.xml') }}
restore-keys: ${{ env.cache-name }}-
- name: Build
run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -DuseDevnet

build_testnet_its:
runs-on: ubuntu-latest
steps:
# Checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
# Set up Java 8
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache mvn dependencies
uses: actions/cache@v2
env:
cache-name: mvn-deps
with:
path: ~/.m2
key: ${{ env.cache-name }}-${{ hashFiles('pom.xml') }}
restore-keys: ${{ env.cache-name }}-
- name: Build
run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -DuseTestnet
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,19 @@ Then you can add any of the xrpl4j modules found in the BOM to your `pom.xml`. F
```

## Development
You can build and install the project locally using maven from the command line:
You can build and test the entire project locally using maven from the command line:
```
mvn clean install -DskipTests
mvn clean install
```

To run unit tests, use the following command:
To build the project while skipping Integration tests, use the following command:
```
mvn clean install -DskipITs
```

To run the integration tests, you can either run
```
mvn clean install
To build the project while skipping Unit and Integration tests, use the following command:
```
which will run both the unit tests and integration tests, or to run only the integration tests, you can run the following commands:
```
cd xrpl4j-integration-tests
mvn clean install
mvn clean install -DskipITs -DskipTests
```

[codecov-image]: https://codecov.io/gh/XRPLF/xrpl4j/branch/main/graph/badge.svg
Expand Down
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
<checkstyle.violationSeverity>warning</checkstyle.violationSeverity>

<skipITs>false</skipITs>


<cryptoconditions.version>1.0.4</cryptoconditions.version>
<jackson.version>2.13.3</jackson.version>
<feign.version>11.6</feign.version>
Expand Down Expand Up @@ -377,10 +374,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipITs>${skipITs}</skipITs>
<argLine>${failsafe.argLine}</argLine>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static org.hamcrest.core.Is.is;

import com.google.common.primitives.UnsignedLong;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xrpl.xrpl4j.client.JsonRpcClientErrorException;
Expand Down Expand Up @@ -56,6 +55,7 @@
import org.xrpl.xrpl4j.model.transactions.Payment;
import org.xrpl.xrpl4j.model.transactions.Transaction;
import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes;
import org.xrpl.xrpl4j.model.transactions.TransactionType;
import org.xrpl.xrpl4j.model.transactions.TrustSet;
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
import org.xrpl.xrpl4j.tests.environment.XrplEnvironment;
Expand All @@ -76,33 +76,24 @@ public abstract class AbstractIT {

public static final String SUCCESS_STATUS = TransactionResultCodes.TES_SUCCESS;

protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final XrplClient xrplClient = xrplClient();
protected final WalletFactory walletFactory = DefaultWalletFactory.getInstance();

protected static XrplEnvironment xrplEnvironment;
protected static XrplEnvironment xrplEnvironment = XrplEnvironment.getConfiguredEnvironment();

/**
* Helper method to initialize the {@link XrplEnvironment} and to also allow sub-classes to use a different
* environment. This construction allows sub-classes to choose an environment that doesn't spin-up a test container.
*
* @return An {@link XrplEnvironment}.
*/
@BeforeAll
protected static void initXrplEnvironment() {
xrplEnvironment = XrplEnvironment.getConfiguredEnvironment();
}
protected final Logger logger = LoggerFactory.getLogger(this.getClass());

protected XrplClient xrplClient() {
return xrplEnvironment.getXrplClient();
}
protected final XrplClient xrplClient = xrplEnvironment.getXrplClient();
protected final WalletFactory walletFactory = DefaultWalletFactory.getInstance();

protected Wallet createRandomAccount() {
///////////////////////
// Create the account
SeedWalletGenerationResult seedResult = walletFactory.randomWallet(true);
final Wallet wallet = seedResult.wallet();
logger.info("Generated wallet with XAddress={} (Classic={})", wallet.xAddress(), wallet.classicAddress());
String network = System.getProperty("useTestnet") != null ? "testnet" :
(System.getProperty("useDevnet") != null ? "devnet" : "local rippled");
logger.info(
"Generated {} wallet with XAddress={} (Classic={})",
network, wallet.xAddress(), wallet.classicAddress()
);

fundAccount(wallet);

Expand Down Expand Up @@ -317,9 +308,10 @@ public TrustLine createTrustLine(
assertThat(trustSetSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(trustSetSubmitResult.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(trustSetSubmitResult.transactionResult().hash());
logger.info(
"TrustSet transaction successful: https://testnet.xrpl.org/transactions/" +
trustSetSubmitResult.transactionResult().hash()

logInfo(
trustSetSubmitResult.transactionResult().transaction().transactionType(),
trustSetSubmitResult.transactionResult().hash()
);

return scanForResult(
Expand Down Expand Up @@ -369,11 +361,11 @@ public void sendIssuedCurrency(

SubmitResult<Payment> paymentResult = xrplClient.submit(issuerWallet, fundCounterparty);
assertThat(paymentResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(paymentResult.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(paymentResult.transactionResult().hash());
logger.info(
"Payment transaction successful: https://testnet.xrpl.org/transactions/" +
paymentResult.transactionResult().hash()
assertThat(paymentResult.transactionResult().hash()).isEqualTo(paymentResult.transactionResult().hash());

logInfo(
paymentResult.transactionResult().transaction().transactionType(),
paymentResult.transactionResult().hash()
);

this.scanForResult(
Expand All @@ -383,4 +375,16 @@ public void sendIssuedCurrency(
);

}

/**
* Helper function to print log statements for Integration Tests which is network specific.
*
* @param transactionType {@link TransactionType} to be logged for the executed transaction.
* @param hash {@link Hash256} to be logged for the executed transaction.
*/
public void logInfo(TransactionType transactionType, Hash256 hash) {
String url = System.getProperty("useTestnet") != null ? "https://testnet.xrpl.org/transactions/" :
(System.getProperty("useDevnet") != null ? "https://devnet.xrpl.org/transactions/" : "");
logger.info(transactionType.value() + " transaction successful: {}{}", url, hash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public void enableAllAndDisableOne() throws JsonRpcClientErrorException {
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"AccountSet transaction successful: https://testnet.xrpl.org/transactions/" + response.transactionResult().hash()
logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

///////////////////////
Expand Down Expand Up @@ -134,8 +135,10 @@ public void disableAndEnableAllFlags() throws JsonRpcClientErrorException {
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"AccountSet transaction successful: https://testnet.xrpl.org/transactions/" + response.transactionResult().hash()

logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

///////////////////////
Expand Down Expand Up @@ -193,9 +196,9 @@ private void assertSetFlag(
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"AccountSet SetFlag transaction successful (asf={}; arf={}): https://testnet.xrpl.org/transactions/{}",
accountSetFlag, accountRootFlag, response.transactionResult().hash()
logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

/////////////////////////
Expand Down Expand Up @@ -229,9 +232,9 @@ private void assertClearFlag(
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"AccountSet ClearFlag transaction successful (asf={}; arf={}): https://testnet.xrpl.org/transactions/{}",
accountSetFlag, accountRootFlag, response.transactionResult().hash()
logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public void createXrpCheckAndCash() throws JsonRpcClientErrorException {
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCreate transaction successful: https://testnet.xrpl.org/transactions/{}",

logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

Expand Down Expand Up @@ -108,8 +109,8 @@ public void createXrpCheckAndCash() throws JsonRpcClientErrorException {
assertThat(cashResponse.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCash transaction successful: https://testnet.xrpl.org/transactions/{}",
logInfo(
cashResponse.transactionResult().transaction().transactionType(),
cashResponse.transactionResult().hash()
);

Expand Down Expand Up @@ -163,8 +164,9 @@ public void createCheckAndSourceCancels() throws JsonRpcClientErrorException {
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCreate transaction successful: https://testnet.xrpl.org/transactions/{}",

logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

Expand Down Expand Up @@ -194,8 +196,9 @@ public void createCheckAndSourceCancels() throws JsonRpcClientErrorException {
assertThat(cancelResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCancel transaction successful: https://testnet.xrpl.org/transactions/{}",

logInfo(
cancelResult.transactionResult().transaction().transactionType(),
cancelResult.transactionResult().hash()
);

Expand Down Expand Up @@ -240,8 +243,9 @@ public void createCheckAndDestinationCancels() throws JsonRpcClientErrorExceptio
assertThat(response.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCreate transaction successful: https://testnet.xrpl.org/transactions/{}",

logInfo(
response.transactionResult().transaction().transactionType(),
response.transactionResult().hash()
);

Expand Down Expand Up @@ -271,8 +275,9 @@ public void createCheckAndDestinationCancels() throws JsonRpcClientErrorExceptio
assertThat(cancelResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(response.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(response.transactionResult().hash());
logger.info(
"CheckCancel transaction successful: https://testnet.xrpl.org/transactions/{}",

logInfo(
cancelResult.transactionResult().transaction().transactionType(),
cancelResult.transactionResult().hash()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public void preauthorizeAccountAndReceivePayment() throws JsonRpcClientErrorExce
assertThat(result.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(result.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(result.transactionResult().hash());
logger.info("DepositPreauth transaction successful. https://testnet.xrpl.org/transactions/{}",

logInfo(
result.transactionResult().transaction().transactionType(),
result.transactionResult().hash()
);

Expand Down Expand Up @@ -112,7 +114,8 @@ public void preauthorizeAccountAndReceivePayment() throws JsonRpcClientErrorExce
assertThat(result.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(result.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(result.transactionResult().hash());
logger.info("Payment transaction successful. https://testnet.xrpl.org/transactions/{}",
logInfo(
paymentResult.transactionResult().transaction().transactionType(),
paymentResult.transactionResult().hash()
);

Expand Down Expand Up @@ -221,7 +224,6 @@ public void updateDepositPreAuthWithLedgerHash() {
* @param fee The {@link XrpCurrencyAmount} of the ledger fee for the AccountSet transaction.
*
* @return The {@link AccountInfoResult} of the wallet once the {@link AccountSet} transaction has been applied.
*
* @throws JsonRpcClientErrorException If {@code xrplClient} throws an error.
*/
private AccountInfoResult enableDepositPreauth(
Expand All @@ -243,9 +245,11 @@ private AccountInfoResult enableDepositPreauth(
assertThat(accountSetResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS);
assertThat(accountSetResult.transactionResult().transaction().hash()).isNotEmpty().get()
.isEqualTo(accountSetResult.transactionResult().hash());
logger.info("AccountSet to enable Deposit Preauth successful. https://testnet.xrpl.org/transactions/{}",
logInfo(
accountSetResult.transactionResult().transaction().transactionType(),
accountSetResult.transactionResult().hash()
);

return this.scanForResult(
() -> this.getValidatedAccountInfo(wallet.classicAddress()),
accountInfo -> accountInfo.accountData().flags().lsfDepositAuth()
Expand Down
Loading

0 comments on commit 691fed8

Please sign in to comment.