Skip to content

Commit

Permalink
cleaned up test support packages and paramterized existing tests for …
Browse files Browse the repository at this point in the history
…solana message encoding

the tests are really slow, need to speed them up somehow - must look at the start-up script for the validator container and see if there's any configuration to tweak to move things along a bit
  • Loading branch information
ml-james committed May 31, 2024
1 parent b22b90a commit 1681beb
Show file tree
Hide file tree
Showing 77 changed files with 205 additions and 164 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencies {
testSupportImplementation 'com.lmax:simple-dsl:3.0.0'
testSupportImplementation 'org.assertj:assertj-core:3.25.3'
testSupportImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testSupportImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testSupportImplementation 'com.fasterxml.jackson.core:jackson-core:2.17.1'
testSupportImplementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
testSupportImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
Expand All @@ -69,6 +70,7 @@ dependencies {
// test dependencies
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testImplementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1'
testImplementation 'org.slf4j:slf4j-api:2.0.13'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.lmax.solana4j.programs;

import com.lmax.solana4j.base.IntegrationTestBase;
import com.lmax.solana4j.base.ParameterizedMessageEncodingTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

final class AddressLookupTableProgramIntegrationTest extends V0EncodingIntegrationTest
final class AddressLookupTableProgramIntegrationTest extends IntegrationTestBase
{
@BeforeEach
void beforeEachTest()
Expand All @@ -13,16 +14,20 @@ void beforeEachTest()
solana.createKeyPair("addressLookupTableAuthority");
}

@Test
void shouldCreateAddressLookupTable()
@ParameterizedMessageEncodingTest
void shouldCreateAddressLookupTable(final String messageEncoding)
{
solana.setMessageEncoding(messageEncoding);

solana.createAddressLookupTable("lookupTableAddress", "addressLookupTableAuthority", "payer");
solana.retrieveAddressLookupTable("lookupTableAddress");
}

@Test
void shouldExtendAddressLookupTable()
@ParameterizedMessageEncodingTest
void shouldExtendAddressLookupTable(final String messageEncoding)
{
solana.setMessageEncoding(messageEncoding);

solana.createAddressLookupTable("lookupTableAddress", "addressLookupTableAuthority", "payer");

solana.createKeyPair("addressForLookupTable1");
Expand Down

This file was deleted.

This file was deleted.

17 changes: 11 additions & 6 deletions src/test-support/java/com/lmax/solana4j/SolanaDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import com.lmax.solana4j.api.AddressLookupTable;
import com.lmax.solana4j.api.Slot;
import com.lmax.solana4j.domain.TestKeyPair;
import com.lmax.solana4j.domain.TestPublicKey;
import com.lmax.solana4j.programs.AddressWithBumpSeed;
import com.lmax.solana4j.testclient.api.AccountInfo;
import com.lmax.solana4j.testclient.api.Commitment;
import com.lmax.solana4j.testclient.api.SolanaApi;
import com.lmax.solana4j.testclient.api.TransactionResponse;
import com.lmax.solana4j.client.api.AccountInfo;
import com.lmax.solana4j.client.api.Commitment;
import com.lmax.solana4j.client.api.SolanaApi;
import com.lmax.solana4j.client.api.TransactionResponse;
import com.lmax.solana4j.transaction.LegacyTransactionFactory;
import com.lmax.solana4j.transaction.TransactionFactory;
import com.lmax.solana4j.transaction.V0TransactionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -53,7 +58,7 @@ public String createAddressLookupTable(final AddressWithBumpSeed addressWithBump
final Slot slot,
final List<AddressLookupTable> addressLookupTables)
{
final com.lmax.solana4j.testclient.api.Blockhash recentBlockhash = solanaApi.getRecentBlockHash();
final com.lmax.solana4j.client.api.Blockhash recentBlockhash = solanaApi.getRecentBlockHash();

final String transactionBlob = getTransactionFactory().createAddressLookupTable(
addressWithBumpSeed,
Expand All @@ -74,7 +79,7 @@ public String extendAddressLookupTable(final TestPublicKey addressLookupTable,
final List<TestPublicKey> addressesToAdd,
final List<AddressLookupTable> addressLookupTables)
{
final com.lmax.solana4j.testclient.api.Blockhash recentBlockhash = solanaApi.getRecentBlockHash();
final com.lmax.solana4j.client.api.Blockhash recentBlockhash = solanaApi.getRecentBlockHash();

final String transactionBlob = getTransactionFactory().extendAddressLookupTable(
addressLookupTable.getSolana4jPublicKey(),
Expand Down
16 changes: 10 additions & 6 deletions src/test-support/java/com/lmax/solana4j/SolanaNodeDsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
import com.lmax.simpledsl.api.RequiredArg;
import com.lmax.solana4j.api.AddressLookupTable;
import com.lmax.solana4j.api.PublicKey;
import com.lmax.solana4j.assertions.IsEqualToAssertion;
import com.lmax.solana4j.assertions.IsNotNullAssertion;
import com.lmax.solana4j.assertion.IsEqualToAssertion;
import com.lmax.solana4j.assertion.IsNotNullAssertion;
import com.lmax.solana4j.domain.Sol;
import com.lmax.solana4j.domain.TestKeyPair;
import com.lmax.solana4j.domain.TestKeyPairGenerator;
import com.lmax.solana4j.domain.TestPublicKey;
import com.lmax.solana4j.programs.AddressLookupTableProgram;
import com.lmax.solana4j.programs.AddressWithBumpSeed;
import com.lmax.solana4j.testclient.api.AccountInfo;
import com.lmax.solana4j.testclient.api.Commitment;
import com.lmax.solana4j.testclient.jsonrpc.SolanaClient;
import com.lmax.solana4j.client.api.AccountInfo;
import com.lmax.solana4j.client.api.Commitment;
import com.lmax.solana4j.client.jsonrpc.SolanaClient;
import org.bouncycastle.util.encoders.Base64;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import static com.lmax.solana4j.testclient.api.Commitment.FINALIZED;
import static com.lmax.solana4j.client.api.Commitment.FINALIZED;
import static java.util.Arrays.stream;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

Expand Down
2 changes: 2 additions & 0 deletions src/test-support/java/com/lmax/solana4j/TestContext.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.lmax.solana4j;

import com.lmax.solana4j.api.AddressLookupTable;
import com.lmax.solana4j.domain.TestKeyPair;
import com.lmax.solana4j.domain.TestPublicKey;

import java.util.HashMap;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion src/test-support/java/com/lmax/solana4j/Waiter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.lmax.solana4j;

import com.lmax.solana4j.assertions.Assertion;
import com.lmax.solana4j.assertion.Assertion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.assertions;
package com.lmax.solana4j.assertion;

public abstract class Assertion<T>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.assertions;
package com.lmax.solana4j.assertion;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.assertions;
package com.lmax.solana4j.assertion;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.lmax.solana4j.programs;
package com.lmax.solana4j.base;

import com.lmax.solana4j.SolanaNodeDsl;
import org.junit.jupiter.api.BeforeEach;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;

abstract class IntegrationTestBase
public abstract class IntegrationTestBase
{
public static final int SOLANA_HTTP_PORT = 8899;
public static final int SOLANA_WS_PORT = 8900;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.lmax.solana4j.base;

import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;

import java.util.stream.Stream;

public class MessageEncodingArgumentsParameter implements ArgumentsProvider
{
@Override
public Stream<? extends Arguments> provideArguments(final ExtensionContext context)
{
return Stream.of(
Arguments.of("V0"),
Arguments.of("Legacy")
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.lmax.solana4j.base;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@ParameterizedTest(name = "{index}: (Message Encoding {0})")
@ArgumentsSource(MessageEncodingArgumentsParameter.class)
public @interface ParameterizedMessageEncodingTest
{
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface AccountKey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface Blockhash
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public enum Commitment
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface Context
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public enum Encoding
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface Header
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface ProgramAccountResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface Reward
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface SignatureInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface SignatureStatus
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface SolanaApi
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface SolanaRpcResponse<T>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface TokenAccount
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface TokenAmount
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface TokenBalance
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface Transaction
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lmax.solana4j.testclient.api;
package com.lmax.solana4j.client.api;

public interface TransactionResponse
{
Expand Down
Loading

0 comments on commit 1681beb

Please sign in to comment.