Skip to content

Commit

Permalink
test address() built-in function
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Apr 10, 2024
1 parent 87b5cd6 commit 2e5b968
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/feature-address.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Address, beginCell, toNano } from "@ton/core";

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, ubuntu-latest)

'Address' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, ubuntu-latest)

'beginCell' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, windows-latest)

'Address' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, windows-latest)

'beginCell' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, macos-latest)

'Address' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/test/feature-address.spec.ts

View workflow job for this annotation

GitHub Actions / test (18.x, macos-latest)

'beginCell' is defined but never used. Allowed unused vars must match /^_/u
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')
});
});
21 changes: 21 additions & 0 deletions src/test/features/address.tact
Original file line number Diff line number Diff line change
@@ -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");
}
}
8 changes: 8 additions & 0 deletions tact.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2e5b968

Please sign in to comment.