@@ -37,7 +37,6 @@ import { Deadline } from '../../src/model/transaction/Deadline';
3737import { MosaicAddressRestrictionTransaction } from '../../src/model/transaction/MosaicAddressRestrictionTransaction' ;
3838import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction' ;
3939import { MosaicGlobalRestrictionTransaction } from '../../src/model/transaction/MosaicGlobalRestrictionTransaction' ;
40- import { Transaction } from '../../src/model/transaction/Transaction' ;
4140import { UInt64 } from '../../src/model/UInt64' ;
4241
4342describe ( 'RestrictionHttp' , ( ) => {
@@ -259,10 +258,10 @@ describe('RestrictionHttp', () => {
259258 describe ( 'getMosaicAddressRestriction' , ( ) => {
260259 it ( 'should call getMosaicAddressRestriction successfully' , ( done ) => {
261260 setTimeout ( ( ) => {
262- restrictionHttp . getMosaicAddressRestriction ( mosaicId , accountAddress ) . subscribe ( ( mosaicRestriction ) => {
261+ restrictionHttp . getMosaicAddressRestriction ( mosaicId , account3 . address ) . subscribe ( ( mosaicRestriction ) => {
263262 deepEqual ( mosaicRestriction . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
264263 deepEqual ( mosaicRestriction . entryType , MosaicRestrictionEntryType . ADDRESS ) ;
265- deepEqual ( mosaicRestriction . targetAddress . plain ( ) , accountAddress . plain ( ) ) ;
264+ deepEqual ( mosaicRestriction . targetAddress . plain ( ) , account3 . address . plain ( ) ) ;
266265 deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
267266 done ( ) ;
268267 } ) ;
@@ -273,10 +272,10 @@ describe('RestrictionHttp', () => {
273272 describe ( 'getMosaicAddressRestrictions' , ( ) => {
274273 it ( 'should call getMosaicAddressRestrictions successfully' , ( done ) => {
275274 setTimeout ( ( ) => {
276- restrictionHttp . getMosaicAddressRestrictions ( mosaicId , [ accountAddress ] ) . subscribe ( ( mosaicRestriction ) => {
275+ restrictionHttp . getMosaicAddressRestrictions ( mosaicId , [ account3 . address ] ) . subscribe ( ( mosaicRestriction ) => {
277276 deepEqual ( mosaicRestriction [ 0 ] . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
278277 deepEqual ( mosaicRestriction [ 0 ] . entryType , MosaicRestrictionEntryType . ADDRESS ) ;
279- deepEqual ( mosaicRestriction [ 0 ] . targetAddress . plain ( ) , accountAddress . plain ( ) ) ;
278+ deepEqual ( mosaicRestriction [ 0 ] . targetAddress . plain ( ) , account3 . address . plain ( ) ) ;
280279 deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
281280 done ( ) ;
282281 } ) ;
@@ -290,7 +289,12 @@ describe('RestrictionHttp', () => {
290289 restrictionHttp . getMosaicGlobalRestriction ( mosaicId ) . subscribe ( ( mosaicRestriction ) => {
291290 deepEqual ( mosaicRestriction . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
292291 deepEqual ( mosaicRestriction . entryType , MosaicRestrictionEntryType . GLOBAL ) ;
293- deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
292+ deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . referenceMosaicId . toHex ( ) ,
293+ new MosaicId ( UInt64 . fromUint ( 0 ) . toHex ( ) ) . toHex ( ) ) ;
294+ deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionType ,
295+ MosaicRestrictionType . GE ) ;
296+ deepEqual ( mosaicRestriction . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionValue . toString ( ) ,
297+ UInt64 . fromUint ( 0 ) . toString ( ) ) ;
294298 done ( ) ;
295299 } ) ;
296300 } , 1000 ) ;
@@ -303,10 +307,54 @@ describe('RestrictionHttp', () => {
303307 restrictionHttp . getMosaicGlobalRestrictions ( [ mosaicId ] ) . subscribe ( ( mosaicRestriction ) => {
304308 deepEqual ( mosaicRestriction [ 0 ] . mosaicId . toHex ( ) , mosaicId . toHex ( ) ) ;
305309 deepEqual ( mosaicRestriction [ 0 ] . entryType , MosaicRestrictionEntryType . GLOBAL ) ;
306- deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) , UInt64 . fromUint ( 2 ) . toString ( ) ) ;
310+ deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . referenceMosaicId . toHex ( ) ,
311+ new MosaicId ( UInt64 . fromUint ( 0 ) . toHex ( ) ) . toHex ( ) ) ;
312+ deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionType ,
313+ MosaicRestrictionType . GE ) ;
314+ deepEqual ( mosaicRestriction [ 0 ] . restrictions [ 0 ] . get ( UInt64 . fromUint ( 60641 ) . toHex ( ) ) ! . restrictionValue . toString ( ) ,
315+ UInt64 . fromUint ( 0 ) . toString ( ) ) ;
307316 done ( ) ;
308317 } ) ;
309318 } , 1000 ) ;
310319 } ) ;
311320 } ) ;
321+
322+ /**
323+ * =========================
324+ * House Keeping
325+ * =========================
326+ */
327+ describe ( 'Remove test AccountRestriction - Address' , ( ) => {
328+ let listener : Listener ;
329+ before ( ( ) => {
330+ listener = new Listener ( config . apiUrl ) ;
331+ return listener . open ( ) ;
332+ } ) ;
333+ after ( ( ) => {
334+ return listener . close ( ) ;
335+ } ) ;
336+
337+ it ( 'Announce AccountRestrictionTransaction' , ( done ) => {
338+ const addressPropertyFilter = AccountRestrictionModification . createForAddress (
339+ AccountRestrictionModificationAction . Remove ,
340+ account3 . address ,
341+ ) ;
342+ const addressModification = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
343+ Deadline . create ( ) ,
344+ AccountRestrictionType . AllowIncomingAddress ,
345+ [ addressPropertyFilter ] ,
346+ NetworkType . MIJIN_TEST ,
347+ ) ;
348+ const signedTransaction = addressModification . signWith ( account , generationHash ) ;
349+ listener . confirmed ( account . address ) . subscribe ( ( ) => {
350+ done ( ) ;
351+ } ) ;
352+ listener . status ( account . address ) . subscribe ( ( error ) => {
353+ console . log ( 'Error:' , error ) ;
354+ assert ( false ) ;
355+ done ( ) ;
356+ } ) ;
357+ transactionHttp . announce ( signedTransaction ) ;
358+ } ) ;
359+ } ) ;
312360} ) ;
0 commit comments