From f6cc669de565b03f92b015b677b730dc6d762b7b Mon Sep 17 00:00:00 2001 From: svetoslav-nikol0v Date: Thu, 18 Apr 2024 16:51:50 +0300 Subject: [PATCH] chore: formatting Signed-off-by: svetoslav-nikol0v --- .../integration/TokenUpdateIntegrationTest.js | 293 ++++++++++-------- 1 file changed, 160 insertions(+), 133 deletions(-) diff --git a/test/integration/TokenUpdateIntegrationTest.js b/test/integration/TokenUpdateIntegrationTest.js index 05f9e0972..65ee48431 100644 --- a/test/integration/TokenUpdateIntegrationTest.js +++ b/test/integration/TokenUpdateIntegrationTest.js @@ -14,7 +14,7 @@ import { } from "../../src/exports.js"; import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; -describe.only("TokenUpdate", function () { +describe("TokenUpdate", function () { let env; before(async function () { @@ -453,13 +453,13 @@ describe.only("TokenUpdate", function () { describe("[HIP-646] Fungible Token Metadata Field", function () { it("should update the metadata of token after signing the transaction with metadata key", async function () { this.timeout(120000); - + let tokenInfo; const operatorId = env.operatorId; const metadataKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -469,43 +469,47 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setMetadata(metadata) .setMetadataKey(metadataKey); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(metadataKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(metadataKey) + ).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); - + it("should update the metadata of token after signing the transaction with admin key", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const adminKey = env.operatorKey; const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -515,42 +519,44 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setAdminKey(adminKey) .setMetadata(metadata); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); it("should NOT update the metadata of token when the new metadata is NOT set", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const adminKey = env.operatorKey; const metadata = new Uint8Array([1]); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -560,42 +566,44 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setAdminKey(adminKey) .setMetadata(metadata); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(metadata); }); it("should earse the metadata of token after signing the transaction with metadata key", async function () { this.timeout(120000); - + let tokenInfo; const operatorId = env.operatorId; const metadataKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array(); - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -605,43 +613,47 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setMetadata(metadata) .setMetadataKey(metadataKey); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(metadataKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(metadataKey) + ).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); - + it("should earse the metadata of token after signing the transaction with admin key", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const adminKey = env.operatorKey; const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array(); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -651,38 +663,39 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setMetadata(metadata) .setAdminKey(adminKey); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); - it("should NOT update the metadata of token when the transaction is not signed with metadata or admin key", async function () { this.timeout(120000); - + let status; const operatorId = env.operatorId; const adminKey = PrivateKey.generateED25519(); @@ -690,7 +703,7 @@ describe.only("TokenUpdate", function () { const wrongKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + try { const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") @@ -702,22 +715,23 @@ describe.only("TokenUpdate", function () { .setAdminKey(adminKey) .setMetadata(metadata) .setMetadataKey(metadataKey); - + const tokenCreateTxresponse = await tokenCreateTx.execute( env.client, ); - const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( - env.client, - ); + const tokenCreateTxReceipt = + await tokenCreateTxresponse.getReceipt(env.client); const tokenId = tokenCreateTxReceipt.tokenId; - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(wrongKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(wrongKey) + ).execute(env.client) ).getReceipt(env.client); } catch (error) { status = error.status; @@ -727,12 +741,12 @@ describe.only("TokenUpdate", function () { it("should NOT update the metadata of token if the metadata or admin keys are NOT set", async function () { this.timeout(120000); - + let status; const operatorId = env.operatorId; const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + try { const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") @@ -742,20 +756,19 @@ describe.only("TokenUpdate", function () { .setInitialSupply(1000000) .setTreasuryAccountId(operatorId) .setMetadata(metadata); - + const tokenCreateTxresponse = await tokenCreateTx.execute( env.client, ); - const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( - env.client, - ); + const tokenCreateTxReceipt = + await tokenCreateTxresponse.getReceipt(env.client); const tokenId = tokenCreateTxReceipt.tokenId; - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await tokenUpdateTx.execute(env.client) ).getReceipt(env.client); @@ -769,14 +782,14 @@ describe.only("TokenUpdate", function () { describe("[HIP-765] Non Fungible Token Metadata Field", function () { it("should update the metadata of token after signing the transaction with metadata key", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const metadataKey = PrivateKey.generateED25519(); const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -785,44 +798,48 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setMetadata(metadata) .setMetadataKey(metadataKey); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(metadataKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(metadataKey) + ).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); it("should update the metadata of token after signing the transaction with admin key", async function () { this.timeout(120000); - + let tokenInfo; const operatorId = env.operatorId; const adminKey = env.operatorKey; const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -831,43 +848,45 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setAdminKey(adminKey) .setMetadata(metadata); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); it("should NOT update the metadata of token when the new metadata is NOT set", async function () { this.timeout(120000); - + let tokenInfo; const operatorId = env.operatorId; const adminKey = env.operatorKey; const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -876,43 +895,45 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setAdminKey(adminKey) .setMetadata(metadata); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(metadata); }); it("should earse the metadata of token after signing the transaction with metadata key", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const metadataKey = PrivateKey.generateED25519(); const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array(); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -921,44 +942,48 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setMetadata(metadata) .setMetadataKey(metadataKey); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(metadataKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(metadataKey) + ).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); - + it("should earse the metadata of token after signing the transaction with admin key", async function () { this.timeout(120000); - + const operatorId = env.operatorId; const adminKey = env.operatorKey; const suppyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array(); let tokenInfo; - + const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") .setTokenSymbol("T") @@ -967,37 +992,39 @@ describe.only("TokenUpdate", function () { .setTreasuryAccountId(operatorId) .setAdminKey(adminKey) .setMetadata(metadata); - - const tokenCreateTxresponse = await tokenCreateTx.execute(env.client); + + const tokenCreateTxresponse = await tokenCreateTx.execute( + env.client, + ); const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( env.client, ); const tokenId = tokenCreateTxReceipt.tokenId; - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); expect(tokenInfo.metadata).to.eql(metadata); - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await (await tokenUpdateTx.sign(adminKey)).execute(env.client) ).getReceipt(env.client); - + tokenInfo = await new TokenInfoQuery() .setTokenId(tokenId) .execute(env.client); - + expect(tokenInfo.metadata).to.eql(newMetadata); }); it("should NOT update the metadata of token when the transaction is not signed with metadata or admin key", async function () { this.timeout(120000); - + let status; const operatorId = env.operatorId; const adminKey = PrivateKey.generateED25519(); @@ -1006,7 +1033,7 @@ describe.only("TokenUpdate", function () { const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + try { const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") @@ -1017,22 +1044,23 @@ describe.only("TokenUpdate", function () { .setAdminKey(adminKey) .setMetadata(metadata) .setMetadataKey(metadataKey); - + const tokenCreateTxresponse = await tokenCreateTx.execute( env.client, ); - const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( - env.client, - ); + const tokenCreateTxReceipt = + await tokenCreateTxresponse.getReceipt(env.client); const tokenId = tokenCreateTxReceipt.tokenId; - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( - await (await tokenUpdateTx.sign(wrongKey)).execute(env.client) + await ( + await tokenUpdateTx.sign(wrongKey) + ).execute(env.client) ).getReceipt(env.client); } catch (error) { status = error.status; @@ -1042,13 +1070,13 @@ describe.only("TokenUpdate", function () { it("should NOT update the metadata of token if the metadata or admin keys are NOT set", async function () { this.timeout(120000); - + let status; const operatorId = env.operatorId; const supplyKey = PrivateKey.generateED25519(); const metadata = new Uint8Array([1]); const newMetadata = new Uint8Array([1, 2]); - + try { const tokenCreateTx = new TokenCreateTransaction() .setTokenName("Test") @@ -1057,20 +1085,19 @@ describe.only("TokenUpdate", function () { .setTokenType(TokenType.NonFungibleUnique) .setTreasuryAccountId(operatorId) .setMetadata(metadata); - + const tokenCreateTxresponse = await tokenCreateTx.execute( env.client, ); - const tokenCreateTxReceipt = await tokenCreateTxresponse.getReceipt( - env.client, - ); + const tokenCreateTxReceipt = + await tokenCreateTxresponse.getReceipt(env.client); const tokenId = tokenCreateTxReceipt.tokenId; - + const tokenUpdateTx = new TokenUpdateTransaction() .setTokenId(tokenId) .setMetadata(newMetadata) .freezeWith(env.client); - + await ( await tokenUpdateTx.execute(env.client) ).getReceipt(env.client);