Skip to content

Commit

Permalink
chore: more tests (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ya7on authored Sep 28, 2024
1 parent c349c85 commit 58f338a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
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"));
});
});

0 comments on commit 58f338a

Please sign in to comment.