sdk/js: Added second solana devnet wallet, fixed race in Aptos NFT CI tests

This commit is contained in:
Kevin Peters 2023-01-31 20:22:17 +00:00 committed by Evan Gray
parent 7a8dea5158
commit 0243019453
5 changed files with 44 additions and 7 deletions

View File

@ -11,9 +11,11 @@
| Token Bridge | ETH | 0x0290FB167208Af455bB137780163b7B7a9a10C16 | |
| NFT Bridge | ETH | 0x26b4afb60d6c903165150c6f0aa14f8016be4aec | |
| Test Wallet | SOL | 6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J | Key in `solana/keys/solana-devnet.json` |
| Test Wallet 2 | SOL | 7HrnXGAzG6mV93Lumk7yfyrNk2bpstq8YyesqojLj8mG | Key in `solana/keys/solana-devnet2.json` |
| Example Token | SOL | 2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ | Tokens minted to Test Wallet |
| Example NFT | SOL | BVxyYhm498L79r4HMQ9sxZ5bi41DmJmeWZ7SCS7Cyvna | One minted to Test Wallet |
| Example NFT 2 | SOL | nftMANh29jbMboVnbYt1AUAWFP9N4Jnckr9Zeq85WUs | One minted to Test Wallet |
| Example NFT 3 | SOL | AQJc65JzbzsT88JnGEXSqZaF8NFAXPo21fX4QUED4uRX | One minted to Test Wallet 2 |
| Bridge Core | SOL | Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o | |
| Token Bridge | SOL | B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE | |
| NFT Bridge | SOL | NFTWqJR8YnRVqPDvTJrYuLrQDitTG5AScqbeghi4zSA | |

View File

