Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 committed Feb 5, 2025
1 parent eeb1a22 commit e8b05c0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/e2e-emulated/contract-with-init-init-parameter.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { toNano } from "@ton/core";
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox";
import { Test } from "./contracts/output/contract-with-init-init-parameter_Test";
import "@ton/test-utils";

describe("contract-with-init-init-parameter", () => {
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({
$$type: "Init",
foo: 99n,
}),
);

const deployResult = await contract.send(
treasure.getSender(),
{ value: toNano("0.5") },
null,
);

expect(deployResult.transactions).toHaveTransaction({
from: treasure.address,
to: contract.address,
success: true,
deploy: true,
});
});

it("should return correct result", async () => {
expect(await contract.getData()).toBe(99n);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct Init { foo: Int as uint8 }

contract Test {
foo: Int;

init(init: Init) {
self.foo = init.foo;
}

receive() {}

get fun data(): Int {
return self.foo;
}
}

0 comments on commit e8b05c0

Please sign in to comment.