Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: more tests #4

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/JettonMaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: true,
op: 0x133701,
});
expect(deployResult.transactions).toHaveTransaction({
from: jettonMaster.address,
to: deployer.address,
success: true,
deploy: false,
op: 0x133702,
});
});

Expand Down Expand Up @@ -92,6 +100,8 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: false,
deploy: false,
op: 0x133701,
exitCode: 6903,
});
});

Expand All @@ -116,6 +126,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: false,
deploy: false,
op: 0x133701,
exitCode: 132,
});
});
Expand All @@ -138,6 +149,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: false,
op: 0x133703,
});

// Jetton description
Expand All @@ -157,6 +169,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: false,
op: 0x133703,
});

// Jetton symbol
Expand All @@ -176,6 +189,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: false,
op: 0x133703,
});

// Jetton max_supply
Expand All @@ -195,6 +209,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: false,
op: 0x133703,
});

// Checks
Expand All @@ -221,12 +236,14 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: true,
deploy: false,
op: 0x133704,
});
expect(mintResult.transactions).toHaveTransaction({
from: jettonMaster.address,
to: jettonWallet.address,
success: true,
deploy: true,
op: 0x178d4519,
});

let jettonMasterMetadata = await jettonMaster.getGetJettonData();
Expand Down Expand Up @@ -254,6 +271,7 @@ describe('JettonMaster', () => {
to: jettonMaster.address,
success: false,
deploy: false,
op: 0x133704,
exitCode: 132,
});
});
Expand Down
62 changes: 61 additions & 1 deletion tests/JettonWallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox';
import { Builder, Slice, toNano } from '@ton/core';
import { Builder, toNano } from '@ton/core';
import { JettonWallet } from '../build/Jetton/tact_JettonWallet';
import { JettonMaster } from '../build/Jetton/tact_JettonMaster';
import '@ton/test-utils';
Expand Down Expand Up @@ -93,4 +93,64 @@ describe('JettonMaster', () => {
let otherJettonWalletData = await otherJettonWallet.getGetWalletData();
expect(otherJettonWalletData.balance).toEqual(toNano("228"));
});

it('should not transfer tokens not owner', async () => {
const transferResult = await jettonWallet.send(
other.getSender(),
{
value: toNano("0.05"),
},
{
$$type: 'JettonTransfer',
query_id: 0n,
amount: toNano("228"),
destination: other.address,
custom_payload: null,
forward_payload: new Builder().asSlice(),
forward_ton_amount: 0n,
response_destination: other.address,
}
);
expect(transferResult.transactions).toHaveTransaction({
from: other.address,
to: jettonWallet.address,
deploy: false,
success: false,
op: 0x0f8a7ea5,
exitCode: 132,
});

let jettonWalletData = await jettonWallet.getGetWalletData();
expect(jettonWalletData.balance).toEqual(toNano("1337"));
});

it('should not transfer tokens not enough amount', async () => {
const transferResult = await jettonWallet.send(
deployer.getSender(),
{
value: toNano("0.05"),
},
{
$$type: 'JettonTransfer',
query_id: 0n,
amount: toNano("100500"),
destination: other.address,
custom_payload: null,
forward_payload: new Builder().asSlice(),
forward_ton_amount: 0n,
response_destination: other.address,
}
);
expect(transferResult.transactions).toHaveTransaction({
from: deployer.address,
to: jettonWallet.address,
deploy: false,
success: false,
op: 0x0f8a7ea5,
exitCode: 6901,
});

let jettonWalletData = await jettonWallet.getGetWalletData();
expect(jettonWalletData.balance).toEqual(toNano("1337"));
});
});
Loading