Expand the output buffer from 4 bytes to 32 bytes and iterate all 32 positions, so values ≥ 2³² are encoded correctly instead of silently dropped. Update tests to assert 32-byte output and add coverage for 2³², 2¹²⁸, and max uint256 roundtrips. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
12 lines
477 B
TypeScript
12 lines
477 B
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { bytesToUint256LittleEndian, uint256ToBytesLittleEndian } from '../subgraph.js';
|
|
|
|
describe('BigInt Conversion Functions', () => {
|
|
test('converts uint256 to bytes and back (little endian)', () => {
|
|
const mockId = uint256ToBytesLittleEndian(3n);
|
|
const expected = new Uint8Array(32);
|
|
expected[0] = 3;
|
|
expect(mockId).toEqual(expected);
|
|
expect(bytesToUint256LittleEndian(mockId)).toEqual(3n);
|
|
});
|
|
});
|