@@ -14,7 +14,9 @@ namespace Lib9c.Tests.Action
1414 using Nekoyume . Action ;
1515 using Nekoyume . Helper ;
1616 using Nekoyume . Model ;
17+ using Nekoyume . Model . Stake ;
1718 using Nekoyume . Model . State ;
19+ using Nekoyume . TableData ;
1820 using Xunit ;
1921
2022 public class TransferAssetsTest
@@ -271,7 +273,7 @@ public void PlainValue(string memo)
271273
272274 var recipients = ( List ) values [ "recipients" ] ;
273275 var info = ( List ) recipients [ 0 ] ;
274- Assert . Equal ( ( Text ) "transfer_assets2 " , plainValue [ "type_id" ] ) ;
276+ Assert . Equal ( ( Text ) "transfer_assets3 " , plainValue [ "type_id" ] ) ;
275277 Assert . Equal ( _sender , values [ "sender" ] . ToAddress ( ) ) ;
276278 Assert . Equal ( _recipient , info [ 0 ] . ToAddress ( ) ) ;
277279 Assert . Equal ( _currency * 100 , info [ 1 ] . ToFungibleAssetValue ( ) ) ;
@@ -398,5 +400,80 @@ public void Execute_Throw_InvalidTransferCurrencyException()
398400 BlockIndex = TransferAsset3 . CrystalTransferringRestrictionStartIndex ,
399401 } ) ) ;
400402 }
403+
404+ [ Fact ]
405+ public void Execute_Throw_ArgumentException ( )
406+ {
407+ var baseState = new MockStateDelta (
408+ MockState . Empty
409+ . SetBalance ( _sender , _currency * 1000 ) ) ;
410+ var action = new TransferAssets (
411+ sender : _sender ,
412+ new List < ( Address , FungibleAssetValue ) >
413+ {
414+ ( StakeState . DeriveAddress ( _recipient ) , _currency * 100 ) ,
415+ ( _recipient2 , _currency * 100 ) ,
416+ }
417+ ) ;
418+ // 스테이킹 주소에 송금하려고 하면 실패합니다.
419+ Assert . Throws < ArgumentException > ( "recipient" , ( ) => action . Execute ( new ActionContext ( )
420+ {
421+ PreviousState = baseState
422+ . SetState (
423+ StakeState . DeriveAddress ( _recipient ) ,
424+ new StakeState ( StakeState . DeriveAddress ( _recipient ) , 0 ) . SerializeV2 ( ) ) ,
425+ Signer = _sender ,
426+ Rehearsal = false ,
427+ BlockIndex = 1 ,
428+ } ) ) ;
429+ Assert . Throws < ArgumentException > ( "recipient" , ( ) => action . Execute ( new ActionContext ( )
430+ {
431+ PreviousState = baseState
432+ . SetState (
433+ StakeState . DeriveAddress ( _recipient ) ,
434+ new StakeStateV2 (
435+ new Contract (
436+ "StakeRegularFixedRewardSheet_V1" ,
437+ "StakeRegularRewardSheet_V1" ,
438+ 50400 ,
439+ 201600 ) ,
440+ 0 ) . Serialize ( ) ) ,
441+ Signer = _sender ,
442+ Rehearsal = false ,
443+ BlockIndex = 1 ,
444+ } ) ) ;
445+ Assert . Throws < ArgumentException > ( "recipient" , ( ) => action . Execute ( new ActionContext ( )
446+ {
447+ PreviousState = baseState
448+ . SetState (
449+ StakeState . DeriveAddress ( _recipient ) ,
450+ new MonsterCollectionState (
451+ MonsterCollectionState . DeriveAddress ( _sender , 0 ) ,
452+ 1 ,
453+ 0 )
454+ . Serialize ( ) ) ,
455+ Signer = _sender ,
456+ Rehearsal = false ,
457+ BlockIndex = 1 ,
458+ } ) ) ;
459+ var monsterCollectionRewardSheet = new MonsterCollectionRewardSheet ( ) ;
460+ monsterCollectionRewardSheet . Set (
461+ "level,required_gold,reward_id\n 1,500,1\n 2,1800,2\n 3,7200,3\n 4,54000,4\n 5,270000,5\n 6,480000,6\n 7,1500000,7\n " ) ;
462+ Assert . Throws < ArgumentException > ( "recipient" , ( ) => action . Execute ( new ActionContext ( )
463+ {
464+ PreviousState = baseState
465+ . SetState (
466+ StakeState . DeriveAddress ( _recipient ) ,
467+ new MonsterCollectionState0 (
468+ MonsterCollectionState . DeriveAddress ( _sender , 0 ) ,
469+ 1 ,
470+ 0 ,
471+ monsterCollectionRewardSheet )
472+ . Serialize ( ) ) ,
473+ Signer = _sender ,
474+ Rehearsal = false ,
475+ BlockIndex = 1 ,
476+ } ) ) ;
477+ }
401478 }
402479}
0 commit comments