|
8 | 8 | FileDeleteTransaction, |
9 | 9 | Hbar, |
10 | 10 | Status, |
| 11 | + AccountId, |
11 | 12 | } from "../../src/exports.js"; |
12 | 13 | import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js"; |
13 | 14 |
|
@@ -41,9 +42,7 @@ describe("ContractUpdate", function () { |
41 | 42 | .setAdminKey(operatorKey) |
42 | 43 | .setGas(300_000) |
43 | 44 | .setConstructorParameters( |
44 | | - new ContractFunctionParameters().addString( |
45 | | - "Hello from Hedera.", |
46 | | - ), |
| 45 | + new ContractFunctionParameters().addString("Hello from Hiero."), |
47 | 46 | ) |
48 | 47 | .setBytecodeFileId(file) |
49 | 48 | .setContractMemo("[e2e::ContractCreateTransaction]") |
@@ -136,9 +135,7 @@ describe("ContractUpdate", function () { |
136 | 135 | .setAdminKey(operatorKey) |
137 | 136 | .setGas(300_000) |
138 | 137 | .setConstructorParameters( |
139 | | - new ContractFunctionParameters().addString( |
140 | | - "Hello from Hedera.", |
141 | | - ), |
| 138 | + new ContractFunctionParameters().addString("Hello from Hiero."), |
142 | 139 | ) |
143 | 140 | .setBytecodeFileId(file) |
144 | 141 | .setContractMemo("[e2e::ContractCreateTransaction]") |
@@ -182,6 +179,108 @@ describe("ContractUpdate", function () { |
182 | 179 | } |
183 | 180 | }); |
184 | 181 |
|
| 182 | + it("should update the auto renew account ID to 0.0.0", async function () { |
| 183 | + const operatorKey = env.operatorKey.publicKey; |
| 184 | + |
| 185 | + let response = await new FileCreateTransaction() |
| 186 | + .setKeys([operatorKey]) |
| 187 | + .setContents(smartContractBytecode) |
| 188 | + .execute(env.client); |
| 189 | + |
| 190 | + let receipt = await response.getReceipt(env.client); |
| 191 | + |
| 192 | + expect(receipt.fileId).to.not.be.null; |
| 193 | + expect(receipt.fileId != null ? receipt.fileId.num > 0 : false).to.be |
| 194 | + .true; |
| 195 | + |
| 196 | + const file = receipt.fileId; |
| 197 | + |
| 198 | + response = await new ContractCreateTransaction() |
| 199 | + .setAdminKey(operatorKey) |
| 200 | + .setGas(300_000) |
| 201 | + .setConstructorParameters( |
| 202 | + new ContractFunctionParameters().addString("Hello from Hiero."), |
| 203 | + ) |
| 204 | + .setBytecodeFileId(file) |
| 205 | + .setContractMemo("[e2e::ContractCreateTransaction]") |
| 206 | + .setAutoRenewAccountId(env.client.operatorAccountId) |
| 207 | + .execute(env.client); |
| 208 | + |
| 209 | + receipt = await response.getReceipt(env.client); |
| 210 | + console.log("contract"); |
| 211 | + |
| 212 | + expect(receipt.contractId).to.not.be.null; |
| 213 | + expect(receipt.contractId != null ? receipt.contractId.num > 0 : false) |
| 214 | + .to.be.true; |
| 215 | + |
| 216 | + let contract = receipt.contractId; |
| 217 | + |
| 218 | + let info = await new ContractInfoQuery() |
| 219 | + .setContractId(contract) |
| 220 | + .setQueryPayment(new Hbar(1)) |
| 221 | + .execute(env.client); |
| 222 | + |
| 223 | + expect(info.contractId.toString()).to.be.equal(contract.toString()); |
| 224 | + expect(info.accountId).to.be.not.null; |
| 225 | + expect( |
| 226 | + info.contractId != null ? info.contractId.toString() : "", |
| 227 | + ).to.be.equal(contract.toString()); |
| 228 | + expect(info.adminKey).to.be.not.null; |
| 229 | + expect( |
| 230 | + info.adminKey != null ? info.adminKey.toString() : "", |
| 231 | + ).to.be.equal(operatorKey.toString()); |
| 232 | + expect(info.storage.toInt()).to.be.equal(128); |
| 233 | + expect(info.contractMemo).to.be.equal( |
| 234 | + "[e2e::ContractCreateTransaction]", |
| 235 | + ); |
| 236 | + expect(info.autoRenewAccountId.toString()).to.be.equal( |
| 237 | + env.client.operatorAccountId.toString(), |
| 238 | + ); |
| 239 | + |
| 240 | + await ( |
| 241 | + await new ContractUpdateTransaction() |
| 242 | + .setContractId(contract) |
| 243 | + .setContractMemo("[e2e::ContractUpdateTransaction]") |
| 244 | + .setAutoRenewAccountId(new AccountId(0, 0, 0)) |
| 245 | + .execute(env.client) |
| 246 | + ).getReceipt(env.client); |
| 247 | + |
| 248 | + info = await new ContractInfoQuery() |
| 249 | + .setContractId(contract) |
| 250 | + .setQueryPayment(new Hbar(5)) |
| 251 | + .execute(env.client); |
| 252 | + |
| 253 | + expect(info.contractId.toString()).to.be.equal(contract.toString()); |
| 254 | + expect(info.accountId).to.be.not.null; |
| 255 | + expect( |
| 256 | + info.contractId != null ? info.contractId.toString() : "", |
| 257 | + ).to.be.equal(contract.toString()); |
| 258 | + expect(info.adminKey).to.be.not.null; |
| 259 | + expect( |
| 260 | + info.adminKey != null ? info.adminKey.toString() : "", |
| 261 | + ).to.be.equal(operatorKey.toString()); |
| 262 | + expect(info.storage.toInt()).to.be.equal(128); |
| 263 | + expect(info.contractMemo).to.be.equal( |
| 264 | + "[e2e::ContractUpdateTransaction]", |
| 265 | + ); |
| 266 | + expect(info.autoRenewAccountId.toString()).to.be.equal( |
| 267 | + new AccountId(0, 0, 0).toString(), |
| 268 | + ); |
| 269 | + |
| 270 | + await ( |
| 271 | + await new ContractDeleteTransaction() |
| 272 | + .setContractId(contract) |
| 273 | + .setTransferAccountId(env.client.operatorAccountId) |
| 274 | + .execute(env.client) |
| 275 | + ).getReceipt(env.client); |
| 276 | + |
| 277 | + await ( |
| 278 | + await new FileDeleteTransaction() |
| 279 | + .setFileId(file) |
| 280 | + .execute(env.client) |
| 281 | + ).getReceipt(env.client); |
| 282 | + }); |
| 283 | + |
185 | 284 | afterAll(async function () { |
186 | 285 | await env.close(); |
187 | 286 | }); |
|
0 commit comments