Skip to content

Commit

Permalink
implement for structs and fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Jun 19, 2024
1 parent 5a8fbe6 commit 9f1a72d
Show file tree
Hide file tree
Showing 11 changed files with 1,022 additions and 57 deletions.
140 changes: 130 additions & 10 deletions src/test/e2e-emulated/__snapshots__/const-string-receiver.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ exports[`constant string receiver should implement const string receiver correct
},
"receiver": "internal",
},
{
"message": {
"kind": "text",
"text": "string 5",
},
"receiver": "internal",
},
{
"message": {
"kind": "text",
"text": "string 6",
},
"receiver": "internal",
},
],
"types": [
{
Expand Down Expand Up @@ -239,6 +253,34 @@ exports[`constant string receiver should implement const string receiver correct
"header": null,
"name": "SendParameters",
},
{
"fields": [
{
"name": "s",
"type": {
"kind": "simple",
"optional": false,
"type": "string",
},
},
],
"header": null,
"name": "MyStruct",
},
{
"fields": [
{
"name": "struct",
"type": {
"kind": "simple",
"optional": false,
"type": "MyStruct",
},
},
],
"header": null,
"name": "MyNestedStruct",
},
],
}
`;
Expand All @@ -257,7 +299,7 @@ exports[`constant string receiver should implement const string receiver correct
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
Expand All @@ -275,7 +317,7 @@ exports[`constant string receiver should implement const string receiver correct
"type": "text",
},
"bounce": true,
"from": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.991947",
Expand All @@ -296,7 +338,7 @@ exports[`constant string receiver should implement const string receiver correct
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
Expand All @@ -314,7 +356,7 @@ exports[`constant string receiver should implement const string receiver correct
"type": "text",
},
"bounce": true,
"from": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.989336",
Expand All @@ -335,7 +377,7 @@ exports[`constant string receiver should implement const string receiver correct
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
Expand All @@ -353,7 +395,7 @@ exports[`constant string receiver should implement const string receiver correct
"type": "text",
},
"bounce": true,
"from": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.989223",
Expand All @@ -374,14 +416,14 @@ exports[`constant string receiver should implement const string receiver correct
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
},
{
"$type": "processed",
"gasUsed": 9730n,
"gasUsed": 9766n,
},
{
"$type": "sent",
Expand All @@ -392,10 +434,88 @@ exports[`constant string receiver should implement const string receiver correct
"type": "text",
},
"bounce": true,
"from": "kQCjCGWLilNv7PPffKoWdQHPZ-88MekCb9F_U5ddfPTsuH3_",
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.989038",
},
],
},
],
},
{
"$seq": 5,
"events": [
{
"$type": "received",
"message": {
"body": {
"text": "string 5",
"type": "text",
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
},
{
"$type": "processed",
"gasUsed": 7453n,
},
{
"$type": "sent",
"messages": [
{
"body": {
"text": "string 5",
"type": "text",
},
"bounce": true,
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.991351",
},
],
},
],
},
{
"$seq": 6,
"events": [
{
"$type": "received",
"message": {
"body": {
"text": "string 6",
"type": "text",
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"type": "internal",
"value": "10",
},
},
{
"$type": "processed",
"gasUsed": 7602n,
},
{
"$type": "sent",
"messages": [
{
"body": {
"text": "string 6",
"type": "text",
},
"bounce": true,
"from": "kQBO2__AL4wOwtXplvVV7psQ7PAJKpbbqzS36LyZWcW01Pl7",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.989074",
"value": "9.991202",
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions src/test/e2e-emulated/const-string-receiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe("constant string receiver", () => {
await contract.send(treasure, { value: toNano("10") }, "string 2");
await contract.send(treasure, { value: toNano("10") }, "string 3");
await contract.send(treasure, { value: toNano("10") }, "string 4");
await contract.send(treasure, { value: toNano("10") }, "string 5");
await contract.send(treasure, { value: toNano("10") }, "string 6");
await system.run();

expect(tracker.collect()).toMatchSnapshot();
Expand Down
24 changes: 24 additions & 0 deletions src/test/e2e-emulated/contracts/const-string-receiver.tact
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ const string1: String = "string 1";
const string2: String = "string 2";
const string3: String = "string 3";

struct MyStruct {
s: String;
}

struct MyNestedStruct {
struct: MyStruct;
}

contract ConstStringReceiverTester {
const string4: String = "string 4";
const struct: MyStruct = MyStruct {
s: "string 5"
};
const nestedStruct: MyNestedStruct = MyNestedStruct {
struct: MyStruct {
s: "string 6"
}
};

receive() { }

Expand All @@ -22,4 +38,12 @@ contract ConstStringReceiverTester {
receive(self.string4) {
self.reply(self.string4.asComment());
}

receive(self.struct.s) {
self.reply("string 5".asComment()); // until const struct fields are fixed
}

receive(self.nestedStruct.struct.s) {
self.reply("string 6".asComment()); // until const struct fields are fixed
}
}
Loading

0 comments on commit 9f1a72d

Please sign in to comment.