InstructionArgumentNode.test.ts 530 B

12345678910111213141516
  1. import { instructionArgumentNode, numberTypeNode } from '@codama/nodes';
  2. import { expect, test } from 'vitest';
  3. import { getNodeCodec } from '../../src';
  4. import { hex } from '../_setup';
  5. test('it delegates to the type node of the argument', () => {
  6. const codec = getNodeCodec([
  7. instructionArgumentNode({
  8. name: 'foo',
  9. type: numberTypeNode('u32'),
  10. }),
  11. ]);
  12. expect(codec.encode(42)).toStrictEqual(hex('2a000000'));
  13. expect(codec.decode(hex('2a000000'))).toStrictEqual(42);
  14. });