1+ import { Address , Dictionary , OpenedContract , TupleBuilder , toNano } from 'ton-core' ;
12import { Blockchain , SandboxContract } from '@ton-community/sandbox' ;
2- import { toNano } from 'ton-core' ;
33import { MultitokenDex } from '../wrappers/MultitokenDex' ;
44import '@ton-community/test-utils' ;
55
66describe ( 'MultitokenDex' , ( ) => {
77 let blockchain : Blockchain ;
88 let multitokenDex : SandboxContract < MultitokenDex > ;
9+ const jettonMasters = [
10+ "EQAMcImLBgZHazWmradz51pI0uHZwvxMONlMQy0QwQTQInD5" ,
11+ "kQAbDiNBKXDn5l3AE8cx-j7zZneFITRRFM-FH-HfBJqsrTLh"
12+ ] . map ( elem => Address . parse ( elem ) ) ;
913
1014 beforeEach ( async ( ) => {
1115 blockchain = await Blockchain . create ( ) ;
12-
13- multitokenDex = blockchain . openContract ( await MultitokenDex . fromInit ( ) ) ;
14-
16+
1517 const deployer = await blockchain . treasury ( 'deployer' ) ;
1618
17- const deployResult = await multitokenDex . send (
18- deployer . getSender ( ) ,
19- {
20- value : toNano ( '0.05' ) ,
21- } ,
22- {
23- $$type : 'Deploy' ,
24- queryId : 0n ,
25- }
26- ) ;
19+ multitokenDex = blockchain . openContract (
20+ await MultitokenDex . fromInit ( 1n , deployer . address , BigInt ( jettonMasters . length ) ) ) ;
2721
22+ const deployResult = await multitokenDex . send ( deployer . getSender ( ) ,
23+ { value : toNano ( '0.05' ) , } ,
24+ { $$type : 'Deploy' , queryId : 0n , } ) ;
2825 expect ( deployResult . transactions ) . toHaveTransaction ( {
2926 from : deployer . address ,
3027 to : multitokenDex . address ,
@@ -33,8 +30,39 @@ describe('MultitokenDex', () => {
3330 } ) ;
3431 } ) ;
3532
36- it ( 'should deploy' , async ( ) => {
37- // the check is done inside beforeEach
38- // blockchain and multitokenDex are ready to use
33+ it ( 'should initialize' , async ( ) => {
34+ // owner
35+ const deployer = await blockchain . treasury ( 'deployer' ) ;
36+
37+ // args to get_wallet_address get-method
38+ let tuple = new TupleBuilder ( ) ; tuple . writeAddress ( multitokenDex . address ) ;
39+ let dict : Dictionary < Address , Address > = Dictionary . empty ( ) ;
40+
41+ // filling jetton wallets list
42+ for ( let item of jettonMasters ) {
43+ let get_result = blockchain . provider ( item ) . get ( "get_wallet_address" , tuple . build ( ) ) ;
44+ dict . set ( item , get_result . stack . readAddress ( ) ) ;
45+ }
46+
47+ const initResult = await multitokenDex . send ( deployer . getSender ( ) ,
48+ { value : toNano ( '0.2' ) , bounce : false , } ,
49+ { $$type : 'DexDeploy' , query_id : 12n , jetton_wallets : dict , } ) ;
50+ expect ( initResult . transactions ) . toHaveTransaction ( {
51+ from : deployer . address ,
52+ to : multitokenDex . address ,
53+ deploy : false ,
54+ success : true
55+ } ) ;
56+ } ) ;
57+
58+ it ( 'should report zero balances' , async ( ) => {
59+ const swapBase = await multitokenDex . getGetSwapBase ( ) ;
60+ expect ( swapBase ) . toStrictEqual ( 0n ) ;
61+ } ) ;
62+
63+ it ( 'should offer zero swap until funded' , async ( ) => {
64+ const offeredJettons = await multitokenDex . getCalcSwapByMasterAddrs (
65+ jettonMasters [ 0 ] , jettonMasters [ 1 ] , 1000000n ) ;
66+ expect ( offeredJettons ) . toStrictEqual ( 0n ) ;
3967 } ) ;
4068} ) ;
0 commit comments