All files / src createStubUtxoProvider.ts

38.46% Statements 5/13
0% Branches 0/5
0% Functions 0/4
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 852x 2x   2x                                                                                                                                             2x                    
import { Cardano, UtxoByAddressesArgs, UtxoProvider } from '@cardano-sdk/core';
import delay from 'delay';
 
export const somePartialUtxos: Cardano.Utxo[] = [
  [
    {
      address: Cardano.PaymentAddress(
        'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg'
      ),
      index: 0,
      txId: Cardano.TransactionId('8fd14baca91c674fafae59701b7dc0eda1266202ec8445bad3244bd8669a7fb5')
    },
    {
      address: Cardano.PaymentAddress(
        'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg'
      ),
      value: {
        coins: BigInt('999502622402')
      }
    }
  ],
  [
    {
      address: Cardano.PaymentAddress(
        'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp'
      ),
      index: 0,
      txId: Cardano.TransactionId('a62624fdc47e8b774ddff11a9a56cae5fa9b072975af87bf0a0583fca0e345f4')
    },
    {
      address: Cardano.PaymentAddress(
        'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp'
      ),
      value: {
        coins: BigInt('19717868703')
      }
    }
  ],
  [
    {
      address: Cardano.PaymentAddress(
        'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg'
      ),
      index: 0,
      txId: Cardano.TransactionId('3d4cd09885d39673125c3a15f8acb45d92fde137f9effe7a5131f6cc7241d960')
    },
    {
      address: Cardano.PaymentAddress(
        'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg'
      ),
      value: {
        coins: BigInt('10306556787917')
      }
    }
  ],
  [
    {
      address: Cardano.PaymentAddress(
        'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7'
      ),
      index: 0,
      txId: Cardano.TransactionId('19251f57476d7af2777252270413c01383d9503110a68b4fde1a239c119c4f5d')
    },
    {
      address: Cardano.PaymentAddress(
        'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7'
      ),
      value: {
        coins: BigInt('1497246388')
      }
    }
  ]
];
 
export const createStubUtxoProvider = (utxos: Cardano.Utxo[] = somePartialUtxos, delayMs?: number): UtxoProvider => ({
  healthCheck: async () => {
    Iif (delayMs) await delay(delayMs);
    return { ok: true };
  },
  utxoByAddresses: async ({ addresses }: UtxoByAddressesArgs) => {
    Iif (delayMs) await delay(delayMs);
    return utxos.filter((u) => addresses.includes(u[0].address) && addresses.includes(u[1].address));
  }
});