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 local network with tests #26

Merged
merged 1 commit into from
Oct 13, 2023
Merged

Use local network with tests #26

merged 1 commit into from
Oct 13, 2023

Conversation

0xmaayan
Copy link
Collaborator

Description

Change tall tests to use local network.
@banool do we need docker in CI?

There is a latency chance when querying indexer right after we submit a transaction, therefore adding sleep(100) - can think about a different approach for our test framework we want to have or in a following PR.

Test Plan

 PASS  tests/unit/account.test.ts
 PASS  tests/unit/ed25519.test.ts
 PASS  tests/e2e/api/general.test.ts
 PASS  tests/e2e/api/faucet.test.ts
 PASS  tests/unit/memoize.test.ts
 PASS  tests/unit/secp256k1.test.ts
 PASS  tests/unit/bcs-helper.test.ts
 PASS  tests/unit/aptos_config.test.ts
 PASS  tests/unit/multi_ed25519.test.ts
 PASS  tests/unit/type_tag.test.ts
 PASS  tests/unit/account_address.test.ts
 PASS  tests/unit/serializer.test.ts
 PASS  tests/unit/script_transaction_arguments.test.ts
 PASS  tests/unit/hex.test.ts
 PASS  tests/unit/authentication_key.test.ts
 PASS  tests/unit/deserializer.test.ts
 PASS  tests/e2e/api/transaction.test.ts (5.712 s)
 PASS  tests/e2e/api/coin.test.ts (7.394 s)
 PASS  tests/e2e/api/account.test.ts (9.325 s)
 PASS  tests/e2e/api/transaction_submission.test.ts (10.225 s)
 PASS  tests/unit/transaction_builder.test.ts (13.372 s)

Related Links

@xbtmatt
Copy link
Contributor

xbtmatt commented Oct 12, 2023

This is so great, huge props again to @banool !!

Copy link
Contributor

@xbtmatt xbtmatt left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

My comments are all about making sure this code is maintainable. Need to follow up with it.

const accountCoinData = await aptos.getAccountCoinsData({
accountAddress: senderAccount.accountAddress.toString(),
});
expect(accountCoinData[0].amount).toBe(100000000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should move to a constant, maybe even a default fund amount, at least for testing

Comment on lines +69 to +70
// to help with indexer latency
await sleep(1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

:(

Copy link
Contributor

Choose a reason for hiding this comment

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

Summarizing what I said in Slack, it'd be better to look at the txn version from the committed txn output and then wait for the indexer to catch up to that version by querying the processor status. That'd have the least latency and be fully reliable.

Comment on lines +505 to +508
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
const alice = Account.generate({ scheme: SigningScheme.Ed25519 });
await aptos.fundAccount({ accountAddress: alice.accountAddress.toString(), amount: 1000000000 });
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 probably at a minimum put this duplicated code in a function

@banool banool merged commit 41047d1 into main Oct 13, 2023
4 of 5 checks passed
@banool banool deleted the use_localnet_on_tests branch October 13, 2023 03:15
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.

4 participants