File tree Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -271,17 +271,11 @@ func IsValidMetaType[T SizableInteger](num T) (MetaType, error) {
271271// IsValidMetaSize checks if the passed data is non-empty and below the maximum
272272// size.
273273func IsValidMetaSize (mBytes []byte , maxSize int ) error {
274- mSize := len (mBytes )
275- switch {
276- case mSize == 0 :
277- return ErrMetaDataMissing
278-
279- case mSize > maxSize :
274+ if len (mBytes ) > maxSize {
280275 return ErrMetaDataTooLarge
281-
282- default :
283- return nil
284276 }
277+
278+ return nil
285279}
286280
287281// IsValidDecDisplay checks if the decimal display value is below the maximum.
@@ -295,15 +289,13 @@ func IsValidDecDisplay(decDisplay uint32) error {
295289
296290// DecodeMetaJSON decodes bytes as a JSON object, after checking that the bytes
297291// could be valid metadata.
298- //
299- // TODO(ffranr): Add unit test for `jBytes := []byte{}`.
300292func DecodeMetaJSON (jBytes []byte ) (map [string ]interface {}, error ) {
301293 jMeta := make (map [string ]interface {})
302294
303295 // These bytes must match our metadata size constraints.
304296 err := IsValidMetaSize (jBytes , MetaDataMaxSizeBytes )
305297 if err != nil {
306- return nil , fmt .Errorf ("%w: %s " , ErrInvalidJSON , err . Error () )
298+ return nil , fmt .Errorf ("%w: %w " , ErrInvalidJSON , err )
307299 }
308300
309301 // Unmarshal checks internally if the JSON is valid.
Original file line number Diff line number Diff line change @@ -71,7 +71,6 @@ func TestValidateMetaReveal(t *testing.T) {
7171 Type : MetaOpaque ,
7272 Data : nil ,
7373 },
74- expectedErr : ErrMetaDataMissing ,
7574 },
7675 {
7776 name : "too much data" ,
You can’t perform that action at this time.
0 commit comments