11import { assert } from "chai" ;
22import { AsyncTimer } from "../asyncTimer" ;
3+ import { GasEstimator } from "../gasEstimator" ;
34import { INetworkConfig , ITransactionOnNetwork } from "../interfaceOfNetwork" ;
45import { loadTestWallets , TestWallet } from "../testutils" ;
56import { createTestnetProvider , INetworkProvider } from "../testutils/networkProviders" ;
7+ import { TokenPayment } from "../tokenPayment" ;
68import { Transaction } from "../transaction" ;
79import { TransactionWatcher } from "../transactionWatcher" ;
10+ import { TransfersFactory } from "../transfersFactory" ;
811import { TokenOperationsFactory } from "./tokenOperationsFactory" ;
912import { TokenOperationsFactoryConfig } from "./tokenOperationsFactoryConfig" ;
1013import { TokenOperationsOutcomeParser } from "./tokenOperationsOutcomeParser" ;
@@ -16,6 +19,7 @@ describe("test factory on testnet", function () {
1619 let network : INetworkConfig ;
1720 let factory : TokenOperationsFactory ;
1821 let parser : TokenOperationsOutcomeParser ;
22+ let transfersFactory : TransfersFactory ;
1923
2024 before ( async function ( ) {
2125 console . log ( `> ${ this . currentTest ?. title } ...` ) ;
@@ -27,6 +31,7 @@ describe("test factory on testnet", function () {
2731 network = await provider . getNetworkConfig ( ) ;
2832 factory = new TokenOperationsFactory ( new TokenOperationsFactoryConfig ( network . ChainID ) ) ;
2933 parser = new TokenOperationsOutcomeParser ( ) ;
34+ transfersFactory = new TransfersFactory ( new GasEstimator ( ) ) ;
3035 } ) ;
3136
3237 it ( "should issue fungible, mint, burn" , async function ( ) {
@@ -99,8 +104,8 @@ describe("test factory on testnet", function () {
99104 assert . equal ( tx4Outcome . burntSupply , "50" ) ;
100105 } ) ;
101106
102- it ( "should issue fungible, pause, unpause, freeze, unfreeze " , async function ( ) {
103- this . timeout ( 120000 ) ;
107+ it ( "should issue fungible, pause, unpause" , async function ( ) {
108+ this . timeout ( 240000 ) ;
104109 await frank . sync ( provider ) ;
105110
106111 // Issue
@@ -148,17 +153,87 @@ describe("test factory on testnet", function () {
148153 const tx3OnNetwork = await processTransaction ( frank , tx3 , "tx3" ) ;
149154 const _tx3Outcome = parser . parseUnpause ( tx3OnNetwork ) ;
150155
156+ // Send some tokens to Grace
157+ const tx4 = transfersFactory . createESDTTransfer ( {
158+ payment : TokenPayment . fungibleFromBigInteger ( tokenIdentifier , 10 ) ,
159+ sender : frank . account . address ,
160+ receiver : grace . account . address ,
161+ chainID : network . ChainID ,
162+ nonce : frank . account . nonce
163+ } ) ;
164+
165+ const _tx4OnNetwork = await processTransaction ( frank , tx4 , "tx4" ) ;
166+ } ) ;
167+
168+ it ( "should issue fungible, freeze, unfreeze" , async function ( ) {
169+ this . timeout ( 240000 ) ;
170+ await frank . sync ( provider ) ;
171+
172+ // Issue
173+ const tx1 = factory . issueFungible ( {
174+ issuer : frank . address ,
175+ tokenName : "FRANK" ,
176+ tokenTicker : "FRANK" ,
177+ initialSupply : 100 ,
178+ numDecimals : 0 ,
179+ canFreeze : true ,
180+ canWipe : true ,
181+ canPause : true ,
182+ canMint : true ,
183+ canBurn : true ,
184+ canChangeOwner : true ,
185+ canUpgrade : true ,
186+ canAddSpecialRoles : true ,
187+ nonce : frank . account . nonce
188+ } ) ;
189+
190+ const tx1OnNetwork = await processTransaction ( frank , tx1 , "tx1" ) ;
191+ const tx1Outcome = parser . parseIssueFungible ( tx1OnNetwork ) ;
192+ const tokenIdentifier = tx1Outcome . tokenIdentifier ;
193+ assert . isTrue ( tokenIdentifier . includes ( "FRANK" ) ) ;
194+
195+ // Send some tokens to Grace
196+ const tx2 = transfersFactory . createESDTTransfer ( {
197+ payment : TokenPayment . fungibleFromBigInteger ( tokenIdentifier , 10 ) ,
198+ sender : frank . account . address ,
199+ receiver : grace . account . address ,
200+ chainID : network . ChainID ,
201+ nonce : frank . account . nonce
202+ } ) ;
203+
204+ const _tx2OnNetwork = await processTransaction ( frank , tx2 , "tx2" ) ;
205+
151206 // Freeze
152- const tx4 = factory . freeze ( {
207+ const tx3 = factory . freeze ( {
153208 freeze : true ,
154209 manager : frank . address ,
155210 user : grace . address ,
156211 tokenIdentifier : tokenIdentifier ,
157212 nonce : frank . account . nonce
158213 } ) ;
159214
215+ const tx3OnNetwork = await processTransaction ( frank , tx3 , "tx3" ) ;
216+ const tx3Outcome = parser . parseFreeze ( tx3OnNetwork ) ;
217+ assert . equal ( tx3Outcome . userAddress , grace . address . bech32 ( ) ) ;
218+ assert . equal ( tx3Outcome . tokenIdentifier , tokenIdentifier ) ;
219+ assert . equal ( tx3Outcome . nonce , 0 ) ;
220+ assert . equal ( tx3Outcome . balance , "10" ) ;
221+
222+ // Unfreeze
223+ const tx4 = factory . freeze ( {
224+ unfreeze : true ,
225+ manager : frank . address ,
226+ user : grace . address ,
227+ tokenIdentifier : tokenIdentifier ,
228+ nonce : frank . account . nonce
229+ } ) ;
230+
160231 const tx4OnNetwork = await processTransaction ( frank , tx4 , "tx4" ) ;
161- // const _tx4Outcome = parser.parseFreeze(tx4OnNetwork);
232+ const tx4Outcome = parser . parseUnfreeze ( tx4OnNetwork ) ;
233+ assert . equal ( tx4Outcome . userAddress , grace . address . bech32 ( ) ) ;
234+ assert . equal ( tx4Outcome . tokenIdentifier , tokenIdentifier ) ;
235+ assert . equal ( tx4Outcome . nonce , 0 ) ;
236+ assert . equal ( tx4Outcome . balance , "10" ) ;
162237 } ) ;
163238
164239 it ( "should issue and create NFT" , async function ( ) {
0 commit comments