-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`feature-ternary should implement try-catch statements correctly 1`] = ` | ||
[ | ||
{ | ||
"$seq": 1, | ||
"events": [ | ||
{ | ||
"$type": "storage-charged", | ||
"amount": "0.000000007", | ||
}, | ||
{ | ||
"$type": "received", | ||
"message": { | ||
"body": { | ||
"text": "increment", | ||
"type": "text", | ||
}, | ||
"bounce": true, | ||
"from": "@treasure(treasure)", | ||
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn", | ||
"type": "internal", | ||
"value": "10", | ||
}, | ||
}, | ||
{ | ||
"$type": "processed", | ||
"gasUsed": 3929n, | ||
}, | ||
], | ||
}, | ||
{ | ||
"$seq": 2, | ||
"events": [ | ||
{ | ||
"$type": "storage-charged", | ||
"amount": "0.000000007", | ||
}, | ||
{ | ||
"$type": "received", | ||
"message": { | ||
"body": { | ||
"text": "incrementTryCatch", | ||
"type": "text", | ||
}, | ||
"bounce": true, | ||
"from": "@treasure(treasure)", | ||
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn", | ||
"type": "internal", | ||
"value": "10", | ||
}, | ||
}, | ||
{ | ||
"$type": "processed", | ||
"gasUsed": 4507n, | ||
}, | ||
], | ||
}, | ||
{ | ||
"$seq": 3, | ||
"events": [ | ||
{ | ||
"$type": "storage-charged", | ||
"amount": "0.000000007", | ||
}, | ||
{ | ||
"$type": "received", | ||
"message": { | ||
"body": { | ||
"text": "tryCatchRegisters", | ||
"type": "text", | ||
}, | ||
"bounce": true, | ||
"from": "@treasure(treasure)", | ||
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn", | ||
"type": "internal", | ||
"value": "10", | ||
}, | ||
}, | ||
{ | ||
"$type": "processed", | ||
"gasUsed": 12023n, | ||
}, | ||
{ | ||
"$type": "sent", | ||
"messages": [ | ||
{ | ||
"body": { | ||
"text": "hello world 1", | ||
"type": "text", | ||
}, | ||
"bounce": true, | ||
"from": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn", | ||
"to": "@treasure(treasure)", | ||
"type": "internal", | ||
"value": "9.986741", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { toNano } from "@ton/core"; | ||
import { ContractSystem } from "@tact-lang/emulator"; | ||
import { __DANGER_resetNodeId } from "../grammar/ast"; | ||
import { TryCatchTester } from "./features/output/try-catch_TryCatchTester"; | ||
|
||
describe("feature-ternary", () => { | ||
beforeEach(() => { | ||
__DANGER_resetNodeId(); | ||
}); | ||
it("should implement try-catch statements correctly", async () => { | ||
// Init | ||
const system = await ContractSystem.create(); | ||
const treasure = system.treasure("treasure"); | ||
const contract = system.open(await TryCatchTester.fromInit()); | ||
await contract.send(treasure, { value: toNano("10") }, null); | ||
await system.run(); | ||
|
||
// Check methods | ||
expect(await contract.getTestTryCatch1()).toEqual(7n); | ||
expect(await contract.getTestTryCatch2()).toEqual(101n); | ||
expect(await contract.getTestTryCatch3()).toEqual(4n); | ||
|
||
// Check state rollbacks | ||
const tracker = system.track(contract); | ||
|
||
expect(await contract.getGetCounter()).toEqual(0n); | ||
await contract.send(treasure, { value: toNano("10") }, "increment"); | ||
await system.run(); | ||
expect(await contract.getGetCounter()).toEqual(1n); | ||
await contract.send( | ||
treasure, | ||
{ value: toNano("10") }, | ||
"incrementTryCatch", | ||
); | ||
await system.run(); | ||
expect(await contract.getGetCounter()).toEqual(1n); | ||
await contract.send( | ||
treasure, | ||
{ value: toNano("10") }, | ||
"tryCatchRegisters", | ||
); | ||
await system.run(); | ||
expect(await contract.getGetCounter()).toEqual(2n); | ||
|
||
expect(tracker.collect()).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.