-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup of bits and pieces including adding remaining but as yet unim…
…plemented integration tests
- Loading branch information
Showing
14 changed files
with
214 additions
and
129 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...tegration-test/java/com/lmax/solana4j/programs/AssociatedTokenProgramIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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.Disabled; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class AssociatedTokenProgramIntegrationTest extends IntegrationTestBase | ||
{ | ||
@BeforeEach | ||
void beforeEachTest() | ||
{ | ||
solana.createKeyPair("payer"); | ||
solana.airdrop("payer", "100"); | ||
} | ||
|
||
@Disabled | ||
@ParameterizedMessageEncodingTest | ||
void shouldCreateAssociatedTokenAddress(final String messageEncoding) | ||
{ | ||
fail(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ation-test/java/com/lmax/solana4j/programs/BpfLoaderUpgradableProgramIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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.Disabled; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class BpfLoaderUpgradableProgramIntegrationTest extends IntegrationTestBase | ||
{ | ||
@BeforeEach | ||
void beforeEachTest() | ||
{ | ||
solana.createKeyPair("payer"); | ||
solana.airdrop("payer", "100"); | ||
} | ||
|
||
@Disabled | ||
@ParameterizedMessageEncodingTest | ||
void shouldSetUpgradeAuthority(final String messageEncoding) | ||
{ | ||
fail(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...integration-test/java/com/lmax/solana4j/programs/ComputeBudgetProgramIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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.Disabled; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class ComputeBudgetProgramIntegrationTest extends IntegrationTestBase | ||
{ | ||
@BeforeEach | ||
void beforeEachTest() | ||
{ | ||
solana.createKeyPair("payer"); | ||
solana.airdrop("payer", "100"); | ||
} | ||
|
||
@Disabled | ||
@ParameterizedMessageEncodingTest | ||
void shouldSetComputeUnitLimit(final String messageEncoding) | ||
{ | ||
fail(); | ||
} | ||
|
||
|
||
@Disabled | ||
@ParameterizedMessageEncodingTest | ||
void shouldSetComputeUnitPrice(final String messageEncoding) | ||
{ | ||
fail(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/lmax/solana4j/programs/AssociatedTokenProgram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,56 @@ | ||
package com.lmax.solana4j.programs; | ||
|
||
import com.lmax.solana4j.Solana; | ||
import com.lmax.solana4j.api.ProgramDerivedAddress; | ||
import com.lmax.solana4j.api.PublicKey; | ||
import com.lmax.solana4j.api.TransactionBuilderBase; | ||
import org.bitcoinj.core.Base58; | ||
|
||
import java.nio.ByteOrder; | ||
|
||
import static com.lmax.solana4j.encoding.SysVar.RENT; | ||
import static com.lmax.solana4j.programs.SystemProgram.SYSTEM_PROGRAM_ACCOUNT; | ||
|
||
public final class AssociatedTokenProgram | ||
{ | ||
private static final byte[] ASSOCIATED_TOKEN_PROGRAM_ID = Base58.decode("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"); | ||
public static final PublicKey ASSOCIATED_TOKEN_PROGRAM_ACCOUNT = Solana.account(ASSOCIATED_TOKEN_PROGRAM_ID); | ||
|
||
public static final int IDEMPOTENT_CREATE_INSTRUCTION = 1; | ||
public static final int CREATE_INSTRUCTION = 0; | ||
|
||
private final TransactionBuilderBase tb; | ||
|
||
public static AssociatedTokenProgram factory(final TransactionBuilderBase tb) | ||
{ | ||
return new AssociatedTokenProgram(tb); | ||
} | ||
|
||
private AssociatedTokenProgram(final TransactionBuilderBase tb) | ||
{ | ||
this.tb = tb; | ||
} | ||
|
||
public AssociatedTokenProgram createAssociatedToken( | ||
final ProgramDerivedAddress programDerivedAddress, | ||
final PublicKey mint, | ||
final PublicKey owner, | ||
final PublicKey payer, | ||
final boolean idempotent) | ||
{ | ||
tb.append(ib -> ib | ||
.program(ASSOCIATED_TOKEN_PROGRAM_ACCOUNT) | ||
.account(payer, true, true) | ||
.account(programDerivedAddress.address(), false, true) | ||
.account(owner, false, false) | ||
.account(mint, false, false) | ||
.account(SYSTEM_PROGRAM_ACCOUNT, false, false) | ||
.account(ASSOCIATED_TOKEN_PROGRAM_ACCOUNT, false, false) | ||
.account(RENT, false, false) | ||
.data(1, bb -> bb.order(ByteOrder.LITTLE_ENDIAN) | ||
.put((byte) (idempotent ? IDEMPOTENT_CREATE_INSTRUCTION : CREATE_INSTRUCTION))) | ||
); | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.