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

update: release all skipped tests #2395

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
49 changes: 22 additions & 27 deletions test/integration/AccountBalanceIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AccountBalanceQuery,
Status,
// TokenCreateTransaction,
TokenCreateTransaction,
} from "../../src/exports.js";
import IntegrationTestEnv, {
Client,
Expand Down Expand Up @@ -85,32 +85,27 @@ describe("AccountBalanceQuery", function () {
}
});

/**
*
* @description The test is temporarily commented because AccountBalanceQuery does a query to the consensus node which was deprecated.
* @todo Uncomment a test when the new query to the mirror node is implemented as it described here https://github.com/hashgraph/hedera-sdk-reference/issues/144
*/
// it("should reflect token with no keys", async function () {
// this.timeout(120000);

// const operatorId = env.operatorId;

// const token = (
// await (
// await new TokenCreateTransaction()
// .setTokenName("ffff")
// .setTokenSymbol("F")
// .setTreasuryAccountId(operatorId)
// .execute(env.client)
// ).getReceipt(env.client)
// ).tokenId;

// const balances = await new AccountBalanceQuery()
// .setAccountId(env.operatorId)
// .execute(env.client);

// expect(balances.tokens.get(token).toInt()).to.be.equal(0);
// });
it("should reflect token with no keys", async function () {
this.timeout(120000);

const operatorId = env.operatorId;

const token = (
await (
await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setTreasuryAccountId(operatorId)
.execute(env.client)
).getReceipt(env.client)
).tokenId;

const balances = await new AccountBalanceQuery()
.setAccountId(env.operatorId)
.execute(env.client);

expect(balances.tokens.get(token).toInt()).to.be.equal(0);
});

after(async function () {
clientPreviewNet.close();
Expand Down
61 changes: 28 additions & 33 deletions test/integration/AccountInfoIntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Hbar,
PrivateKey,
Status,
// TokenCreateTransaction,
TokenCreateTransaction,
TransactionId,
} from "../../src/exports.js";
import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js";
Expand Down Expand Up @@ -154,38 +154,33 @@ describe("AccountInfo", function () {
}
});

/**
*
* @description The test is temporarily commented because AccountInfoQuery does a query to the consensus node which was deprecated.
* @todo Uncomment a test when the new query to the mirror node is implemented as it described here https://github.com/hashgraph/hedera-sdk-reference/issues/144
*/
// it("should reflect token with no keys", async function () {
// this.timeout(120000);

// const operatorId = env.operatorId;

// const token = (
// await (
// await new TokenCreateTransaction()
// .setTokenName("ffff")
// .setTokenSymbol("F")
// .setTreasuryAccountId(operatorId)
// .execute(env.client)
// ).getReceipt(env.client)
// ).tokenId;

// const info = await new AccountInfoQuery()
// .setAccountId(operatorId)
// .execute(env.client);

// const relationship = info.tokenRelationships.get(token);

// expect(relationship).to.be.not.null;
// expect(relationship.tokenId.toString()).to.be.equal(token.toString());
// expect(relationship.balance.toInt()).to.be.equal(0);
// expect(relationship.isKycGranted).to.be.null;
// expect(relationship.isFrozen).to.be.null;
// });
it("should reflect token with no keys", async function () {
this.timeout(120000);

const operatorId = env.operatorId;

const token = (
await (
await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setTreasuryAccountId(operatorId)
.execute(env.client)
).getReceipt(env.client)
).tokenId;

const info = await new AccountInfoQuery()
.setAccountId(operatorId)
.execute(env.client);

const relationship = info.tokenRelationships.get(token);

expect(relationship).to.be.not.null;
expect(relationship.tokenId.toString()).to.be.equal(token.toString());
expect(relationship.balance.toInt()).to.be.equal(0);
expect(relationship.isKycGranted).to.be.null;
expect(relationship.isFrozen).to.be.null;
});

