-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inability to create and execute freeze transaction (#2171)
* update: add execute method Signed-off-by: svetoslav-nikol0v <[email protected]> * update: export FreezeType Signed-off-by: svetoslav-nikol0v <[email protected]> * chore: integration and unit test added Signed-off-by: svetoslav-nikol0v <[email protected]> --------- Signed-off-by: svetoslav-nikol0v <[email protected]>
- Loading branch information
1 parent
0feddb2
commit 841655f
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
Timestamp, | ||
FreezeTransaction, | ||
FreezeType, | ||
// TransactionResponse, | ||
// TransactionReceipt, | ||
Status, | ||
} from "../../src/exports.js"; | ||
import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; | ||
|
||
describe("FreezeTransaction", function () { | ||
let client; | ||
|
||
before(async function () { | ||
const env = await IntegrationTestEnv.new(); | ||
client = env.client; | ||
}); | ||
|
||
it("should be executable but not supported", async function () { | ||
this.timeout(120000); | ||
const seconds = Math.round(Date.now() / 1000); | ||
const validStart = new Timestamp(seconds, 0); | ||
|
||
const transaction = new FreezeTransaction() | ||
.setStartTimestamp(validStart) | ||
.setFreezeType(new FreezeType(1)) | ||
.freezeWith(client); | ||
expect(transaction.startTimestamp).to.be.equal(validStart); | ||
expect(transaction.freezeType).to.be.instanceof(FreezeType); | ||
|
||
try { | ||
await transaction.execute(client); | ||
} catch (error) { | ||
expect(error.status).to.be.equal(Status.NotSupported); | ||
} | ||
|
||
// At the moment the API is not supported that's why the following lines are commented out. | ||
// Once supported the try/catch block above should be removed. | ||
// The status from execution of the transaction is code 13 which means NOT_SUPPORTED. | ||
|
||
// const response = await transaction.execute(client) | ||
// expect(response).to.be.instanceof(TransactionResponse) | ||
// const receipt = await response.getReceipt(client) | ||
// expect(receipt).to.be.instanceof(TransactionReceipt) | ||
// expect(receipt.status.toString).to.be.instanceof(Status.Success) | ||
|
||
client.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect } from "chai"; | ||
|
||
import { FreezeTransaction, Timestamp, FreezeType } from "../../src/index.js"; | ||
|
||
describe("FreezeTransaction", function () { | ||
it("create transaction and set ", function () { | ||
const seconds = Math.round(Date.now() / 1000); | ||
const validStart = new Timestamp(seconds, 0); | ||
const freezeType = new FreezeType(1); | ||
|
||
const transaction = new FreezeTransaction() | ||
.setStartTimestamp(validStart) | ||
.setFreezeType(freezeType); | ||
|
||
expect(transaction).to.be.instanceof(FreezeTransaction); | ||
expect(transaction.startTimestamp).to.be.equal(validStart); | ||
expect(transaction.freezeType).to.be.instanceof(FreezeType); | ||
expect(transaction.freezeType.toString()).to.be.equal( | ||
freezeType.toString(), | ||
); | ||
}); | ||
}); |