fix: correct BitVec length calculation from bytes to bits in codec (#6152)

This commit is contained in:
rajk93
2025-05-29 15:11:19 -03:00
committed by GitHub
parent 53d17dc3e5
commit d81f6e9eb2
2 changed files with 3 additions and 2 deletions
@@ -90,7 +90,8 @@ describe('BitVec', (): void => {
expect(
new BitVec(registry, '0x0837').inspect()
).toEqual({
outer: [new Uint8Array([0]), new Uint8Array([0x08, 0x37])]
// For input '0x0837' (yields 16 bits): compactToU8a(16) is 16<<2 = 64.
outer: [new Uint8Array([64]), new Uint8Array([0x08, 0x37])]
});
});
});
+1 -1
View File
@@ -29,7 +29,7 @@ function decodeBitVec (value?: AnyU8a): [number, Uint8Array] {
if (Array.isArray(value) || isString(value)) {
const u8a = u8aToU8a(value);
return [u8a.length / 8, u8a];
return [u8a.length * 8, u8a];
}
return decodeBitVecU8a(value);