@@ -148,7 +148,7 @@ describe('AccountRestrictionTransaction', () => {
148148 expect ( addressRestrictionTransaction . maxFee . lower ) . to . be . equal ( 1 ) ;
149149 } ) ;
150150
151- it ( 'should create address restriction transaction' , ( ) => {
151+ it ( 'should create allow incmoing address restriction transaction' , ( ) => {
152152
153153 const address = Address . createFromRawAddress ( 'SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC' ) ;
154154 const addressRestrictionFilter = AccountRestrictionModification . createForAddress (
@@ -179,15 +179,24 @@ describe('AccountRestrictionTransaction', () => {
179179 address ,
180180 ) ;
181181
182- expect ( ( ) => {
183- AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
184- Deadline . create ( ) ,
185- AccountRestrictionType . Sentinel ,
186- [ addressRestrictionFilter ] ,
187- NetworkType . MIJIN_TEST ,
188- ) ;
189- } ) . to . throw ( Error , 'Restriction type is not allowed.' ) ;
190-
182+ const invalidType = [ AccountRestrictionType . AllowIncomingTransactionType ,
183+ AccountRestrictionType . AllowMosaic ,
184+ AccountRestrictionType . AllowOutgoingTransactionType ,
185+ AccountRestrictionType . BlockIncomingTransactionType ,
186+ AccountRestrictionType . BlockMosaic ,
187+ AccountRestrictionType . BlockOutgoingTransactionType ,
188+ AccountRestrictionType . Sentinel ,
189+ ] ;
190+ invalidType . forEach ( ( type ) => {
191+ expect ( ( ) => {
192+ AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
193+ Deadline . create ( ) ,
194+ type ,
195+ [ addressRestrictionFilter ] ,
196+ NetworkType . MIJIN_TEST ,
197+ ) ;
198+ } ) . to . throw ( Error , 'Restriction type is not allowed.' ) ;
199+ } ) ;
191200 } ) ;
192201
193202 it ( 'should create mosaic restriction transaction' , ( ) => {
@@ -213,23 +222,34 @@ describe('AccountRestrictionTransaction', () => {
213222
214223 } ) ;
215224
216- it ( 'should throw exception when create mosaic restriction transaction with wrong type' , ( ) => {
225+ it ( 'should throw exception when create account mosaic restriction transaction with wrong type' , ( ) => {
217226
218227 const mosaicId = new MosaicId ( [ 2262289484 , 3405110546 ] ) ;
219228 const mosaicRestrictionFilter = AccountRestrictionModification . createForMosaic (
220229 RestrictionModificationType . Add ,
221230 mosaicId ,
222231 ) ;
223232
224- expect ( ( ) => {
225- AccountRestrictionTransaction . createMosaicRestrictionModificationTransaction (
226- Deadline . create ( ) ,
227- AccountRestrictionType . Sentinel ,
228- [ mosaicRestrictionFilter ] ,
229- NetworkType . MIJIN_TEST ,
230- ) ;
231- } ) . to . throw ( Error , 'Restriction type is not allowed.' ) ;
232-
233+ const invalidType = [ AccountRestrictionType . AllowIncomingTransactionType ,
234+ AccountRestrictionType . AllowIncomingAddress ,
235+ AccountRestrictionType . AllowOutgoingTransactionType ,
236+ AccountRestrictionType . BlockIncomingTransactionType ,
237+ AccountRestrictionType . AllowOutgoingAddress ,
238+ AccountRestrictionType . BlockOutgoingTransactionType ,
239+ AccountRestrictionType . BlockIncomingAddress ,
240+ AccountRestrictionType . BlockOutgoingAddress ,
241+ AccountRestrictionType . Sentinel ,
242+ ] ;
243+ invalidType . forEach ( ( type ) => {
244+ expect ( ( ) => {
245+ AccountRestrictionTransaction . createMosaicRestrictionModificationTransaction (
246+ Deadline . create ( ) ,
247+ type ,
248+ [ mosaicRestrictionFilter ] ,
249+ NetworkType . MIJIN_TEST ,
250+ ) ;
251+ } ) . to . throw ( Error , 'Restriction type is not allowed.' ) ;
252+ } ) ;
233253 } ) ;
234254
235255 it ( 'should create operation restriction transaction' , ( ) => {
@@ -254,4 +274,106 @@ describe('AccountRestrictionTransaction', () => {
254274 ) ) . to . be . equal ( '0401004E42' ) ;
255275
256276 } ) ;
277+
278+ it ( 'should throw exception when create account operation restriction transaction with wrong type' , ( ) => {
279+
280+ const operation = TransactionType . ADDRESS_ALIAS ;
281+ const operationRestrictionFilter = AccountRestrictionModification . createForOperation (
282+ RestrictionModificationType . Add ,
283+ operation ,
284+ ) ;
285+
286+ const invalidType = [ AccountRestrictionType . AllowIncomingAddress ,
287+ AccountRestrictionType . AllowMosaic ,
288+ AccountRestrictionType . BlockMosaic ,
289+ AccountRestrictionType . AllowOutgoingAddress ,
290+ AccountRestrictionType . BlockIncomingAddress ,
291+ AccountRestrictionType . BlockOutgoingAddress ,
292+ AccountRestrictionType . Sentinel ,
293+ ] ;
294+ invalidType . forEach ( ( type ) => {
295+ expect ( ( ) => {
296+ AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
297+ Deadline . create ( ) ,
298+ type ,
299+ [ operationRestrictionFilter ] ,
300+ NetworkType . MIJIN_TEST ,
301+ ) ;
302+ } ) . to . throw ( Error , 'Restriction type is not allowed.' ) ;
303+ } ) ;
304+ } ) ;
305+
306+ it ( 'should create outgoing address restriction transaction' , ( ) => {
307+
308+ const address = Address . createFromRawAddress ( 'SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC' ) ;
309+ const addressRestrictionFilter = AccountRestrictionModification . createForAddress (
310+ RestrictionModificationType . Add ,
311+ address ,
312+ ) ;
313+ let addressRestrictionTransaction = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
314+ Deadline . create ( ) ,
315+ AccountRestrictionType . AllowOutgoingAddress ,
316+ [ addressRestrictionFilter ] ,
317+ NetworkType . MIJIN_TEST ,
318+ ) ;
319+
320+ let signedTransaction = addressRestrictionTransaction . signWith ( account , generationHash ) ;
321+
322+ expect ( signedTransaction . payload . substring (
323+ 240 ,
324+ signedTransaction . payload . length ,
325+ ) ) . to . be . equal ( '4101009050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E142' ) ;
326+
327+ addressRestrictionTransaction = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
328+ Deadline . create ( ) ,
329+ AccountRestrictionType . BlockOutgoingAddress ,
330+ [ addressRestrictionFilter ] ,
331+ NetworkType . MIJIN_TEST ,
332+ ) ;
333+
334+ signedTransaction = addressRestrictionTransaction . signWith ( account , generationHash ) ;
335+
336+ expect ( signedTransaction . payload . substring (
337+ 240 ,
338+ signedTransaction . payload . length ,
339+ ) ) . to . be . equal ( 'C101009050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E142' ) ;
340+
341+ } ) ;
342+
343+ it ( 'should create outgoing operation restriction transaction' , ( ) => {
344+
345+ const operation = TransactionType . ADDRESS_ALIAS ;
346+ const operationRestrictionFilter = AccountRestrictionModification . createForOperation (
347+ RestrictionModificationType . Add ,
348+ operation ,
349+ ) ;
350+ let operationRestrictionTransaction = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
351+ Deadline . create ( ) ,
352+ AccountRestrictionType . AllowOutgoingTransactionType ,
353+ [ operationRestrictionFilter ] ,
354+ NetworkType . MIJIN_TEST ,
355+ ) ;
356+
357+ let signedTransaction = operationRestrictionTransaction . signWith ( account , generationHash ) ;
358+
359+ expect ( signedTransaction . payload . substring (
360+ 240 ,
361+ signedTransaction . payload . length ,
362+ ) ) . to . be . equal ( '4401004E42' ) ;
363+
364+ operationRestrictionTransaction = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
365+ Deadline . create ( ) ,
366+ AccountRestrictionType . BlockOutgoingTransactionType ,
367+ [ operationRestrictionFilter ] ,
368+ NetworkType . MIJIN_TEST ,
369+ ) ;
370+
371+ signedTransaction = operationRestrictionTransaction . signWith ( account , generationHash ) ;
372+
373+ expect ( signedTransaction . payload . substring (
374+ 240 ,
375+ signedTransaction . payload . length ,
376+ ) ) . to . be . equal ( 'C401004E42' ) ;
377+
378+ } ) ;
257379} ) ;
0 commit comments