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

Add account query tests #23

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Add account query tests #23

merged 1 commit into from
Oct 12, 2023

Conversation

0xmaayan
Copy link
Collaborator

Description

Add missing account query tests, a better test framework to come after
https://aptos-org.slack.com/archives/C04339KQNUC/p1697063710300629

Test Plan

 ✓ it fetches account transactions (912 ms)
 ✓ it fetches account transactions (1129 ms)
 ✓ it fetches account coins data (641 ms)
 ✓ it fetches account coins count (835 ms)

Related Links

@0xmaayan 0xmaayan requested a review from a team as a code owner October 11, 2023 23:41
Copy link
Contributor

@gregnazario gregnazario left a comment

Choose a reason for hiding this comment

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

Please update the one name so it differs

// TODO
// add account getTransactions tests once sdk v2 supports faucet (which needs transaction operation support)
import { Account, Aptos, AptosConfig, Network } from "../../../src";
import { U64 } from "../../../src/bcs/serializable/move-primitives";
Copy link
Contributor

Choose a reason for hiding this comment

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

With the exports this should all collapse! Hopefully everything will be easily accessible from one path.

Comment on lines +82 to +109
test("it fetches account transactions", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const senderAccount = Account.generate({ scheme: SigningScheme.Ed25519 });
await aptos.fundAccount({ accountAddress: senderAccount.accountAddress.toString(), amount: 1000000000 });
const bob = Account.generate({ scheme: SigningScheme.Ed25519 });
const rawTxn = await aptos.generateTransaction({
sender: senderAccount.accountAddress.toString(),
data: {
function: "0x1::aptos_account::transfer",
type_arguments: [],
arguments: [bob.accountAddress, new U64(10)],
},
});
const authenticator = aptos.signTransaction({
signer: senderAccount,
transaction: rawTxn,
});
const response = await aptos.submitTransaction({
transaction: rawTxn,
senderAuthenticator: authenticator,
});
const txn = await aptos.waitForTransaction({ txnHash: response.hash });
const accountTransactions = await aptos.getAccountTransactions({
accountAddress: senderAccount.accountAddress.toString(),
});
expect(accountTransactions[0]).toStrictEqual(txn);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We should put some of this stuff in a common place so that it can be a little more legible / add more white space

tests/e2e/api/account.test.ts Outdated Show resolved Hide resolved
@0xmaayan 0xmaayan merged commit 22c8d3c into main Oct 12, 2023
5 checks passed
@0xmaayan 0xmaayan deleted the account_query_tests branch October 12, 2023 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants