-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codegen): always store contract data if
init()
is used (#2077)
- Loading branch information
1 parent
bd242c2
commit bbfe31c
Showing
12 changed files
with
114 additions
and
53 deletions.
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
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
11 changes: 11 additions & 0 deletions
11
src/test/e2e-emulated/contracts/storage-write-analysis.tact
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,11 @@ | ||
contract Tester { | ||
|
||
init() { | ||
// if storage write analysis is implemented correctly, this will send | ||
// just one message back to self, otherwise it will spam with messages | ||
// until it runs out of gas | ||
message(MessageParameters { to: myAddress(), value: 0, mode: SendRemainingValue }) | ||
} | ||
|
||
receive() { } // does not modify the contract state | ||
} |
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,42 @@ | ||
import { toNano } from "@ton/core"; | ||
import type { SandboxContract, TreasuryContract } from "@ton/sandbox"; | ||
import { Blockchain } from "@ton/sandbox"; | ||
import { Tester } from "./contracts/output/storage-write-analysis_Tester"; | ||
import "@ton/test-utils"; | ||
|
||
describe("storage-write-analysis", () => { | ||
let blockchain: Blockchain; | ||
let treasure: SandboxContract<TreasuryContract>; | ||
let contract: SandboxContract<Tester>; | ||
|
||
beforeEach(async () => { | ||
blockchain = await Blockchain.create(); | ||
blockchain.verbosity.print = false; | ||
treasure = await blockchain.treasury("treasure"); | ||
|
||
contract = blockchain.openContract(await Tester.fromInit()); | ||
|
||
const deployResult = await contract.send( | ||
treasure.getSender(), | ||
{ value: toNano("1") }, | ||
null, | ||
); | ||
expect(deployResult.transactions).toHaveTransaction({ | ||
from: treasure.address, | ||
to: contract.address, | ||
actionResultCode: 0, | ||
success: true, | ||
deploy: true, | ||
}); | ||
expect(deployResult.transactions).toHaveTransaction({ | ||
from: contract.address, | ||
to: contract.address, | ||
success: true, | ||
}); | ||
expect(deployResult.transactions.length).toStrictEqual(1 + 1 + 1); // wallet + deploy + one message back to self in init | ||
}); | ||
|
||
it("should persist contract storage when init is called before the empty receiver", async () => { | ||
// the deployment has the test | ||
}); | ||
}); |