-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: contract method calls in
return
statements (#829)
- Loading branch information
1 parent
897b480
commit 82fec48
Showing
5 changed files
with
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { toNano } from "@ton/core"; | ||
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox"; | ||
import { Test } from "./contracts/output/contract-methods_Test"; | ||
import "@ton/test-utils"; | ||
|
||
describe("contract-methods", () => { | ||
let blockchain: Blockchain; | ||
let treasure: SandboxContract<TreasuryContract>; | ||
let contract: SandboxContract<Test>; | ||
|
||
beforeEach(async () => { | ||
blockchain = await Blockchain.create(); | ||
blockchain.verbosity.print = false; | ||
treasure = await blockchain.treasury("treasure"); | ||
|
||
contract = blockchain.openContract(await Test.fromInit()); | ||
|
||
const deployResult = await contract.send( | ||
treasure.getSender(), | ||
{ value: toNano("10") }, | ||
null, | ||
); | ||
expect(deployResult.transactions).toHaveTransaction({ | ||
from: treasure.address, | ||
to: contract.address, | ||
success: true, | ||
deploy: true, | ||
}); | ||
}); | ||
|
||
it("should implement contract methods correctly", async () => {}); | ||
}); |
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,24 @@ | ||
contract Test { | ||
flags: Int as uint256 = 0; | ||
oneMoreVar: Int = 239; | ||
receive() { | ||
self.checkImmediateReturn(); | ||
require(self.flags == 42, "checkImmediateReturn() is mis-compiled"); | ||
self.flags = 0; | ||
self.checkReturnViaLocalVar(); | ||
require(self.flags == 42, "checkReturnViaLocalVar() is mis-compiled"); | ||
} | ||
|
||
fun checkImmediateReturn(): Bool { | ||
return self.check(); | ||
} | ||
fun checkReturnViaLocalVar(): Bool { | ||
let foo = self.check(); | ||
return foo; | ||
} | ||
fun check(): Bool { | ||
self.flags = 42; | ||
return true; | ||
} | ||
} | ||
|
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