Skip to content

Commit

Permalink
refactor: reuse variables in file append integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ivaylo Nikolov <[email protected]>
  • Loading branch information
ivaylonikolov7 committed Sep 26, 2024
1 parent b02bdc6 commit 0d6609f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/integration/FileAppendIntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js";

describe("FileAppend", function () {
let env;
let newContentsLength;
let newContents;
let operatorKey;

before(async function () {
env = await IntegrationTestEnv.new();
newContentsLength = 5000;
newContents = generateUInt8Array(newContentsLength);
operatorKey = env.operatorKey.publicKey;
});
it("should be executable", async function () {
this.timeout(120000);

const operatorKey = env.operatorKey.publicKey;

let response = await new FileCreateTransaction()
.setKeys([operatorKey])
.setContents("[e2e::FileCreateTransaction]")
Expand Down Expand Up @@ -214,10 +218,6 @@ describe("FileAppend", function () {
it("should keep content after deserialization", async function () {
this.timeout(120000);

const NEW_CONTENTS_LENGTH = 5000;
const NEW_CONTENTS = generateUInt8Array(NEW_CONTENTS_LENGTH);
const operatorKey = env.operatorKey.publicKey;

let response = await new FileCreateTransaction()
.setKeys([operatorKey])
.setContents(Buffer.from(""))
Expand All @@ -230,7 +230,7 @@ describe("FileAppend", function () {

const tx = new FileAppendTransaction()
.setFileId(fileId)
.setContents(NEW_CONTENTS);
.setContents(newContents);

const txBytes = tx.toBytes();
const txFromBytes = FileAppendTransaction.fromBytes(txBytes);
Expand All @@ -240,7 +240,7 @@ describe("FileAppend", function () {
const content = await new FileInfoQuery()
.setFileId(fileId)
.execute(env.client);
expect(content.size.toInt()).to.be.equal(NEW_CONTENTS_LENGTH);
expect(content.size.toInt()).to.be.equal(newContentsLength);
});

it("should be able to freeze after deserialze", async function () {
Expand Down

0 comments on commit 0d6609f

Please sign in to comment.