it("should be error with no account ID", async function () {
this.timeout(120000);
Expand Down
135 changes: 65 additions & 70 deletions test/integration/TokenAssociateIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
// AccountBalanceQuery,
// AccountCreateTransaction,
// AccountInfoQuery,
// Hbar,
// PrivateKey,
AccountBalanceQuery,
AccountCreateTransaction,
AccountInfoQuery,
Hbar,
PrivateKey,
Status,
TokenAssociateTransaction,
TokenCreateTransaction,
Expand All @@ -17,71 +17,66 @@ describe("TokenAssociate", function () {
env = await IntegrationTestEnv.new();
});

/**
*
* @description The test is temporarily commented because AccountBalanceQuery does a query to the consensus node which was deprecated.
* @todo Uncomment a test when the new query to the mirror node is implemented as it described here https://github.com/hashgraph/hedera-sdk-reference/issues/144
*/
// it("should be executable", async function () {
// this.timeout(120000);

// const operatorId = env.operatorId;
// const operatorKey = env.operatorKey.publicKey;
// const key = PrivateKey.generateED25519();

// const response = await new AccountCreateTransaction()
// .setKey(key)
// .setInitialBalance(new Hbar(2))
// .execute(env.client);

// const account = (await response.getReceipt(env.client)).accountId;

// const token = (
// await (
// await new TokenCreateTransaction()
// .setTokenName("ffff")
// .setTokenSymbol("F")
// .setDecimals(3)
// .setInitialSupply(1000000)
// .setTreasuryAccountId(operatorId)
// .setAdminKey(operatorKey)
// .setKycKey(operatorKey)
// .setFreezeKey(operatorKey)
// .setWipeKey(operatorKey)
// .setSupplyKey(operatorKey)
// .setFreezeDefault(false)
// .execute(env.client)
// ).getReceipt(env.client)
// ).tokenId;

// await (
// await (
// await new TokenAssociateTransaction()
// .setTokenIds([token])
// .setAccountId(account)
// .freezeWith(env.client)
// .sign(key)
// ).execute(env.client)
// ).getReceipt(env.client);

// const balances = await new AccountBalanceQuery()
// .setAccountId(account)
// .execute(env.client);

// expect(balances.tokens.get(token).toInt()).to.be.equal(0);

// const info = await new AccountInfoQuery()
// .setAccountId(account)
// .execute(env.client);

// const relationship = info.tokenRelationships.get(token);

// expect(relationship).to.be.not.null;
// expect(relationship.tokenId.toString()).to.be.equal(token.toString());
// expect(relationship.balance.toInt()).to.be.equal(0);
// expect(relationship.isKycGranted).to.be.false;
// expect(relationship.isFrozen).to.be.false;
// });
it("should be executable", async function () {
this.timeout(120000);

const operatorId = env.operatorId;
const operatorKey = env.operatorKey.publicKey;
const key = PrivateKey.generateED25519();

const response = await new AccountCreateTransaction()
.setKey(key)
.setInitialBalance(new Hbar(2))
.execute(env.client);

const account = (await response.getReceipt(env.client)).accountId;

const token = (
await (
await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setDecimals(3)
.setInitialSupply(1000000)
.setTreasuryAccountId(operatorId)
.setAdminKey(operatorKey)
.setKycKey(operatorKey)
.setFreezeKey(operatorKey)
.setWipeKey(operatorKey)
.setSupplyKey(operatorKey)
.setFreezeDefault(false)
.execute(env.client)
).getReceipt(env.client)
).tokenId;

await (
await (
await new TokenAssociateTransaction()
.setTokenIds([token])
.setAccountId(account)
.freezeWith(env.client)
.sign(key)
).execute(env.client)
).getReceipt(env.client);

const balances = await new AccountBalanceQuery()
.setAccountId(account)
.execute(env.client);

expect(balances.tokens.get(token).toInt()).to.be.equal(0);

const info = await new AccountInfoQuery()
.setAccountId(account)
.execute(env.client);

const relationship = info.tokenRelationships.get(token);

expect(relationship).to.be.not.null;
expect(relationship.tokenId.toString()).to.be.equal(token.toString());
expect(relationship.balance.toInt()).to.be.equal(0);
expect(relationship.isKycGranted).to.be.false;
expect(relationship.isFrozen).to.be.false;
});

it("should be executable even when no token IDs are set", async function () {
this.timeout(120000);
Expand Down
98 changes: 46 additions & 52 deletions test/integration/TokenBurnIntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TokenCreateTransaction,
TokenSupplyType,
TokenType,
// AccountBalanceQuery,
AccountBalanceQuery,
} from "../../src/exports.js";
import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js";

Expand Down Expand Up @@ -64,58 +64,52 @@ describe("TokenBurn", function () {
throw new Error("token Burn did not error");
}
});
it("should not error when amount is not set", async function () {
this.timeout(120000);

const operatorId = env.operatorId;
const operatorKey = env.operatorKey.publicKey;

const response = await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setDecimals(3)
.setInitialSupply(1000000)
.setTreasuryAccountId(operatorId)
.setAdminKey(operatorKey)
.setKycKey(operatorKey)
.setFreezeKey(operatorKey)
.setWipeKey(operatorKey)
.setSupplyKey(operatorKey)
.setFreezeDefault(false)
.execute(env.client);

/**
*
* @description The test is temporarily commented because AccountBalanceQuery does a query to the consensus node which was deprecated.
* @todo Uncomment a test when the new query to the mirror node is implemented as it described here https://github.com/hashgraph/hedera-sdk-reference/issues/144
*/
// it("should not error when amount is not set", async function () {
// this.timeout(120000);

// const operatorId = env.operatorId;
// const operatorKey = env.operatorKey.publicKey;

// const response = await new TokenCreateTransaction()
// .setTokenName("ffff")
// .setTokenSymbol("F")
// .setDecimals(3)
// .setInitialSupply(1000000)
// .setTreasuryAccountId(operatorId)
// .setAdminKey(operatorKey)
// .setKycKey(operatorKey)
// .setFreezeKey(operatorKey)
// .setWipeKey(operatorKey)
// .setSupplyKey(operatorKey)
// .setFreezeDefault(false)
// .execute(env.client);

// const token = (await response.getReceipt(env.client)).tokenId;

// let err = false;

// try {
// await (
// await new TokenBurnTransaction()
// .setTokenId(token)
// .execute(env.client)
// ).getReceipt(env.client);
// } catch (error) {
// err = error;
// }

// const accountBalance = await new AccountBalanceQuery()
// .setAccountId(operatorId)
// .execute(env.client);

// expect(
// accountBalance.tokens._map.get(token.toString()).toNumber(),
// ).to.be.equal(1000000);

// if (err) {
// throw new Error("token burn did error");
// }
// });
const token = (await response.getReceipt(env.client)).tokenId;

let err = false;

try {
await (
await new TokenBurnTransaction()
.setTokenId(token)
.execute(env.client)
).getReceipt(env.client);
} catch (error) {
err = error;
}

const accountBalance = await new AccountBalanceQuery()
.setAccountId(operatorId)
.execute(env.client);

expect(
accountBalance.tokens._map.get(token.toString()).toNumber(),
).to.be.equal(1000000);

if (err) {
throw new Error("token burn did error");
}
});

it("cannot burn token with invalid metadata", async function () {
this.timeout(120000);
Expand Down
Loading