You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.8 KiB

import { toNano, Address } from "ton";
import { ContractSystem } from "ton-emulator";
import {TONB} from '../output/jetton_TONB';
import { default_content } from '../utils/config';
import { TONBWallet } from '../output/jetton_TONBWallet';
2 years ago
import { beginCell } from 'ton-core';
describe('jetton', () => {
2 years ago
it('should deploy and deposit the wallet with the correct sum of money', async () => {
// Create jetton
let system = await ContractSystem.create();
let owner = system.treasure('owner');
let contract = system.open(await TONB.fromInit(owner.address, default_content));
let tracker = system.track(contract.address);
// Mint
2 years ago
await contract.send(owner, { value: toNano('1.2') }, { $$type: 'Deposit', amount: toNano('1') });
let log = await system.run();
let events = tracker.events();
expect(events).toMatchSnapshot();
2 years ago
let addr = Address.parse((events[4] as any).messages[0].to);
let wallet_contract = system.contract(addr);
let wdata = ((await wallet_contract.get(97026, [])) as any).stack.items;
expect(wdata[0].value).toEqual(1000000000n);
let linker_contract = system.contract(Address.parse((events[3] as any).messages[0].to));
let linker_owner = ((await linker_contract.get('owner', [])) as any).stack.items[0];
expect(linker_owner.cell.toBoc()).toEqual(beginCell().storeAddress(addr).endCell().toBoc());
// Check owner
expect((await contract.getOwner()).toString()).toEqual(owner.address.toString());
// Withdraw
await contract.send(owner, { value: toNano('0.15') }, { $$type: 'Withdraw', amount: toNano('0.3') });
log = await system.run();
events = tracker.events();
expect((events[5] as any).messages[0].value).toBeGreaterThan(toNano('0.29'));
});
});