Skip to content

Commit

Permalink
test: const-eval sha256()
Browse files Browse the repository at this point in the history
  • Loading branch information
novusnota committed Oct 3, 2024
1 parent d479c76 commit 1744a02
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/compilation-failed/abi-global-errors.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { __DANGER_resetNodeId } from "../../grammar/ast";
import { itShouldNotCompile } from "./util";

describe("abi/global.ts errors", () => {
beforeEach(() => {
__DANGER_resetNodeId();
});

itShouldNotCompile({
testName: "sha256-expects-string-or-slice",
errorMessage: "sha256 expects string or slice argument",
});
});
5 changes: 5 additions & 0 deletions src/test/compilation-failed/const-eval-failed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,9 @@ describe("fail-const-eval", () => {
errorMessage:
"Cannot evaluate expression to a constant: ascii string cannot be empty",
});
itShouldNotCompile({
testName: "const-eval-sha256-too-large",
errorMessage:
"Cannot evaluate expression to a constant: data is too large for sha256 hash, expected up to 128 bytes, got 129",
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
contract Sha256 {
receive() {
sha256("------------------------------------------------------------------------------------------------------------------------------129");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract Sha256 {
val: Int = 0;
receive() {
sha256(self.val);
}
}
10 changes: 10 additions & 0 deletions src/test/compilation-failed/tact.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
"name": "scope-const-shadows-stdlib-ident",
"path": "./contracts/scope-const-shadows-stdlib-ident.tact",
"output": "./contracts/output"
},
{
"name": "sha256-expects-string-or-slice",
"path": "./contracts/sha256-expects-string-or-slice.tact",
"output": "./contracts/output"
},
{
"name": "const-eval-sha256-too-large",
"path": "./contracts/const-eval-sha256-too-large.tact",
"output": "./contracts/output"
}
]
}

0 comments on commit 1744a02

Please sign in to comment.