Skip to content

Commit

Permalink
[ans-test] Fix ANS test typing issues
Browse files Browse the repository at this point in the history
There were async functions that were being set to non-async functions
then being awaited.  That was very confusing, and this fixes it
  • Loading branch information
gregnazario committed Dec 1, 2023
1 parent 54877bf commit 434c0f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
21 changes: 15 additions & 6 deletions tests/e2e/ans/ans.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

import { Aptos, Network, Account, AnyRawTransaction, U8, AptosConfig, GetANSNameResponse } from "../../../src";
import {
Aptos,
Network,
Account,
AnyRawTransaction,
U8,
AptosConfig,
GetANSNameResponse,
CommittedTransactionResponse,
} from "../../../src";
import { isValidANSName } from "../../../src/internal/ans";
import { generateTransaction } from "../../../src/internal/transactionSubmission";
import { publishAnsContract } from "./publishANSContracts";
Expand All @@ -18,9 +27,9 @@ describe("ANS", () => {
expirationDate: number,
domainName: string,
subdomainName?: string,
) => void;
) => Promise<CommittedTransactionResponse>;

let changeRouterMode: (mode: 0 | 1) => void;
let changeRouterMode: (mode: 0 | 1) => Promise<CommittedTransactionResponse>;

const signAndSubmit = async (signer: Account, transaction: AnyRawTransaction) => {
const pendingTxn = await aptos.signAndSubmitTransaction({ transaction, signer });
Expand Down Expand Up @@ -466,7 +475,7 @@ describe("ANS", () => {
test("can renew a v2 name that is eligible for renewal", async () => {
const name = domainName;

changeRouterMode(1);
await changeRouterMode(1);

await signAndSubmit(
alice,
Expand All @@ -479,7 +488,7 @@ describe("ANS", () => {

// Change the expiration date of the name to be tomorrow
const newExpirationDate = Math.floor(new Date(Date.now() + 24 * 60 * 60 * 1000).valueOf() / 1000);
changeExpirationDate(1, newExpirationDate, name);
await changeExpirationDate(1, newExpirationDate, name);

await signAndSubmit(alice, await aptos.renewDomain({ name, sender: alice }));

Expand All @@ -493,7 +502,7 @@ describe("ANS", () => {
const tld = domainName;
const name = `${subdomainName}.${domainName}`;

changeRouterMode(1);
await changeRouterMode(1);

await signAndSubmit(
alice,
Expand Down
11 changes: 8 additions & 3 deletions tests/e2e/api/digitalAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ describe("DigitalAsset", () => {
recipient: digitalAssetReceiver.accountAddress,
});
const pendingTransaction = await aptos.signAndSubmitTransaction({ signer: creator, transaction });
await aptos.waitForTransaction({ transactionHash: pendingTransaction.hash });

const tokenData = (await aptos.getOwnedTokens({ ownerAddress: digitalAssetReceiver.accountAddress }))[0];
const committedTransaction = await aptos.waitForTransaction({ transactionHash: pendingTransaction.hash });

const tokenData = (
await aptos.getOwnedTokens({
ownerAddress: digitalAssetReceiver.accountAddress,
minimumLedgerVersion: BigInt(committedTransaction.version),
})
)[0];
expect(tokenData.token_data_id).toEqual(tokenAddress);
expect(tokenData.owner_address).toEqual(digitalAssetReceiver.accountAddress.toString());
});
Expand Down

0 comments on commit 434c0f5

Please sign in to comment.