Skip to content

Commit

Permalink
Fix failing AMM IT
Browse files Browse the repository at this point in the history
* Reduce default amount of XRP in ITs to conform to new 100 XRP faucet policies.
* Update ammendments
* Update rippled container to v2.2
  • Loading branch information
sappenin committed May 22, 2024
1 parent eabbafe commit 584c7bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces
TradingFee expectedTradingFee = TradingFee.ofPercent(
issuerLpTokenBalance.multiply(amm.amm().tradingFee().bigDecimalValue()).add(
traderLpTokenBalance.multiply(newTradingFee.bigDecimalValue())
).divide(issuerLpTokenBalance.add(traderLpTokenBalance), RoundingMode.FLOOR)
.setScale(3, RoundingMode.FLOOR)
).divide(issuerLpTokenBalance.add(traderLpTokenBalance), RoundingMode.HALF_UP)
.setScale(3, RoundingMode.HALF_UP)
);

AmmInfoResult ammAfterVote = getAmmInfo(issuerKeyPair);
Expand Down Expand Up @@ -255,7 +255,7 @@ void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingExce
.build()
)
.asset(Issue.XRP)
.amount(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(90)))
.amount(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(9)))
.flags(AmmWithdrawFlags.SINGLE_ASSET)
.build();

Expand Down Expand Up @@ -296,7 +296,7 @@ private AccountInfoResult depositXrp(
SignatureService<PrivateKey> signatureService,
FeeResult feeResult
) throws JsonRpcClientErrorException, JsonProcessingException {
XrpCurrencyAmount depositAmount = XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100));
XrpCurrencyAmount depositAmount = XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(10));
AmmDeposit deposit = AmmDeposit.builder()
.account(traderAccount.accountData().account())
.asset2(
Expand Down Expand Up @@ -373,10 +373,10 @@ private AmmInfoResult createAmm(
IssuedCurrencyAmount.builder()
.issuer(issuerKeyPair.publicKey().deriveAddress())
.currency(xrpl4jCoin)
.value("25")
.value("2.5")
.build()
)
.amount2(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100)))
.amount2(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(10)))
.tradingFee(TradingFee.ofPercent(BigDecimal.ONE))
.lastLedgerSequence(issuerAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue())
.signingPublicKey(issuerKeyPair.publicKey())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public class RippledContainer {
LOGGER.warn("Ledger accept failed", e);
}
};
private final GenericContainer rippledContainer;
private final GenericContainer<?> rippledContainer;
private final ScheduledExecutorService ledgerAcceptor;
private boolean started;

/**
* No-args constructor.
*/
public RippledContainer() {
rippledContainer = new GenericContainer("rippleci/rippled:2.0.0-b4")
rippledContainer = new GenericContainer<>("rippleci/rippled:2.2.0-rc3")
.withCreateContainerCmdModifier((Consumer<CreateContainerCmd>) (cmd) ->
cmd.withEntrypoint("/opt/ripple/bin/rippled"))
.withCommand("-a --start --conf /config/rippled.cfg")
Expand All @@ -92,8 +92,6 @@ public static KeyPair getMasterKeyPair() {

/**
* Starts container with default interval (1s) for closing ledgers.
*
* @return
*/
public RippledContainer start() {
return this.start(1000);
Expand All @@ -102,9 +100,9 @@ public RippledContainer start() {
/**
* Start contain with given interval for closing ledgers.
*
* @param acceptIntervalMillis
* @param acceptIntervalMillis The number of milliseconds before each accept call to close the ledger.
*
* @return
* @return A {@link RippledContainer}.
*/
public RippledContainer start(int acceptIntervalMillis) {
if (started) {
Expand Down Expand Up @@ -166,7 +164,7 @@ private void assertContainerStarted() {
/**
* Provides an instance of an {@link XrplAdminClient} that will connect to the rippled container.
*
* @return
* @return A {@link XrplAdminClient}.
*/
public XrplAdminClient getXrplAdminClient() {
return new XrplAdminClient(this.getBaseUri());
Expand All @@ -175,13 +173,13 @@ public XrplAdminClient getXrplAdminClient() {
/**
* Provides an instance of an {@link XrplClient} that will connect to the rippled container.
*
* @return
* @return A {@link XrplAdminClient}.
*/
public XrplClient getXrplClient() {
return new XrplClient(this.getBaseUri());
}

private static HttpUrl getBaseUri(GenericContainer rippledContainer) {
private static HttpUrl getBaseUri(GenericContainer<?> rippledContainer) {
return HttpUrl.parse("http://" + rippledContainer.getHost() + ":" + rippledContainer.getMappedPort(5005) + "/");
}

Expand Down
15 changes: 14 additions & 1 deletion xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,17 @@ fixReducedOffersV1
fixNFTokenRemint
# 2.0.0 Amendments
XChainBridge
DID
DID
fixFillOrKill
fixDisallowIncomingV1
# 2.1.0 Amendments
fixNFTokenReserve
fixInnerObjTemplate
# 2.1.1 Amendments
fixAMMOverflowOffer
# TBD Version
fixPreviousTxnID
fixAMMv1_1
fixEmptyDID
fixXChainRewardRounding
PriceOracle

0 comments on commit 584c7bf

Please sign in to comment.