From adca81b6396ce207385826812b3cba779f01b51c Mon Sep 17 00:00:00 2001 From: Daniil Sedov <42098239+Gusarich@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:09:05 +0300 Subject: [PATCH] test: `address()` built-in function (#236) --- src/test/feature-address.spec.ts | 29 +++++++++++++++++++++++++++++ src/test/features/address.tact | 21 +++++++++++++++++++++ tact.config.json | 8 ++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/test/feature-address.spec.ts create mode 100644 src/test/features/address.tact diff --git a/src/test/feature-address.spec.ts b/src/test/feature-address.spec.ts new file mode 100644 index 000000000..89234ea32 --- /dev/null +++ b/src/test/feature-address.spec.ts @@ -0,0 +1,29 @@ +import { toNano } from "@ton/core"; +import { ContractSystem } from "@tact-lang/emulator"; +import { __DANGER_resetNodeId } from "../grammar/ast"; +import { AddressTester } from "./features/output/address_AddressTester"; + +describe("feature-address", () => { + beforeEach(() => { + __DANGER_resetNodeId(); + }); + it("should implement addresses correctly", async () => { + // Init + const system = await ContractSystem.create(); + const treasure = system.treasure("treasure"); + const contract = system.open(await AddressTester.fromInit()); + await contract.send(treasure, { value: toNano("10") }, null); + await system.run(); + + // Check methods + expect((await contract.getTest1()).toRawString()).toEqual( + "0:4a81708d2cf7b15a1b362fbf64880451d698461f52f05f145b36c08517d76873", + ); + expect((await contract.getTest2()).toRawString()).toEqual( + "0:4a81708d2cf7b15a1b362fbf64880451d698461f52f05f145b36c08517d76873", + ); + expect((await contract.getTest3()).toRawString()).toEqual( + "0:4a81708d2cf7b15a1b362fbf64880451d698461f52f05f145b36c08517d76873", + ); + }); +}); diff --git a/src/test/features/address.tact b/src/test/features/address.tact new file mode 100644 index 000000000..851847aa8 --- /dev/null +++ b/src/test/features/address.tact @@ -0,0 +1,21 @@ +contract AddressTester { + init() { + + } + + receive() { + + } + + get fun test1(): Address { + return address("UQBKgXCNLPexWhs2L79kiARR1phGH1LwXxRbNsCFF9doczSI"); + } + + get fun test2(): Address { + return address("EQBKgXCNLPexWhs2L79kiARR1phGH1LwXxRbNsCFF9doc2lN"); + } + + get fun test3(): Address { + return address("0:4a81708d2cf7b15a1b362fbf64880451d698461f52f05f145b36c08517d76873"); + } +} \ No newline at end of file diff --git a/tact.config.json b/tact.config.json index c970e44cc..42d65880f 100644 --- a/tact.config.json +++ b/tact.config.json @@ -230,6 +230,14 @@ "masterchain": true } }, + { + "name": "address", + "path": "./src/test/features/address.tact", + "output": "./src/test/features/output", + "options": { + "debug": true + } + }, { "name": "ternary", "path": "./src/test/features/ternary.tact",