py-scale-codec
py-scale-codec copied to clipboard
0-length FixedLengthArray of U8 decodes to []
https://github.com/JAMdotTech/py-scale-codec/blob/ee3ab0c987a97102d98761c793e0e8287f1e1ccc/scalecodec/types.py#L1925-L1938
All other U8 lengths decode to 0x...
Getting an array out of this is very surprising if not outright incorrect
can i try this?? @kkowalski-reef
Yeah, sorry, here's a minimal repro:
from scalecodec.base import RuntimeConfigurationObject, ScaleBytes
conf = RuntimeConfigurationObject()
b32_0 = conf.create_scale_object("[u8; 0]", data=ScaleBytes(b""))
print(b32_0.decode()) # []
b32_8 = conf.create_scale_object("[u8; 8]", data=ScaleBytes(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
print(b32_8.decode()) # "0x0102030405060708"
The problem is that self.element_count == 0 immediately returns a []
To be clear I'm on 1.2.11, .12 doesn't seem to be addressing this and v2 is apparently in alpha state so I haven't tested that.