Skip to content

Commit

Permalink
chore: remove _struct suffix from changed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Aug 16, 2024
1 parent e6d767d commit b557fca
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 45 deletions.
4 changes: 2 additions & 2 deletions examples/wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { storeTransfer, Transfer_struct, Wallet } from "./output/wallet_Wallet";
import { storeTransfer, Transfer, Wallet } from "./output/wallet_Wallet";
import { ContractSystem, testKey } from "@tact-lang/emulator";
import { beginCell, toNano } from "@ton/core";
import { sign } from "@ton/crypto";
Expand All @@ -25,7 +25,7 @@ describe("wallet", () => {
expect(await contract.getSeqno()).toBe(0n);

// Send transfer and check seqno
const transfer: Transfer_struct = {
const transfer: Transfer = {
$$type: "Transfer",
seqno: 0n,
mode: 1n,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e-emulated/__snapshots__/constants.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ ConstantTester {
{
"fields": [],
"header": null,
"name": "ConstantTester",
"name": "ConstantTester$Data",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ exports[`strings should implement external fallbacks correctly 1`] = `
},
],
"header": null,
"name": "ExternalFallbacksTester",
"name": "ExternalFallbacksTester$Data",
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ exports[`local-type-inference should automatically set types for let statements
{
"fields": [],
"header": null,
"name": "LocalTypeInferenceTester",
"name": "LocalTypeInferenceTester$Data",
},
],
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/e2e-emulated/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { randomAddress } from "../utils/randomAddress";
import { __DANGER_resetNodeId } from "../../grammar/ast";
import {
MapTestContract,
SomeStruct_struct,
SomeStruct,
} from "./contracts/output/maps_MapTestContract";
import { ContractSystem } from "@tact-lang/emulator";
import { beginCell, toNano } from "@ton/core";
import { ComputeError } from "@ton/core";

function strEq(a: SomeStruct_struct | null, b: SomeStruct_struct | null) {
function strEq(a: SomeStruct | null, b: SomeStruct | null) {
if (a === null || b === null) {
return a === b;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ describe("map", () => {
const valueBool = k < 0n;
const addr = randomAddress(0, "addr-" + k.toString(10));
const valueCell = beginCell().storeUint(123123, 128).endCell();
const valueStruct: SomeStruct_struct = {
const valueStruct: SomeStruct = {
$$type: "SomeStruct",
value: 10012312n,
};
Expand Down Expand Up @@ -645,7 +645,7 @@ describe("map", () => {
const valueBool = k < 0n;
const addr = randomAddress(0, "addr-" + k.toString(10));
const valueCell = beginCell().storeUint(123123, 128).endCell();
const valueStruct: SomeStruct_struct = {
const valueStruct: SomeStruct = {
$$type: "SomeStruct",
value: 10012312n,
};
Expand Down
22 changes: 8 additions & 14 deletions src/test/e2e-emulated/optionals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import { randomAddress } from "../utils/randomAddress";
import { __DANGER_resetNodeId } from "../../grammar/ast";
import {
ContractWithOptionals,
SomeGenericStruct_struct,
StructWithOptionals_struct,
SomeGenericStruct,
StructWithOptionals,
} from "./contracts/output/optionals_ContractWithOptionals";
import { Opt4 } from "./contracts/output/optionals_Opt4";
import { Address, beginCell, Cell, toNano } from "@ton/core";
import { ContractSystem } from "@tact-lang/emulator";

function strEq2(
a: StructWithOptionals_struct | null,
b: StructWithOptionals_struct | null,
) {
function strEq2(a: StructWithOptionals | null, b: StructWithOptionals | null) {
// Null checks
if (a === null && b === null) {
return true;
Expand Down Expand Up @@ -82,10 +79,7 @@ function strEq2(
return true;
}

function strEq(
a: SomeGenericStruct_struct | null,
b: SomeGenericStruct_struct | null,
) {
function strEq(a: SomeGenericStruct | null, b: SomeGenericStruct | null) {
if (a === null && b === null) {
return true;
}
Expand Down Expand Up @@ -126,15 +120,15 @@ describe("features", () => {
value4: 4n,
value5: 5n,
};
const ev2: StructWithOptionals_struct = {
const ev2: StructWithOptionals = {
$$type: "StructWithOptionals" as const,
a: 1n,
b: true,
c: null,
d: randomAddress(0, "address1"),
e: eV,
};
const ev3: StructWithOptionals_struct = {
const ev3: StructWithOptionals = {
$$type: "StructWithOptionals" as const,
a: 1n,
b: true,
Expand All @@ -147,8 +141,8 @@ describe("features", () => {
b: boolean | null;
c: Cell | null;
d: Address | null;
e: SomeGenericStruct_struct | null;
f: StructWithOptionals_struct | null;
e: SomeGenericStruct | null;
f: StructWithOptionals | null;
}[] = [];
cases.push({ a: null, b: null, c: null, d: null, e: null, f: null });
cases.push({
Expand Down
40 changes: 18 additions & 22 deletions src/test/e2e-emulated/structs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Dictionary, beginCell, toNano } from "@ton/core";
import { ContractSystem } from "@tact-lang/emulator";
import { __DANGER_resetNodeId } from "../../grammar/ast";
import {
MyMessage1_struct,
MyStruct1_struct,
MyStruct2_struct,
MyStruct3_struct,
MyMessage1,
MyStruct1,
MyStruct2,
MyStruct3,
StructsTester,
loadMyMessage1,
loadMyStruct1,
Expand All @@ -31,40 +31,40 @@ describe("structs", () => {
expect(await contract.getStructInitializerTest()).toEqual(true);

// Prepare test values
const s1: MyStruct1_struct = {
const s1: MyStruct1 = {
$$type: "MyStruct1",
a: 1n,
b: 2n,
c: 3n,
};
const s2: MyStruct1_struct = {
const s2: MyStruct1 = {
$$type: "MyStruct1",
a: 1n,
b: 2n,
c: null,
};
const s3: MyStruct2_struct = {
const s3: MyStruct2 = {
$$type: "MyStruct2",
m: Dictionary.empty(
Dictionary.Keys.BigInt(257),
Dictionary.Values.BigUint(64),
),
s: s1,
};
const s4: MyStruct2_struct = {
const s4: MyStruct2 = {
$$type: "MyStruct2",
m: Dictionary.empty(
Dictionary.Keys.BigInt(257),
Dictionary.Values.BigUint(64),
),
s: null,
};
const m1: MyMessage1_struct = {
const m1: MyMessage1 = {
$$type: "MyMessage1",
a: 1n,
s: s3,
};
const m2: MyMessage1_struct = {
const m2: MyMessage1 = {
$$type: "MyMessage1",
a: 2n,
s: s4,
Expand Down Expand Up @@ -124,23 +124,19 @@ describe("structs", () => {
c6.toString(),
);

expect(await contract.getFromCell1(c1)).toMatchObject<MyStruct1_struct>(
s1,
);
expect(await contract.getFromCell1(c2)).toMatchObject<MyStruct1_struct>(
s2,
);
expect(await contract.getFromCell1(c1)).toMatchObject<MyStruct1>(s1);
expect(await contract.getFromCell1(c2)).toMatchObject<MyStruct1>(s2);
expect(await contract.getFromCell2(c3)).toMatchSnapshot();
expect(await contract.getFromCell2(c4)).toMatchSnapshot();
expect(await contract.getFromCellMessage1(c5)).toMatchSnapshot();
expect(await contract.getFromCellMessage1(c6)).toMatchSnapshot();

expect(
await contract.getFromSlice1(c1.asSlice()),
).toMatchObject<MyStruct1_struct>(s1);
).toMatchObject<MyStruct1>(s1);
expect(
await contract.getFromSlice1(c2.asSlice()),
).toMatchObject<MyStruct1_struct>(s2);
).toMatchObject<MyStruct1>(s2);
expect(await contract.getFromSlice2(c3.asSlice())).toMatchSnapshot();
expect(await contract.getFromSlice2(c4.asSlice())).toMatchSnapshot();
expect(
Expand All @@ -165,8 +161,8 @@ describe("structs", () => {

// Test wrappers

expect(loadMyStruct1(c1.asSlice())).toMatchObject<MyStruct1_struct>(s1);
expect(loadMyStruct1(c2.asSlice())).toMatchObject<MyStruct1_struct>(s2);
expect(loadMyStruct1(c1.asSlice())).toMatchObject<MyStruct1>(s1);
expect(loadMyStruct1(c2.asSlice())).toMatchObject<MyStruct1>(s2);
expect(loadMyStruct2(c3.asSlice())).toMatchSnapshot();
expect(loadMyStruct2(c4.asSlice())).toMatchSnapshot();
expect(loadMyMessage1(c5.asSlice())).toMatchSnapshot();
Expand Down Expand Up @@ -210,11 +206,11 @@ describe("structs", () => {
loadMyStruct1(beginCell().storeUint(0, 123).endCell().asSlice()),
).toThrow();

const s5: MyStruct3_struct = {
const s5: MyStruct3 = {
$$type: "MyStruct3",
s: "contract const struct test",
};
const s6: MyStruct3_struct = {
const s6: MyStruct3 = {
$$type: "MyStruct3",
s: "global const struct test",
};
Expand Down

0 comments on commit b557fca

Please sign in to comment.