Skip to content

Commit

Permalink
Merge branch 'main' into nk/xchain
Browse files Browse the repository at this point in the history
  • Loading branch information
nkramer44 authored Nov 30, 2023
2 parents fb64cc3 + 45d33c7 commit 757f859
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.google.common.primitives.UnsignedInteger;
import com.google.common.primitives.UnsignedLong;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.xrpl.xrpl4j.client.JsonRpcClientErrorException;
import org.xrpl.xrpl4j.crypto.keys.KeyPair;
import org.xrpl.xrpl4j.crypto.keys.PrivateKey;
Expand Down Expand Up @@ -54,8 +55,14 @@
import java.math.RoundingMode;
import java.util.stream.Collectors;

@DisabledIf(value = "shouldNotRun", disabledReason = "AmmIT only runs on local rippled node or devnet.")
public class AmmIT extends AbstractIT {

static boolean shouldNotRun() {
return System.getProperty("useTestnet") != null ||
System.getProperty("useClioTestnet") != null;
}

String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0');

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.primitives.UnsignedInteger;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.xrpl.xrpl4j.client.JsonRpcClientErrorException;
import org.xrpl.xrpl4j.crypto.keys.KeyPair;
import org.xrpl.xrpl4j.crypto.signing.SingleSignedTransaction;
Expand All @@ -22,8 +23,14 @@
import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes;
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;

@DisabledIf(value = "shouldNotRun", disabledReason = "ClawbackIT only runs on local rippled node or devnet.")
public class ClawbackIT extends AbstractIT {

static boolean shouldNotRun() {
return System.getProperty("useTestnet") != null ||
System.getProperty("useClioTestnet") != null;
}

@Test
void issueBalanceAndClawback() throws JsonRpcClientErrorException, JsonProcessingException {
KeyPair issuerKeyPair = createRandomAccountEd25519();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ public void sendPayment() throws JsonRpcClientErrorException, JsonProcessingExce

@Test
public void sendPaymentFromSecp256k1KeyPair() throws JsonRpcClientErrorException, JsonProcessingException {
KeyPair senderKeyPair = Seed.fromBase58EncodedSecret(
Base58EncodedSecret.of("sp5fghtJtpUorTwvof1NpDXAzNwf5")
).deriveKeyPair();
KeyPair senderKeyPair = this.createRandomAccountSecp256k1();
logger.info("Generated source testnet wallet with address " + senderKeyPair.publicKey().deriveAddress());

fundAccount(senderKeyPair.publicKey().deriveAddress());

KeyPair destinationKeyPair = createRandomAccountEd25519();

FeeResult feeResult = xrplClient.fee();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Comparator;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

/**
Expand All @@ -59,7 +60,15 @@ public class TransactUsingDerivedKeySignatureServiceIT extends AbstractIT {

@Test
public void sendPaymentFromEd25519Account() throws JsonRpcClientErrorException, JsonProcessingException {
final PrivateKeyReference sourceKeyMetadata = constructPrivateKeyReference("sourceWallet", KeyType.ED25519);
// We must use a random key identifier here rather than a hardcoded identifier because the keypair associated
// with the hard coded identifier is deterministic. When we run ITs on a real network in CI like testnet or devnet,
// we sometimes see `tefPAST_SEQ` errors when submitting the transaction because another CI job has submitted
// a transaction for the account between when this test gets the source's account info and when it submits the
// transaction. Using a random account every time ensures this test's behavior is isolated from other tests.
final PrivateKeyReference sourceKeyMetadata = constructPrivateKeyReference(
UUID.randomUUID().toString(),
KeyType.ED25519
);
final PublicKey sourceWalletPublicKey = derivedKeySignatureService.derivePublicKey(sourceKeyMetadata);
final Address sourceWalletAddress = sourceWalletPublicKey.deriveAddress();
this.fundAccount(sourceWalletAddress);
Expand Down Expand Up @@ -94,7 +103,15 @@ public void sendPaymentFromEd25519Account() throws JsonRpcClientErrorException,

@Test
public void sendPaymentFromSecp256k1Account() throws JsonRpcClientErrorException, JsonProcessingException {
final PrivateKeyReference sourceKeyMetadata = constructPrivateKeyReference("sourceWallet", KeyType.SECP256K1);
// We must use a random key identifier here rather than a hardcoded identifier because the keypair associated
// with the hard coded identifier is deterministic. When we run ITs on a real network in CI like testnet or devnet,
// we sometimes see `tefPAST_SEQ` errors when submitting the transaction because another CI job has submitted
// a transaction for the account between when this test gets the source's account info and when it submits the
// transaction. Using a random account every time ensures this test's behavior is isolated from other tests.
final PrivateKeyReference sourceKeyMetadata = constructPrivateKeyReference(
UUID.randomUUID().toString(),
KeyType.SECP256K1
);
final PublicKey sourceWalletPublicKey = derivedKeySignatureService.derivePublicKey(sourceKeyMetadata);
final Address sourceWalletAddress = sourceWalletPublicKey.deriveAddress();
this.fundAccount(sourceWalletAddress);
Expand Down

0 comments on commit 757f859

Please sign in to comment.