Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 23 additions & 48 deletions tests/e2e/api/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ describe("account api", () => {
});

test("it fetches account modules with a limit", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const data = await aptos.getAccountModules({
accountAddress: "0x1",
options: {
Expand All @@ -55,8 +54,7 @@ describe("account api", () => {
});

test("it fetches account modules with pagination", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
let { modules, cursor } = await aptos.getAccountModulesPage({
accountAddress: "0x1",
options: {
Expand All @@ -82,8 +80,7 @@ describe("account api", () => {
});

test("it fetches an account module", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const data = await aptos.getAccountModule({
accountAddress: "0x1",
moduleName: "coin",
Expand All @@ -92,17 +89,15 @@ describe("account api", () => {
});

test("it fetches account resources", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const data = await aptos.getAccountResources({
accountAddress: "0x1",
});
expect(data.length).toBeGreaterThan(0);
});

test("it fetches account resources with a limit", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const data = await aptos.getAccountResources({
accountAddress: "0x1",
options: {
Expand All @@ -113,8 +108,7 @@ describe("account api", () => {
});

test("it fetches account resources with pagination", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const { resources, cursor } = await aptos.getAccountResourcesPage({
accountAddress: "0x1",
options: {
Expand All @@ -136,8 +130,7 @@ describe("account api", () => {
});

test("it fetches an account resource without a type", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const data = await aptos.getAccountResource({
accountAddress: "0x1",
resourceType: "0x1::account::Account",
Expand All @@ -149,8 +142,7 @@ describe("account api", () => {
});

test("it fetches an account resource typed", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
type AccountRes = {
authentication_key: string;
coin_register_events: {
Expand Down Expand Up @@ -186,8 +178,7 @@ describe("account api", () => {
});

test("it fetches account transactions", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const senderAccount = Account.generate();
await aptos.fundAccount({
accountAddress: senderAccount.accountAddress,
Expand Down Expand Up @@ -217,8 +208,7 @@ describe("account api", () => {
});

test("it fetches account transactions count", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const senderAccount = Account.generate();
const response = await aptos.fundAccount({
accountAddress: senderAccount.accountAddress,
Expand All @@ -233,8 +223,7 @@ describe("account api", () => {
});

test("it fetches account coins data", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const senderAccount = Account.generate();
const fundTxn = await aptos.fundAccount({
accountAddress: senderAccount.accountAddress,
Expand All @@ -250,8 +239,7 @@ describe("account api", () => {
});

test("it fetches account coins count", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const senderAccount = Account.generate();
const fundTxn = await aptos.fundAccount({
accountAddress: senderAccount.accountAddress,
Expand All @@ -266,8 +254,7 @@ describe("account api", () => {
});

test("it fetches account's coin amount", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const senderAccount = Account.generate();
const fundTxn = await aptos.fundAccount({
accountAddress: senderAccount.accountAddress,
Expand Down Expand Up @@ -317,8 +304,7 @@ describe("account api", () => {
});

test("it fetches account balance by coin type (APT)", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const account = Account.generate();

const fundTxn = await aptos.fundAccount({
Expand All @@ -335,8 +321,7 @@ describe("account api", () => {
});

test("it fetches account balance by FA metadata address (APT)", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const account = Account.generate();

const fundTxn = await aptos.fundAccount({
Expand All @@ -353,8 +338,7 @@ describe("account api", () => {
});

test("lookupOriginalAccountAddress - Look up account address before key rotation", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const account = Account.generate();

// Fund and create account on-chain
Expand All @@ -367,8 +351,7 @@ describe("account api", () => {
});

test("it fetches account owned token from collection", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const creator = Account.generate();
await aptos.fundAccount({ accountAddress: creator.accountAddress, amount: FUND_AMOUNT });
const collectionCreationTransaction = await aptos.createCollectionTransaction({
Expand Down Expand Up @@ -410,10 +393,7 @@ describe("account api", () => {
});

describe("it derives an account from a private key", () => {
const config = new AptosConfig({
network: Network.LOCAL,
});
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

test("single sender ed25519", async () => {
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: false });
Expand Down Expand Up @@ -459,8 +439,7 @@ describe("account api", () => {

describe("Key Rotation", () => {
test("it should rotate ed25519 to ed25519 auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
Expand Down Expand Up @@ -491,8 +470,7 @@ describe("account api", () => {
}, 10000);

test("it should rotate ed25519 to multi-ed25519 auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
Expand Down Expand Up @@ -530,8 +508,7 @@ describe("account api", () => {
}, 10000);

test("it should rotate ed25519 to multikey auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
Expand Down Expand Up @@ -568,8 +545,7 @@ describe("account api", () => {
}, 10000);

test("it should rotate ed25519 to unverified auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
Expand Down Expand Up @@ -601,8 +577,7 @@ describe("account api", () => {
});

describe("Account Derivation APIs", () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();

const minterAccount = Account.generate();

Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/api/coin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { getAptosClient } from "../helper";

describe("coin", () => {
test("it generates a transfer coin transaction with AptosCoin coin type", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const sender = Account.generate();
const recipient = Account.generate();
await aptos.fundAccount({ accountAddress: sender.accountAddress, amount: FUND_AMOUNT });
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/api/keyless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

import {
Account,
Aptos,
AptosConfig,
FederatedKeylessAccount,
Groth16Zkp,
KeylessAccount,
ProofFetchStatus,
ZeroKnowledgeSig,
ZkProof,
ZkpVariant,
Network,
} from "../../../src";

import { FUND_AMOUNT, TRANSFER_AMOUNT } from "../../unit/helper";
import { getAptosClient } from "../helper";
import { EPHEMERAL_KEY_PAIR, simpleCoinTransactionHeler as simpleCoinTransactionHelper } from "../transaction/helper";

export const TEST_JWT_TOKENS = [
Expand Down Expand Up @@ -67,7 +69,9 @@ const KEYLESS_TEST_TIMEOUT = 12000;

describe("keyless api", () => {
const ephemeralKeyPair = EPHEMERAL_KEY_PAIR;
const { aptos } = getAptosClient();
// Keyless only works in devnet and others
const aptosConfig = new AptosConfig({ network: Network.DEVNET });
const aptos = new Aptos(aptosConfig);
const jwkAccount = Account.generate();

beforeEach(async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/api/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { AptosConfig, Aptos, Network } from "../../../src";
import { longTestTimeout } from "../../unit/helper";
import { getAptosClient } from "../helper";

describe("staking api", () => {
test(
Expand All @@ -26,8 +27,7 @@ describe("staking api", () => {
);

test("it returns 0 if the poolAddress does not exist", async () => {
const config = new AptosConfig({ network: Network.DEVNET });
const aptos = new Aptos(config);
const { aptos } = getAptosClient();
const badAddress = "0x12345678901234567850020dfd67646b1e46282999483e7064e70f02f7e12345";
const numDelegators = await aptos.getNumberOfDelegators({ poolAddress: badAddress });
expect(numDelegators).toBe(0);
Expand Down
26 changes: 13 additions & 13 deletions tests/e2e/api/verifySignatureAsync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
import {
Account,
AccountAddress,
AptosConfig,
Ed25519PrivateKey,
Secp256k1PrivateKey,
SigningSchemeInput,
MultiKey,
MultiKeyAccount,
Groth16Zkp,
KeylessAccount,
MultiEd25519Account,
MultiEd25519PublicKey,
KeylessAccount,
MultiKey,
MultiKeyAccount,
Network,
Secp256k1PrivateKey,
SigningSchemeInput,
ZeroKnowledgeSig,
ZkProof,
Groth16Zkp,
ZkpVariant,
ZeroKnowledgeSig,
} from "../../../src";

import {
ed25519,
secp256k1TestObject,
keylessTestObject,
EPHEMERAL_KEY_PAIR,
keylessTestObject,
secp256k1TestObject,
singleSignerED25519,
EXPIRED_EPHEMERAL_KEY_PAIR,
} from "../../unit/helper";
import { getAptosClient } from "../helper";

describe("verifySignatureAsync", () => {
const { aptos } = getAptosClient();
const aptosConfig = aptos.config;
// This can only run against a real network, so we'll make it devnet
const aptosConfig = new AptosConfig({ network: Network.DEVNET });

it("signs a message with single signer Secp256k1 scheme and verifies successfully", async () => {
const { privateKey: privateKeyBytes, address, signatureHex, messageEncoded, stringMessage } = secp256k1TestObject;
Expand Down
Loading