sdk/js: Fix CI eth test wallet tx nonce race
This commit is contained in:
parent
0243019453
commit
eab0e38b89
|
@ -8,11 +8,7 @@ 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";
|
||||
|
@ -44,10 +40,10 @@ import {
|
|||
APTOS_FAUCET_URL,
|
||||
APTOS_NODE_URL,
|
||||
ETH_NODE_URL,
|
||||
ETH_PRIVATE_KEY,
|
||||
ETH_PRIVATE_KEY8,
|
||||
SOLANA_HOST,
|
||||
SOLANA_PRIVATE_KEY2,
|
||||
TEST_SOLANA_TOKEN2,
|
||||
TEST_SOLANA_TOKEN3,
|
||||
} from "./consts";
|
||||
import {
|
||||
deployTestNftOnAptos,
|
||||
|
@ -74,7 +70,7 @@ let faucet: FaucetClient;
|
|||
// ethereum setup
|
||||
const web3 = new Web3(ETH_NODE_URL);
|
||||
const ethProvider = new ethers.providers.WebSocketProvider(ETH_NODE_URL);
|
||||
const ethSigner = new ethers.Wallet(ETH_PRIVATE_KEY, ethProvider); // corresponds to accounts[1]
|
||||
const ethSigner = new ethers.Wallet(ETH_PRIVATE_KEY8, ethProvider);
|
||||
|
||||
// solana setup
|
||||
const solanaConnection = new Connection(SOLANA_HOST, "confirmed");
|
||||
|
@ -362,7 +358,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_TOKEN2),
|
||||
new PublicKey(TEST_SOLANA_TOKEN3),
|
||||
solanaKeypair.publicKey
|
||||
);
|
||||
const solanaTransferTx = await transferFromSolana(
|
||||
|
@ -371,7 +367,7 @@ describe("Aptos NFT SDK tests", () => {
|
|||
SOLANA_NFT_BRIDGE_ADDRESS,
|
||||
solanaPayerAddress,
|
||||
fromAddress.toString(),
|
||||
TEST_SOLANA_TOKEN2,
|
||||
TEST_SOLANA_TOKEN3,
|
||||
tryNativeToUint8Array(aptosAccount.address().toString(), CHAIN_ID_APTOS),
|
||||
CHAIN_ID_APTOS
|
||||
);
|
||||
|
@ -423,7 +419,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_TOKEN2, CHAIN_ID_SOLANA)
|
||||
tryNativeToHexString(TEST_SOLANA_TOKEN3, CHAIN_ID_SOLANA)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,6 +7,9 @@ const ci = !!process.env.CI;
|
|||
export const ETH_NODE_URL = ci ? "ws://eth-devnet:8545" : "ws://localhost:8545";
|
||||
export const ETH_PRIVATE_KEY =
|
||||
"0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1"; // account 1
|
||||
export const ETH_PRIVATE_KEY8 =
|
||||
"0x829e924fdf021ba3dbbc4225edfece9aca04b929d6e75613329ca6f1d31c0bb4"; // account 8 - aptos nft tests
|
||||
|
||||
export const SOLANA_HOST = ci
|
||||
? "http://solana-devnet:8899"
|
||||
: "http://localhost:8899";
|
||||
|
@ -35,7 +38,8 @@ 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 TEST_SOLANA_TOKEN3 =
|
||||
"AQJc65JzbzsT88JnGEXSqZaF8NFAXPo21fX4QUED4uRX";
|
||||
export const WORMHOLE_RPC_HOSTS = ci
|
||||
? ["http://guardian:7071"]
|
||||
: ["http://localhost:7071"];
|
||||
|
|
|
@ -43,15 +43,15 @@ export async function deployTestNftOnEthereum(
|
|||
uri: string,
|
||||
howMany: number
|
||||
): Promise<NFTImplementation> {
|
||||
const accounts = await web3.eth.getAccounts();
|
||||
const address = await signer.getAddress();
|
||||
const nftContract = new web3.eth.Contract(ERC721.abi);
|
||||
let nft = await nftContract
|
||||
const nft = await nftContract
|
||||
.deploy({
|
||||
data: ERC721.bytecode,
|
||||
arguments: [name, symbol, uri],
|
||||
})
|
||||
.send({
|
||||
from: accounts[1],
|
||||
from: address,
|
||||
gas: 5000000,
|
||||
});
|
||||
|
||||
|
@ -60,8 +60,8 @@ export async function deployTestNftOnEthereum(
|
|||
// foreign ids on terra get converted to the decimal stringified form of the
|
||||
// original id.
|
||||
for (var i = 0; i < howMany; i++) {
|
||||
await nft.methods.mint(accounts[1]).send({
|
||||
from: accounts[1],
|
||||
await nft.methods.mint(address).send({
|
||||
from: address,
|
||||
gas: 1000000,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ export const ETH_PRIVATE_KEY6 =
|
|||
"0xe485d098507f54e7733a205420dfddbe58db035fa577fc294ebd14db90767a52"; // account 6 - aptos tests
|
||||
export const ETH_PRIVATE_KEY7 =
|
||||
"0xa453611d9419d0e56f499079478fd72c37b251a94bfde4d19872c44cf65386e3"; // account 7 - algorand tests
|
||||
export const ETH_PRIVATE_KEY8 =
|
||||
"0x829e924fdf021ba3dbbc4225edfece9aca04b929d6e75613329ca6f1d31c0bb4"; // account 8 - unused
|
||||
export const ETH_PRIVATE_KEY9 =
|
||||
"0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773"; // account 9 - accountant tests
|
||||
export const SOLANA_HOST = ci
|
||||
|
|
Loading…
Reference in New Issue