@ -8,7 +8,11 @@ import {
} from "@jest/globals";
import { BN } from "@project-serum/anchor";
import { getAssociatedTokenAddress } from "@solana/spl-token";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import {
Connection,
Keypair,
PublicKey,
} from "@solana/web3.js";
import { AptosAccount, AptosClient, FaucetClient, Types } from "aptos";
import { ethers } from "ethers";
import Web3 from "web3";
@ -42,8 +46,8 @@ import {
ETH_NODE_URL,
ETH_PRIVATE_KEY,
SOLANA_HOST,
SOLANA_PRIVATE_KEY,
TEST_SOLANA_TOKEN,
SOLANA_PRIVATE_KEY2,
TEST_SOLANA_TOKEN2,
} from "./consts";
import {
deployTestNftOnAptos,
@ -74,7 +78,7 @@ const ethSigner = new ethers.Wallet(ETH_PRIVATE_KEY, ethProvider); // correspond
// solana setup
const solanaConnection = new Connection(SOLANA_HOST, "confirmed");
const solanaKeypair = Keypair.fromSecretKey(SOLANA_PRIVATE_KEY);
const solanaKeypair = Keypair.fromSecretKey(SOLANA_PRIVATE_KEY2);
const solanaPayerAddress = solanaKeypair.publicKey.toString();
beforeEach(async () => {
@ -358,7 +362,7 @@ describe("Aptos NFT SDK tests", () => {
test("Transfer Solana SPL to Aptos", async () => {
// transfer SPL token to Aptos
const fromAddress = await getAssociatedTokenAddress(
new PublicKey(TEST_SOLANA_TOKEN),
new PublicKey(TEST_SOLANA_TOKEN2),
solanaKeypair.publicKey
);
const solanaTransferTx = await transferFromSolana(
@ -367,7 +371,7 @@ describe("Aptos NFT SDK tests", () => {
SOLANA_NFT_BRIDGE_ADDRESS,
solanaPayerAddress,
fromAddress.toString(),
TEST_SOLANA_TOKEN,
TEST_SOLANA_TOKEN2,
tryNativeToUint8Array(aptosAccount.address().toString(), CHAIN_ID_APTOS),
CHAIN_ID_APTOS
);
@ -419,7 +423,7 @@ describe("Aptos NFT SDK tests", () => {
)) as DepositEvent[];
expect(events.length).toBe(1);
expect(events[0].data.id.token_data_id.name).toBe(
tryNativeToHexString(TEST_SOLANA_TOKEN, CHAIN_ID_SOLANA)
tryNativeToHexString(TEST_SOLANA_TOKEN2, CHAIN_ID_SOLANA)
);
});
});

View File

@ -16,6 +16,12 @@ export const SOLANA_PRIVATE_KEY = new Uint8Array([
8, 174, 214, 157, 175, 126, 98, 90, 54, 24, 100, 177, 247, 77, 19, 112, 47,
44, 165, 109, 233, 102, 14, 86, 109, 29, 134, 145, 132, 141,
]);
export const SOLANA_PRIVATE_KEY2 = new Uint8Array([
118, 84, 4, 83, 83, 183, 31, 184, 20, 172, 95, 146, 7, 107, 141, 183, 124,
196, 66, 246, 215, 243, 54, 61, 118, 188, 239, 237, 168, 108, 227, 169, 93,
119, 180, 216, 9, 169, 30, 4, 167, 235, 188, 51, 70, 24, 181, 227, 189, 59,
163, 161, 252, 219, 17, 105, 197, 241, 19, 66, 205, 188, 232, 131,
]);
export const TERRA_NODE_URL = ci
? "http://terra-terrad:1317"
: "http://localhost:1317";
@ -29,6 +35,7 @@ export const TEST_ERC721 = "0x5b9b42d6e4B2e4Bf8d42Eba32D46918e10899B66";
export const TERRA_CW721_CODE_ID = 7;
export const TEST_CW721 = "terra18dt935pdcn2ka6l0syy5gt20wa48n3mktvdvjj";
export const TEST_SOLANA_TOKEN = "BVxyYhm498L79r4HMQ9sxZ5bi41DmJmeWZ7SCS7Cyvna";
export const TEST_SOLANA_TOKEN2 = "AQJc65JzbzsT88JnGEXSqZaF8NFAXPo21fX4QUED4uRX";
export const WORMHOLE_RPC_HOSTS = ci
? ["http://guardian:7071"]
: ["http://localhost:7071"];

View File

@ -30,6 +30,11 @@ cat <<EOF > nft2.json
[40,74,92,250,81,56,202,67,129,124,193,219,24,161,198,98,191,214,136,7,112,26,72,17,33,249,24,225,183,237,27,216,11,179,26,170,82,220,3,253,152,185,151,186,12,21,138,161,175,46,180,3,167,165,70,51,128,45,237,143,146,49,34,180]
EOF
# Static key for the 3nd NFT mint so it always has the same address
cat <<EOF > nft3.json
[237,91,99,59,171,108,222,79,145,161,183,11,19,47,174,103,92,35,34,136,123,190,169,63,107,117,190,109,0,240,233,8,139,177,114,106,66,109,185,216,58,55,83,115,160,194,236,49,7,252,13,189,79,81,65,124,113,183,96,26,14,98,166,118]
EOF
# Constants
cli_address=6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J
bridge_address=Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
@ -37,6 +42,7 @@ nft_bridge_address=NFTWqJR8YnRVqPDvTJrYuLrQDitTG5AScqbeghi4zSA
token_bridge_address=B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE
recipient_address=90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
chain_id_ethereum=2
account2=7HrnXGAzG6mV93Lumk7yfyrNk2bpstq8YyesqojLj8mG
# load the .env file with the devent init data
source .env
@ -50,6 +56,9 @@ retry () {
# Fund our account (as defined in solana/keys/solana-devnet.json).
retry solana airdrop 1000
# Fund our second account
solana airdrop 1000 "$account2"
# Create a new SPL token
token=$(spl-token create-token -- token.json | grep 'Creating token' | awk '{ print $3 }')
echo "Created token $token"
@ -88,6 +97,20 @@ spl-token mint "$nft" 1 "$nft_account"
token-bridge-client create-meta "$nft" "Not a PUNK 2🎸" "PUNK2🎸" "https://wrappedpunks.com:3000/api/punks/metadata/51"
# Create a new SPL NFT
nft=$(spl-token create-token --decimals 0 -- nft3.json | grep 'Creating token' | awk '{ print $3 }')
echo "Created NFT $nft"
# Create NFT account
nft_account=$(spl-token create-account --owner "$account2" "$nft" | grep 'Creating account' | awk '{ print $3 }')
echo "Created NFT account $nft_account"
# Mint new NFT owned by our second account
spl-token mint "$nft" 1 "$nft_account"
# Create meta for token
token-bridge-client create-meta "$nft" "Not a PUNK3🎸" "PUNK3🎸" "https://wrappedpunks.com:3000/api/punks/metadata/69"
# Create the bridge contract at a known address
# OK to fail on subsequent attempts (already created).
retry client create-bridge "$bridge_address" "$INIT_SIGNERS_CSV" 86400 100

View File

@ -0,0 +1 @@
[118,84,4,83,83,183,31,184,20,172,95,146,7,107,141,183,124,196,66,246,215,243,54,61,118,188,239,237,168,108,227,169,93,119,180,216,9,169,30,4,167,235,188,51,70,24,181,227,189,59,163,161,252,219,17,105,197,241,19,66,205,188,232,131]