PdaNode.test.ts 962 B

123456789101112131415161718192021222324252627282930313233
  1. import {
  2. constantPdaSeedNode,
  3. constantPdaSeedNodeFromProgramId,
  4. numberTypeNode,
  5. numberValueNode,
  6. pdaNode,
  7. variablePdaSeedNode,
  8. } from '@kinobi-so/nodes';
  9. import { expect, test } from 'vitest';
  10. import { pdaNodeFromAnchorV00 } from '../../src';
  11. test('it creates PDA nodes', () => {
  12. const node = pdaNodeFromAnchorV00({
  13. name: 'myPda',
  14. seeds: [
  15. { kind: 'programId' },
  16. { kind: 'constant', type: 'u8', value: 42 },
  17. { description: 'seed description', kind: 'variable', name: 'myVariableSeed', type: 'u16' },
  18. ],
  19. });
  20. expect(node).toEqual(
  21. pdaNode({
  22. name: 'myPda',
  23. seeds: [
  24. constantPdaSeedNodeFromProgramId(),
  25. constantPdaSeedNode(numberTypeNode('u8'), numberValueNode(42)),
  26. variablePdaSeedNode('myVariableSeed', numberTypeNode('u16'), 'seed description'),
  27. ],
  28. }),
  29. );
  30. });