@@ -1395,22 +1395,64 @@ fn index_consistency_during_complex_recipient_updates() {
13951395 assert ! ( !participants_2. contains( & permission_id) ) ; // Removed
13961396 assert ! ( participants_3. contains( & permission_id) ) ; // Still there
13971397 assert ! ( participants_4. contains( & permission_id) ) ; // Added
1398+ } ) ;
1399+ }
13981400
1399- // Test complete removal of all recipients should delete permission
1400- let empty_recipients = BoundedBTreeMap :: new ( ) ;
1401+ #[ test]
1402+ fn cannot_create_empty_recipients_for_irrevocable_permissions ( ) {
1403+ new_test_ext ( ) . execute_with ( || {
1404+ zero_min_burn ( ) ;
1405+ let agent_0 = 0 ;
1406+ register_empty_agent ( agent_0) ;
1407+
1408+ add_balance ( agent_0, as_tors ( 10 ) + 1 ) ;
1409+
1410+ let stream_id = generate_root_stream_id ( & agent_0) ;
1411+ let mut streams = BTreeMap :: new ( ) ;
1412+ streams. insert ( stream_id, Percent :: from_percent ( 50 ) ) ;
14011413
1402- // This should fail as permissions need at least one recipient
14031414 assert_err ! (
1404- pallet_permission0:: Pallet :: <Test >:: update_stream_permission (
1415+ pallet_permission0:: Pallet :: <Test >:: delegate_stream_permission (
14051416 get_origin( agent_0) ,
1406- permission_id,
1407- Some ( empty_recipients) ,
1417+ Default :: default ( ) ,
1418+ pallet_permission0:: StreamAllocation :: Streams ( streams. clone( ) . try_into( ) . unwrap( ) ) ,
1419+ pallet_permission0:: DistributionControl :: Manual ,
1420+ pallet_permission0:: PermissionDuration :: Indefinite ,
1421+ pallet_permission0:: RevocationTerms :: Irrevocable ,
1422+ pallet_permission0:: EnforcementAuthority :: None ,
14081423 None ,
14091424 None ,
1425+ ) ,
1426+ pallet_permission0:: Error :: <Test >:: NoRecipientsSpecified
1427+ ) ;
1428+
1429+ assert_err ! (
1430+ pallet_permission0:: Pallet :: <Test >:: delegate_stream_permission(
1431+ get_origin( agent_0) ,
1432+ Default :: default ( ) ,
1433+ pallet_permission0:: StreamAllocation :: Streams ( streams. clone( ) . try_into( ) . unwrap( ) ) ,
1434+ pallet_permission0:: DistributionControl :: Manual ,
1435+ pallet_permission0:: PermissionDuration :: Indefinite ,
1436+ pallet_permission0:: RevocationTerms :: RevocableAfter ( 10 ) ,
1437+ pallet_permission0:: EnforcementAuthority :: None ,
1438+ None ,
14101439 None ,
1411- None
14121440 ) ,
14131441 pallet_permission0:: Error :: <Test >:: NoRecipientsSpecified
14141442 ) ;
1443+
1444+ assert_ok ! (
1445+ pallet_permission0:: Pallet :: <Test >:: delegate_stream_permission(
1446+ get_origin( agent_0) ,
1447+ Default :: default ( ) ,
1448+ pallet_permission0:: StreamAllocation :: Streams ( streams. try_into( ) . unwrap( ) ) ,
1449+ pallet_permission0:: DistributionControl :: Manual ,
1450+ pallet_permission0:: PermissionDuration :: Indefinite ,
1451+ pallet_permission0:: RevocationTerms :: RevocableByDelegator ,
1452+ pallet_permission0:: EnforcementAuthority :: None ,
1453+ None ,
1454+ None ,
1455+ )
1456+ ) ;
14151457 } ) ;
14161458}
0 commit comments