diff --git a/packages/util/src/bn/toU8a.spec.ts b/packages/util/src/bn/toU8a.spec.ts index 822b84a7b..cc5ae61a7 100644 --- a/packages/util/src/bn/toU8a.spec.ts +++ b/packages/util/src/bn/toU8a.spec.ts @@ -50,12 +50,18 @@ describe('bnToU8a', (): void => { ).toEqual(new Uint8Array([251, 46])); }); - it('converts negative numbers (bitLength)', (): void => { + it('converts negative numbers (LE)', (): void => { expect( bnToU8a(new BN(-1234), { bitLength: 32, isNegative: true }) ).toEqual(new Uint8Array([46, 251, 255, 255])); }); + it('converts negative numbers (LE, bitLength)', (): void => { + expect( + bnToU8a(new BN(-123456), { bitLength: 32, isNegative: true }) + ).toEqual(new Uint8Array([192, 29, 254, 255])); + }); + it('handles backwards compatibility', (): void => { expect( bnToU8a(new BN(1234), 32, false) diff --git a/packages/util/src/u8a/toBigInt.spec.ts b/packages/util/src/u8a/toBigInt.spec.ts index ad5cd5913..d15497121 100644 --- a/packages/util/src/u8a/toBigInt.spec.ts +++ b/packages/util/src/u8a/toBigInt.spec.ts @@ -42,10 +42,10 @@ describe('u8aToBigInt', (): void => { it('handles negative numbers (little-endian)', (): void => { expect( u8aToBigInt( - new Uint8Array([46, 251]), + new Uint8Array([192, 29, 254]), { isLe: true, isNegative: true } ) - ).toEqual(-1234n); + ).toEqual(-123456n); }); it('handles negative numbers (big-endian)', (): void => {