@@ -478,6 +478,10 @@ enforce_valid_tx(TX) ->
478478 hb_util :ok_or_throw (TX ,
479479 hb_util :check_size (Value , {range , 0 , ? MAX_TAG_VALUE_SIZE }),
480480 {invalid_field , tag_value , Value }
481+ ),
482+ hb_util :ok_or_throw (TX ,
483+ hb_util :check_size (<<Name /binary , Value /binary >>, {range , 0 , ? MAX_TAG_COMBINED_SIZE }),
484+ {invalid_field , tag_size , {Name , Value }}
481485 );
482486 (InvalidTagForm ) ->
483487 throw ({invalid_field , tag , InvalidTagForm })
@@ -985,6 +989,7 @@ test_enforce_valid_tx_happy() ->
985989 {empty_tag_name_value , BaseTX # tx {tags = [{<<>>, <<>>}]}},
986990 {max_len_tag_name , BaseTX # tx {tags = [{crypto :strong_rand_bytes (? MAX_TAG_NAME_SIZE ), <<" val" >>}]}},
987991 {max_len_tag_value , BaseTX # tx {tags = [{<<" key" >>, crypto :strong_rand_bytes (? MAX_TAG_VALUE_SIZE )}]}},
992+ {max_len_combined , BaseTX # tx {tags = [{crypto :strong_rand_bytes (? MAX_TAG_COMBINED_SIZE div 2 ), crypto :strong_rand_bytes (? MAX_TAG_COMBINED_SIZE div 2 )}]}},
988993 {max_len_tags , BaseTX # tx {tags = [{crypto :strong_rand_bytes (42 ), <<" val" >>} || _ <- lists :seq (1 ,? MAX_TAG_COUNT )]}}
989994 ],
990995
@@ -1005,6 +1010,8 @@ test_enforce_valid_tx_failure() ->
10051010 TooLongTagName = crypto :strong_rand_bytes (? MAX_TAG_NAME_SIZE + 1 ),
10061011 TooLongTagValue = crypto :strong_rand_bytes (? MAX_TAG_VALUE_SIZE + 1 ),
10071012 TooManyTags = [{crypto :strong_rand_bytes (42 ), <<" val" >>} || _ <- lists :seq (1 ,? MAX_TAG_COUNT + 1 )],
1013+ LargeTag = crypto :strong_rand_bytes ((? MAX_TAG_COMBINED_SIZE div 2 ) + 1 ),
1014+ TooLongCombinedTag = {LargeTag , LargeTag },
10081015
10091016 SigInvalidSize1 = crypto :strong_rand_bytes (1 ),
10101017 SigInvalidSize64 = crypto :strong_rand_bytes (64 ),
@@ -1048,6 +1055,7 @@ test_enforce_valid_tx_failure() ->
10481055 {tag_name_too_long , BaseTX # tx {tags = [{TooLongTagName , <<" val" >>}]}, {invalid_field , tag_name , TooLongTagName }},
10491056 {tag_value_not_binary , BaseTX # tx {tags = [{<<" key" >>, not_binary }]}, {invalid_field , tag_value , not_binary }},
10501057 {tag_value_too_long , BaseTX # tx {tags = [{<<" key" >>, TooLongTagValue }]}, {invalid_field , tag_value , TooLongTagValue }},
1058+ {tag_combined_size_too_long , BaseTX # tx {tags = [TooLongCombinedTag ]}, {invalid_field , tag_size , TooLongCombinedTag }},
10511059 {tag_list_length_too_high , BaseTX # tx {tags = TooManyTags }, {invalid_field , tag_count , TooManyTags }},
10521060 {invalid_tag_form_atom , BaseTX # tx {tags = [not_a_tuple ]}, {invalid_field , tag , not_a_tuple }},
10531061 {invalid_tag_form_list , BaseTX # tx {tags = [[<<" name" >>, <<" value" >>]]}, {invalid_field , tag , [<<" name" >>, <<" value" >>]} }
0 commit comments