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.
39 lines
1.6 KiB
39 lines
1.6 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'; |
|
import { beginCell } from 'ton-core'; |
|
|
|
|
|
|
|
describe('jetton', () => { |
|
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 |
|
await contract.send(owner, { value: toNano('1.2') }, { $$type: 'Deposit', amount: toNano('1') }); |
|
let log = await system.run(); |
|
await system.run(); |
|
let events = tracker.events(); |
|
expect(events).toMatchSnapshot(); |
|
|
|
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()); |
|
|
|
}); |
|
}); |