-
Notifications
You must be signed in to change notification settings - Fork 218
refactor: require() now uses exit codes starting from 1024
#2315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6918dfd
Solved
Shvandre f57a6bc
linter
Shvandre 3e93c02
fmt
Shvandre 2f784cc
cspell
Shvandre c02a71d
fix: do not escape twice
verytactical a48d33b
fmt
verytactical b4cab16
Merge remote-tracking branch 'origin/closes-2313' into 2245-require-s…
Shvandre 5ce53ff
Merge branch 'main' into 2245-require-should-use-smaller-exit-codes
Shvandre 9eb63c5
Added tests
Shvandre f1bfa74
Fixed linter
Shvandre 6ddbbce
fix
Shvandre ad5396f
Merge branch 'main' into 2245-require-should-use-smaller-exit-codes
Shvandre 087225d
Update src/cli/tact/e2e.spec.ts
b457ff8
blah
2eb6543
docs for require (could be useful in the future)
novusnota 0e797f6
Merge branch '2245-require-should-use-smaller-exit-codes' of github.c…
novusnota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 @@ | ||
| contract ExitCodesChild { | ||
| receive() {} | ||
| get fun test() { | ||
| require(false, "second"); | ||
| return; | ||
| } | ||
| } |
This file contains hidden or 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,13 @@ | ||
| import "./exit-codes-child"; | ||
|
|
||
| contract ExitCodesParent { | ||
| receive() {} | ||
| get fun firstExitCode() { | ||
| require(false, "first"); | ||
| return; | ||
| } | ||
| get fun secondExitCode() { | ||
| require(false, "second"); | ||
| return; | ||
| } | ||
| } |
This file contains hidden or 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,79 @@ | ||
| import { toNano } from "@ton/core"; | ||
| import type { SandboxContract, TreasuryContract } from "@ton/sandbox"; | ||
| import { Blockchain } from "@ton/sandbox"; | ||
| import { ExitCodesParent } from "./contracts/output/exit-codes-parent_ExitCodesParent"; | ||
| import { ExitCodesChild as SameProjectChild } from "./contracts/output/exit-codes-parent_ExitCodesChild"; | ||
| import { ExitCodesChild as SeparatedChild } from "./contracts/output/exit-codes-child_ExitCodesChild"; | ||
| import "@ton/test-utils"; | ||
|
|
||
| describe("exit-codes", () => { | ||
| let blockchain: Blockchain; | ||
| let treasure: SandboxContract<TreasuryContract>; | ||
| let parent: SandboxContract<ExitCodesParent>; | ||
| let childSameProj: SandboxContract<SameProjectChild>; | ||
|
|
||
| beforeEach(async () => { | ||
| blockchain = await Blockchain.create(); | ||
| blockchain.verbosity.print = false; | ||
| treasure = await blockchain.treasury("treasure"); | ||
|
|
||
| parent = blockchain.openContract(await ExitCodesParent.fromInit()); | ||
| childSameProj = blockchain.openContract( | ||
| await SameProjectChild.fromInit(), | ||
| ); | ||
|
|
||
| const deployResult = await parent.send( | ||
| treasure.getSender(), | ||
| { value: toNano("10") }, | ||
| null, | ||
| ); | ||
|
|
||
| expect(deployResult.transactions).toHaveTransaction({ | ||
| from: treasure.address, | ||
| to: parent.address, | ||
| success: true, | ||
| deploy: true, | ||
| }); | ||
| }); | ||
|
|
||
| it("abi should be correct", async () => { | ||
| const parentProvider = blockchain.getContract(parent.address); | ||
| const firstExitCode = ExitCodesParent.errors["first"]; | ||
| const realFirstExitCode = ( | ||
| await (await parentProvider).get("firstExitCode") | ||
| ).exitCode; | ||
| expect(realFirstExitCode).toBe(firstExitCode); | ||
|
|
||
| const secondExitCode = ExitCodesParent.errors["second"]; | ||
| const realSecondExitCode = ( | ||
| await (await parentProvider).get("secondExitCode") | ||
| ).exitCode; | ||
| expect(realSecondExitCode).toBe(secondExitCode); | ||
|
|
||
| const childProvider = blockchain.getContract(childSameProj.address); | ||
| const childExitCode = SameProjectChild.errors["second"]; | ||
| const realChildExitCode = ( | ||
| await (await childProvider).get("secondExitCode") | ||
| ).exitCode; | ||
| expect(realChildExitCode).toBe(childExitCode); | ||
| }); | ||
|
|
||
| it("should be same in same project", () => { | ||
| const firstParentExitCode = ExitCodesParent.errors["first"]; | ||
| const secondParentExitCode = ExitCodesParent.errors["second"]; | ||
| const childExitCode = SameProjectChild.errors["second"]; | ||
|
|
||
| expect( | ||
| new Set([firstParentExitCode, secondParentExitCode, childExitCode]), | ||
| ).toEqual(new Set([1024, 1025])); | ||
| }); | ||
|
|
||
| it("should be different in different projects", () => { | ||
| const parentExitCode = ExitCodesParent.errors["second"]; | ||
| const separateExitCode = SeparatedChild.errors["second"]; | ||
| expect(separateExitCode).toBe(1024); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| expect(parentExitCode === 1024 || parentExitCode === 1025).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.