@@ -54,6 +54,7 @@ describe('RestrictionHttp', () => {
5454 let restrictionHttp : RestrictionHttp ;
5555 let transactionHttp : TransactionHttp ;
5656 let mosaicId : MosaicId ;
57+ let referenceMosaicId : MosaicId ;
5758 let generationHash : string ;
5859 let config ;
5960
@@ -122,6 +123,40 @@ describe('RestrictionHttp', () => {
122123 } ) ;
123124 } ) ;
124125
126+ describe ( 'MosaicDefinitionTransaction' , ( ) => {
127+ let listener : Listener ;
128+ before ( ( ) => {
129+ listener = new Listener ( config . apiUrl ) ;
130+ return listener . open ( ) ;
131+ } ) ;
132+ after ( ( ) => {
133+ return listener . close ( ) ;
134+ } ) ;
135+ it ( 'standalone' , ( done ) => {
136+ const nonce = MosaicNonce . createRandom ( ) ;
137+ referenceMosaicId = MosaicId . createFromNonce ( nonce , account . publicAccount ) ;
138+ const mosaicDefinitionTransaction = MosaicDefinitionTransaction . create (
139+ Deadline . create ( ) ,
140+ nonce ,
141+ referenceMosaicId ,
142+ MosaicFlags . create ( true , true , true ) ,
143+ 3 ,
144+ UInt64 . fromUint ( 1000 ) ,
145+ NetworkType . MIJIN_TEST ,
146+ ) ;
147+ const signedTransaction = mosaicDefinitionTransaction . signWith ( account , generationHash ) ;
148+ listener . confirmed ( account . address ) . subscribe ( ( ) => {
149+ done ( ) ;
150+ } ) ;
151+ listener . status ( account . address ) . subscribe ( ( error ) => {
152+ console . log ( 'Error:' , error ) ;
153+ assert ( false ) ;
154+ done ( ) ;
155+ } ) ;
156+ transactionHttp . announce ( signedTransaction ) ;
157+ } ) ;
158+ } ) ;
159+
125160 describe ( 'Setup Test AccountAddressRestriction' , ( ) => {
126161 let listener : Listener ;
127162 before ( ( ) => {
@@ -156,7 +191,42 @@ describe('RestrictionHttp', () => {
156191 } ) ;
157192 } ) ;
158193
159- describe ( 'MosaicGlobalRestrictionTransaction' , ( ) => {
194+ describe ( 'MosaicGlobalRestrictionTransaction - Reference' , ( ) => {
195+ let listener : Listener ;
196+ before ( ( ) => {
197+ listener = new Listener ( config . apiUrl ) ;
198+ return listener . open ( ) ;
199+ } ) ;
200+ after ( ( ) => {
201+ return listener . close ( ) ;
202+ } ) ;
203+
204+ it ( 'standalone' , ( done ) => {
205+ const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction . create (
206+ Deadline . create ( ) ,
207+ referenceMosaicId ,
208+ UInt64 . fromUint ( 60641 ) ,
209+ UInt64 . fromUint ( 0 ) ,
210+ MosaicRestrictionType . NONE ,
211+ UInt64 . fromUint ( 0 ) ,
212+ MosaicRestrictionType . GE ,
213+ NetworkType . MIJIN_TEST ,
214+ ) ;
215+ const signedTransaction = mosaicGlobalRestrictionTransaction . signWith ( account , generationHash ) ;
216+
217+ listener . confirmed ( account . address ) . subscribe ( ( ) => {
218+ done ( ) ;
219+ } ) ;
220+ listener . status ( account . address ) . subscribe ( ( error ) => {
221+ console . log ( 'Error:' , error ) ;
222+ assert ( false ) ;
223+ done ( ) ;
224+ } ) ;
225+ transactionHttp . announce ( signedTransaction ) ;
226+ } ) ;
227+ } ) ;
228+
229+ describe ( 'MosaicGlobalRestrictionTransaction - with referenceMosaicId' , ( ) => {
160230 let listener : Listener ;
161231 before ( ( ) => {
162232 listener = new Listener ( config . apiUrl ) ;
@@ -176,6 +246,8 @@ describe('RestrictionHttp', () => {
176246 UInt64 . fromUint ( 0 ) ,
177247 MosaicRestrictionType . GE ,
178248 NetworkType . MIJIN_TEST ,
249+ // TODO:
250+ // referenceMosaicId,
179251 ) ;
180252 const signedTransaction = mosaicGlobalRestrictionTransaction . signWith ( account , generationHash ) ;
181253
@@ -262,7 +334,7 @@ describe('RestrictionHttp', () => {
262334 deepEqual ( mosaicRestriction . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
263335 deepEqual ( mosaicRestriction . entryType , MosaicRestrictionEntryType . ADDRESS ) ;
264336 deepEqual ( mosaicRestriction . targetAddress . plain ( ) , account3 . address . plain ( ) ) ;
265- deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
337+ deepEqual ( mosaicRestriction . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
266338 done ( ) ;
267339 } ) ;
268340 } , 1000 ) ;
@@ -276,7 +348,7 @@ describe('RestrictionHttp', () => {
276348 deepEqual ( mosaicRestriction [ 0 ] . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
277349 deepEqual ( mosaicRestriction [ 0 ] . entryType , MosaicRestrictionEntryType . ADDRESS ) ;
278350 deepEqual ( mosaicRestriction [ 0 ] . targetAddress . plain ( ) , account3 . address . plain ( ) ) ;
279- deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
351+ deepEqual ( mosaicRestriction [ 0 ] . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
280352 done ( ) ;
281353 } ) ;
282354 } , 1000 ) ;
@@ -289,11 +361,11 @@ describe('RestrictionHttp', () => {
289361 restrictionHttp . getMosaicGlobalRestriction ( mosaicId ) . subscribe ( ( mosaicRestriction ) => {
290362 deepEqual ( mosaicRestriction . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
291363 deepEqual ( mosaicRestriction . entryType , MosaicRestrictionEntryType . GLOBAL ) ;
292- deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . referenceMosaicId . toHex ( ) ,
364+ deepEqual ( mosaicRestriction . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . referenceMosaicId . toHex ( ) ,
293365 new MosaicId ( UInt64 . fromUint ( 0 ) . toHex ( ) ) . toHex ( ) ) ;
294- deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionType ,
366+ deepEqual ( mosaicRestriction . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . restrictionType ,
295367 MosaicRestrictionType . GE ) ;
296- deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionValue . toString ( ) ,
368+ deepEqual ( mosaicRestriction . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . restrictionValue . toString ( ) ,
297369 UInt64 . fromUint ( 0 ) . toString ( ) ) ;
298370 done ( ) ;
299371 } ) ;
@@ -307,11 +379,11 @@ describe('RestrictionHttp', () => {
307379 restrictionHttp . getMosaicGlobalRestrictions ( [ mosaicId ] ) . subscribe ( ( mosaicRestriction ) => {
308380 deepEqual ( mosaicRestriction [ 0 ] . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
309381 deepEqual ( mosaicRestriction [ 0 ] . entryType , MosaicRestrictionEntryType . GLOBAL ) ;
310- deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . referenceMosaicId . toHex ( ) ,
382+ deepEqual ( mosaicRestriction [ 0 ] . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . referenceMosaicId . toHex ( ) ,
311383 new MosaicId ( UInt64 . fromUint ( 0 ) . toHex ( ) ) . toHex ( ) ) ;
312- deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionType ,
384+ deepEqual ( mosaicRestriction [ 0 ] . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . restrictionType ,
313385 MosaicRestrictionType . GE ) ;
314- deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionValue . toString ( ) ,
386+ deepEqual ( mosaicRestriction [ 0 ] . restrictions . get ( UInt64 . fromUint ( 60641 ) . toString ( ) ) ! . restrictionValue . toString ( ) ,
315387 UInt64 . fromUint ( 0 ) . toString ( ) ) ;
316388 done ( ) ;
317389 } ) ;
0 commit comments