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.
 
 

52 lines
2.3 KiB

import { toNano, Address } from "ton";
import { ContractSystem } from "ton-emulator";
import {SampleJetton} from './output/jetton_SampleJetton';
import { default_content } from './config';
import { JettonDefaultWallet } from './output/jetton_JettonDefaultWallet';
import { toBufferBE } from "bigint-buffer";
describe('jetton', () => {
it('should deploy', async () => {
// Create jetton
let system = await ContractSystem.create();
let owner = system.treasure('owner');
let contract = system.open(await SampleJetton.fromInit(owner.address, default_content));
let tracker = system.track(contract.address);
let wallet_contract = system.open(await JettonDefaultWallet.fromInit(contract.address, owner.address));
let wallet_tracker = system.track(wallet_contract.address);
// Mint
let res1 = await contract.send(owner, { value: toNano(1) }, { $$type: 'Mint', amount: toNano(1000000) });
let res = await system.run();
console.log(res1)
console.log(res)
expect(tracker.events()).toMatchSnapshot();
// expect(wallet_tracker.events()).toMatchSnapshot();
let addr_get = await contract.getGetWalletAddress(owner.address);
let addr = toBufferBE(res[1].address, owner.address.hash.length);
// console.log(await wallet_contract.getGetWalletData());
console.log((new Address(0, addr)).toString())
console.log(wallet_contract.address.toString())
let wc_proto = await JettonDefaultWallet.fromInit(contract.address, owner.address);
// wc_proto.address = new Address(0, addr);
let wallet_contract_2 = system.contract(new Address(0, addr));
let wdata = (await wallet_contract_2.get(97026, [])) as any;
console.log('wdata', wdata, )
console.log(wdata.stack)
console.log(wallet_contract.address.toString(), addr_get.toString());
// let c = system.open({address: addr, abi: wallet_contract.abi});
// console.log(await c.abi.getGetWalletData());
// Check owner
expect((await contract.getOwner()).toString()).toEqual(owner.address.toString());
// Data
let data = await contract.getGetJettonData();
// console.warn(data);
console.log(tracker.events())
});
});