-
Notifications
You must be signed in to change notification settings - Fork 109
/
send.spec.ts
64 lines (55 loc) · 1.95 KB
/
send.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { toNano, beginCell } from "@ton/core";
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox";
import { SendTester } from "./contracts/output/send_SendTester";
import "@ton/test-utils";
describe("send", () => {
let blockchain: Blockchain;
let treasure: SandboxContract<TreasuryContract>;
let contract: SandboxContract<SendTester>;
beforeEach(async () => {
blockchain = await Blockchain.create();
blockchain.verbosity.print = false;
treasure = await blockchain.treasury("treasure");
contract = blockchain.openContract(await SendTester.fromInit());
const deployResult = await contract.send(
treasure.getSender(),
{ value: toNano("10") },
{ $$type: "Deploy", queryId: 0n },
);
expect(deployResult.transactions).toHaveTransaction({
from: treasure.address,
to: contract.address,
success: true,
deploy: true,
});
});
it("should send reply correctly", async () => {
const sendResult = await contract.send(
treasure.getSender(),
{ value: toNano("10") },
"Hello",
);
expect(sendResult.transactions).toHaveTransaction({
from: treasure.address,
to: contract.address,
success: true,
body: beginCell()
.storeUint(0, 32)
.storeStringTail("Hello")
.endCell(),
});
});
it("should bounce on unknown message", async () => {
const sendResult = await treasure.send({
to: contract.address,
value: toNano("10"),
body: beginCell().storeStringTail("Unknown").endCell(),
});
expect(sendResult.transactions).toHaveTransaction({
from: treasure.address,
to: contract.address,
success: false,
exitCode: 130,
});
});
});