From 064fd775050c0e16b27c210b64eec5477da40b61 Mon Sep 17 00:00:00 2001 From: svetoslav-nikol0v Date: Tue, 9 Jul 2024 14:47:17 +0300 Subject: [PATCH] update: release all skipped tests Signed-off-by: svetoslav-nikol0v --- .../AccountBalanceIntegrationTest.js | 49 ++--- .../integration/AccountInfoIntegrationTest.js | 61 +++--- .../TokenAssociateIntegrationTest.js | 135 ++++++------- test/integration/TokenBurnIntegrationTest.js | 98 +++++---- .../TokenDissociateIntegrationTest.js | 175 ++++++++-------- .../integration/TokenFreezeIntegrationTest.js | 137 ++++++------- .../TokenGrantKycIntegrationTest.js | 137 ++++++------- .../TokenRevokeKycIntegrationTest.js | 183 ++++++++--------- .../TokenUnfreezeIntegrationTest.js | 183 ++++++++--------- test/integration/TokenWipeIntegrationTest.js | 191 +++++++++--------- .../client/BaseIntegrationTestEnv.js | 2 +- 11 files changed, 650 insertions(+), 701 deletions(-) diff --git a/test/integration/AccountBalanceIntegrationTest.js b/test/integration/AccountBalanceIntegrationTest.js index f2be8c9ca..28f994f04 100644 --- a/test/integration/AccountBalanceIntegrationTest.js +++ b/test/integration/AccountBalanceIntegrationTest.js @@ -1,7 +1,7 @@ import { AccountBalanceQuery, Status, - // TokenCreateTransaction, + TokenCreateTransaction, } from "../../src/exports.js"; import IntegrationTestEnv, { Client, @@ -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(); diff --git a/test/integration/AccountInfoIntegrationTest.js b/test/integration/AccountInfoIntegrationTest.js index ea6cfbbd5..4ee2a083e 100644 --- a/test/integration/AccountInfoIntegrationTest.js +++ b/test/integration/AccountInfoIntegrationTest.js @@ -5,7 +5,7 @@ import { Hbar, PrivateKey, Status, - // TokenCreateTransaction, + TokenCreateTransaction, TransactionId, } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; @@ -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); diff --git a/test/integration/TokenAssociateIntegrationTest.js b/test/integration/TokenAssociateIntegrationTest.js index 020813a07..56bfe956b 100644 --- a/test/integration/TokenAssociateIntegrationTest.js +++ b/test/integration/TokenAssociateIntegrationTest.js @@ -1,9 +1,9 @@ import { - // AccountBalanceQuery, - // AccountCreateTransaction, - // AccountInfoQuery, - // Hbar, - // PrivateKey, + AccountBalanceQuery, + AccountCreateTransaction, + AccountInfoQuery, + Hbar, + PrivateKey, Status, TokenAssociateTransaction, TokenCreateTransaction, @@ -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); diff --git a/test/integration/TokenBurnIntegrationTest.js b/test/integration/TokenBurnIntegrationTest.js index 5c7fae214..4cfc76019 100644 --- a/test/integration/TokenBurnIntegrationTest.js +++ b/test/integration/TokenBurnIntegrationTest.js @@ -4,7 +4,7 @@ import { TokenCreateTransaction, TokenSupplyType, TokenType, - // AccountBalanceQuery, + AccountBalanceQuery, } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; @@ -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); diff --git a/test/integration/TokenDissociateIntegrationTest.js b/test/integration/TokenDissociateIntegrationTest.js index 5b1e29414..92916b3a3 100644 --- a/test/integration/TokenDissociateIntegrationTest.js +++ b/test/integration/TokenDissociateIntegrationTest.js @@ -1,8 +1,8 @@ import { - // AccountBalanceQuery, + AccountBalanceQuery, AccountCreateTransaction, - // AccountInfoQuery, - // Hbar, + AccountInfoQuery, + Hbar, PrivateKey, Status, TokenAssociateTransaction, @@ -23,93 +23,88 @@ describe("TokenDissociate", 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); - - // let balances = await new AccountBalanceQuery() - // .setAccountId(account) - // .execute(env.client); - - // expect(balances.tokens.get(token).toInt()).to.be.equal(0); - - // let 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; - - // await ( - // await ( - // await new TokenDissociateTransaction() - // .setTokenIds([token]) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // balances = await new AccountBalanceQuery() - // .setAccountId(account) - // .execute(env.client); - - // expect(balances.tokens.get(token)).to.be.null; - - // info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // expect(info.tokenRelationships.get(token)).to.be.null; - // }); + 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); + + let balances = await new AccountBalanceQuery() + .setAccountId(account) + .execute(env.client); + + expect(balances.tokens.get(token).toInt()).to.be.equal(0); + + let 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; + + await ( + await ( + await new TokenDissociateTransaction() + .setTokenIds([token]) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + balances = await new AccountBalanceQuery() + .setAccountId(account) + .execute(env.client); + + expect(balances.tokens.get(token)).to.be.null; + + info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + expect(info.tokenRelationships.get(token)).to.be.null; + }); it("should be executable even when no token IDs are set", async function () { this.timeout(120000); diff --git a/test/integration/TokenFreezeIntegrationTest.js b/test/integration/TokenFreezeIntegrationTest.js index f35aed9b6..48af381af 100644 --- a/test/integration/TokenFreezeIntegrationTest.js +++ b/test/integration/TokenFreezeIntegrationTest.js @@ -1,10 +1,10 @@ import { AccountCreateTransaction, - // AccountInfoQuery, + AccountInfoQuery, Hbar, PrivateKey, Status, - // TokenAssociateTransaction, + TokenAssociateTransaction, TokenCreateTransaction, TokenFreezeTransaction, } from "../../src/exports.js"; @@ -17,75 +17,70 @@ describe("TokenFreeze", function () { env = await IntegrationTestEnv.new(); }); - /** - * - * @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 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); - - // await ( - // await ( - // await new TokenFreezeTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // 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.true; - // }); + 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); + + await ( + await ( + await new TokenFreezeTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + 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.true; + }); it("should be executable with no tokens set", async function () { this.timeout(120000); diff --git a/test/integration/TokenGrantKycIntegrationTest.js b/test/integration/TokenGrantKycIntegrationTest.js index 2fa40851b..5355b2058 100644 --- a/test/integration/TokenGrantKycIntegrationTest.js +++ b/test/integration/TokenGrantKycIntegrationTest.js @@ -1,10 +1,10 @@ import { AccountCreateTransaction, - // AccountInfoQuery, + AccountInfoQuery, Hbar, PrivateKey, Status, - // TokenAssociateTransaction, + TokenAssociateTransaction, TokenCreateTransaction, TokenGrantKycTransaction, } from "../../src/exports.js"; @@ -17,75 +17,70 @@ describe("TokenGrantKyc", function () { env = await IntegrationTestEnv.new(); }); - /** - * - * @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 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); - - // await ( - // await ( - // await new TokenGrantKycTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // 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.true; - // 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); + + await ( + await ( + await new TokenGrantKycTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + 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.true; + expect(relationship.isFrozen).to.be.false; + }); it("should be executable even when no token IDs are set", async function () { this.timeout(120000); diff --git a/test/integration/TokenRevokeKycIntegrationTest.js b/test/integration/TokenRevokeKycIntegrationTest.js index d1023d9fa..8bbe25881 100644 --- a/test/integration/TokenRevokeKycIntegrationTest.js +++ b/test/integration/TokenRevokeKycIntegrationTest.js @@ -1,12 +1,12 @@ import { AccountCreateTransaction, - // AccountInfoQuery, + AccountInfoQuery, Hbar, PrivateKey, Status, - // TokenAssociateTransaction, + TokenAssociateTransaction, TokenCreateTransaction, - // TokenGrantKycTransaction, + TokenGrantKycTransaction, TokenRevokeKycTransaction, } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; @@ -18,97 +18,92 @@ describe("TokenRevokeKyc", function () { env = await IntegrationTestEnv.new(); }); - /** - * - * @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 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); - - // await ( - // await ( - // await new TokenGrantKycTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // let info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // let 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.true; - // expect(relationship.isFrozen).to.be.false; - - // await ( - // await ( - // await new TokenRevokeKycTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // 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); + + await ( + await ( + await new TokenGrantKycTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + let info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + let 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.true; + expect(relationship.isFrozen).to.be.false; + + await ( + await ( + await new TokenRevokeKycTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + 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); diff --git a/test/integration/TokenUnfreezeIntegrationTest.js b/test/integration/TokenUnfreezeIntegrationTest.js index ec4390e8f..81a841d37 100644 --- a/test/integration/TokenUnfreezeIntegrationTest.js +++ b/test/integration/TokenUnfreezeIntegrationTest.js @@ -1,12 +1,12 @@ import { AccountCreateTransaction, - // AccountInfoQuery, + AccountInfoQuery, Hbar, PrivateKey, Status, - // TokenAssociateTransaction, + TokenAssociateTransaction, TokenCreateTransaction, - // TokenFreezeTransaction, + TokenFreezeTransaction, TokenUnfreezeTransaction, } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; @@ -18,97 +18,92 @@ describe("TokenUnfreeze", function () { env = await IntegrationTestEnv.new(); }); - /** - * - * @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 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); - - // await ( - // await ( - // await new TokenFreezeTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // let info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // let 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.true; - - // await ( - // await ( - // await new TokenUnfreezeTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // 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); + + await ( + await ( + await new TokenFreezeTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + let info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + let 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.true; + + await ( + await ( + await new TokenUnfreezeTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + 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); diff --git a/test/integration/TokenWipeIntegrationTest.js b/test/integration/TokenWipeIntegrationTest.js index f31d05bc7..5d66b8e98 100644 --- a/test/integration/TokenWipeIntegrationTest.js +++ b/test/integration/TokenWipeIntegrationTest.js @@ -1,6 +1,6 @@ import { AccountCreateTransaction, - // AccountInfoQuery, + AccountInfoQuery, Hbar, PrivateKey, Status, @@ -8,7 +8,7 @@ import { TokenCreateTransaction, TokenGrantKycTransaction, TokenWipeTransaction, - // TransferTransaction, + TransferTransaction, Transaction, } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; @@ -21,102 +21,97 @@ describe("TokenWipe", function () { env = await IntegrationTestEnv.new(); }); - /** - * - * @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 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); - - // await ( - // await ( - // await new TokenGrantKycTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .freezeWith(env.client) - // .sign(key) - // ).execute(env.client) - // ).getReceipt(env.client); - - // await ( - // await new TransferTransaction() - // .addTokenTransfer(token, account, 10) - // .addTokenTransfer(token, env.operatorId, -10) - // .execute(env.client) - // ).getReceipt(env.client); - - // let info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // let 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(10); - // expect(relationship.isKycGranted).to.be.true; - // expect(relationship.isFrozen).to.be.false; - - // await ( - // await new TokenWipeTransaction() - // .setTokenId(token) - // .setAccountId(account) - // .setAmount(10) - // .execute(env.client) - // ).getReceipt(env.client); - - // info = await new AccountInfoQuery() - // .setAccountId(account) - // .execute(env.client); - - // 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.true; - // 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); + + await ( + await ( + await new TokenGrantKycTransaction() + .setTokenId(token) + .setAccountId(account) + .freezeWith(env.client) + .sign(key) + ).execute(env.client) + ).getReceipt(env.client); + + await ( + await new TransferTransaction() + .addTokenTransfer(token, account, 10) + .addTokenTransfer(token, env.operatorId, -10) + .execute(env.client) + ).getReceipt(env.client); + + let info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + let 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(10); + expect(relationship.isKycGranted).to.be.true; + expect(relationship.isFrozen).to.be.false; + + await ( + await new TokenWipeTransaction() + .setTokenId(token) + .setAccountId(account) + .setAmount(10) + .execute(env.client) + ).getReceipt(env.client); + + info = await new AccountInfoQuery() + .setAccountId(account) + .execute(env.client); + + 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.true; + expect(relationship.isFrozen).to.be.false; + }); it("should error when token ID is not set", async function () { this.timeout(120000); diff --git a/test/integration/client/BaseIntegrationTestEnv.js b/test/integration/client/BaseIntegrationTestEnv.js index 5a0c4d0c9..723d8d6c3 100644 --- a/test/integration/client/BaseIntegrationTestEnv.js +++ b/test/integration/client/BaseIntegrationTestEnv.js @@ -92,7 +92,7 @@ export default class BaseIntegrationTestEnv { options.env.OPERATOR_KEY != null ) { const operatorId = AccountId.fromString(options.env.OPERATOR_ID); - const operatorKey = PrivateKey.fromStringDer(options.env.OPERATOR_KEY); + const operatorKey = PrivateKey.fromStringED25519(options.env.OPERATOR_KEY); client.setOperator(operatorId, operatorKey); }