Skip to content

Commit

Permalink
Run ITs on devnet and testnet by default (#252)
Browse files Browse the repository at this point in the history
* run ITs on testnet and devnet by default and use -DuseLocal for running on local rippled
* refactor log statements in all ITs
* increase fees on all txs; maxQSize() in feeResult mandatory; replace log.info with method to print correct links
* remove unnecessary print statement

Signed-off-by: David Fuelling <[email protected]>
Co-authored-by: David Fuelling <[email protected]>
  • Loading branch information
mukulljangid and sappenin authored Aug 5, 2022
1 parent 9dcbbfa commit 4ef7e7c
Show file tree
Hide file tree
Showing 25 changed files with 419 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 @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -55,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 Down Expand Up @@ -87,7 +88,12 @@ protected Wallet createRandomAccount() {
// Create the account
SeedWalletGenerationResult seedResult = walletFactory.randomWallet(true);
final Wallet wallet = seedResult.wallet();
logger.info("Generated testnet 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 @@ -302,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 @@ -356,9 +363,10 @@ public void sendIssuedCurrency(
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()

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

this.scanForResult(
Expand All @@ -368,4 +376,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 @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down 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 4ef7e7c

Please sign in to comment.