Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use test constants keys/function address #14

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 16 additions & 15 deletions tests/e2e/api/transaction_submission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
TransactionPayloadScript,
} from "../../../src/transactions/instances/transactionPayload";
import { SigningScheme } from "../../../src/types";
import { ALICE_PRIVATE_KEY, BOB_PRIVATE_KEY, TRANSFER_FUNCTION_ADDRESS } from "../../utils/const";

describe("transaction submission", () => {
describe("generateTransaction", () => {
Expand All @@ -26,7 +27,7 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests are going to change. We now test it against devnet and eventually will change it to run against localnet. We had these fix accounts because we couldn't use the fund query so we fund it using the cli and "created" it on devnet.
We will probably not use any fix private keys to create an account but create and fund it on run time

}),
});
const rawTxn = await aptos.generateTransaction({
Expand All @@ -49,15 +50,15 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const rawTxn = await aptos.generateTransaction({
sender: alice.accountAddress.toString(),
data: {
multisigAddress: bob.accountAddress,
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
},
Expand All @@ -74,14 +75,14 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const rawTxn = await aptos.generateTransaction({
sender: alice.accountAddress.toString(),
data: {
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
},
Expand All @@ -99,12 +100,12 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924",
hexInput: BOB_PRIVATE_KEY,
}),
});
const rawTxn = await aptos.generateTransaction({
Expand Down Expand Up @@ -138,7 +139,7 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const rawTxn = await aptos.generateTransaction({
Expand All @@ -164,15 +165,15 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const rawTxn = await aptos.generateTransaction({
sender: alice.accountAddress.toString(),
data: {
multisigAddress: bob.accountAddress,
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
},
Expand All @@ -192,14 +193,14 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const rawTxn = await aptos.generateTransaction({
sender: alice.accountAddress.toString(),
data: {
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
},
Expand All @@ -220,12 +221,12 @@ describe("transaction submission", () => {
const aptos = new Aptos(config);
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924",
hexInput: BOB_PRIVATE_KEY,
}),
});
const rawTxn = await aptos.generateTransaction({
Expand Down Expand Up @@ -282,7 +283,7 @@ describe("transaction submission", () => {
const rawTxn = await aptos.generateTransaction({
sender: alice.accountAddress.toString(),
data: {
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
},
Expand Down
61 changes: 31 additions & 30 deletions tests/unit/transaction_builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Network } from "../../src/utils/apiEndpoints";
import { SignedTransaction } from "../../src/transactions/instances/signedTransaction";
import { U64 } from "../../src/bcs/serializable/move-primitives";
import { MoveObject } from "../../src/bcs/serializable/move-structs";
import { ALICE_PRIVATE_KEY, TRANSFER_FUNCTION_ADDRESS } from "../utils/const";

describe("transaction builder", () => {
describe("generate transaction payload", () => {
Expand All @@ -51,15 +52,15 @@ describe("transaction builder", () => {
test("it generates a multi sig transaction payload", async () => {
const payload = generateTransactionPayload({
multisigAddress: Account.generate({ scheme: SigningScheme.Ed25519 }).accountAddress,
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [],
});
expect(payload instanceof TransactionPayloadMultisig).toBeTruthy();
});
test("it generates an entry function transaction payload", async () => {
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [],
});
Expand All @@ -71,7 +72,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const payload = generateTransactionPayload({
Expand Down Expand Up @@ -99,13 +100,13 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
multisigAddress: bob.accountAddress,
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -122,12 +123,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -145,7 +146,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const payload = generateTransactionPayload({
Expand Down Expand Up @@ -174,12 +175,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -205,12 +206,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -231,12 +232,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand Down Expand Up @@ -266,7 +267,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const payload = generateTransactionPayload({
Expand Down Expand Up @@ -302,7 +303,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const payload = generateTransactionPayload({
Expand Down Expand Up @@ -336,13 +337,13 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
multisigAddress: bob.accountAddress,
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -368,7 +369,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
Expand Down Expand Up @@ -405,7 +406,7 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const payload = generateTransactionPayload({
Expand Down Expand Up @@ -440,12 +441,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand Down Expand Up @@ -477,12 +478,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand Down Expand Up @@ -515,12 +516,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -537,12 +538,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand All @@ -563,12 +564,12 @@ describe("transaction builder", () => {
const config = new AptosConfig({ network: Network.DEVNET });
const alice = Account.fromPrivateKey({
privateKey: new Ed25519PrivateKey({
hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c",
hexInput: ALICE_PRIVATE_KEY,
}),
});
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const payload = generateTransactionPayload({
function: "0x1::aptos_account::transfer",
function: TRANSFER_FUNCTION_ADDRESS,
type_arguments: [],
arguments: [new MoveObject(bob.accountAddress), new U64(1)],
});
Expand Down
3 changes: 3 additions & 0 deletions tests/utils/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const ALICE_PRIVATE_KEY = "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c"
export const BOB_PRIVATE_KEY = "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924"
export const TRANSFER_FUNCTION_ADDRESS = "0x1::aptos_account::transfer"
Loading