ListBasicType.serialize accepts values longer than the list limit
Describe the bug
ListBasicType.serialize does not enforce the list limit. A value longer than the limit is written as SSZ bytes without error. The matching fromJson and deserialize paths already reject the same over-length input.
Repro on @chainsafe/[email protected] (current master):
import { ListBasicType, UintNumberType } from "@chainsafe/ssz";
const list = new ListBasicType(new UintNumberType(1), 4);
list.serialize([1, 2, 3, 4, 5]);
// -> Uint8Array [1, 2, 3, 4, 5] (no throw)
list.fromJson([1, 2, 3, 4, 5]);
// throws: Invalid list length 5 over limit 4
list.deserialize(list.serialize([1, 2, 3, 4, 5]));
// throws: Invalid list length 5 over limit 4
Expected behavior
serialize should reject a value whose length is greater than the list limit, with the same class of error as fromJson / deserialize (Invalid list length N over limit M).
Actual behavior
serialize emits SSZ bytes for the over-length value. Round-tripping through deserialize then fails, and fromJson already refuses the same input.
Additional context
Same asymmetry class as serialize-time validation gaps elsewhere in the package (e.g. uint range checks on serialize). VectorBasicType with the wrong fixed length also needs a quick check in the same area if it is not already covered.
Same serialize-time gap on two nearby types in the same build:
ListCompositeTypewith limit 2 also serializes three elements without error;fromJsonrejects them.VectorBasicType(Uint8, 4)silently pads a short value with zeros (serialize([1,2])→[1,2,0,0]) and truncates a long value (serialize([1,2,3,4,5])→[1,2,3,4]), instead of rejecting a wrong length.