query.spec.js 915 B

1234567891011121314151617181920212223242526272829303132
  1. /* Import modules. */
  2. const Nito = require('../..')
  3. describe('Blockchain:query', () => {
  4. test('it should report the UTXO is spent', async () => {
  5. /* Set transaction id. */
  6. const txid = '5cd9fdf3cbed66305daf736b0c2ad1e01773b9a64b1d2d35cb4a0256c6b20092'
  7. /* Set output index. */
  8. const vout = 0
  9. /* Run test. */
  10. const isSpent = await Nito.Blockchain.Query.isSpent(txid, vout)
  11. /* Evaluate test. */
  12. expect(isSpent).toBeTruthy()
  13. })
  14. test('it should report the UTXO is unspent', async () => {
  15. /* Set transaction id. */
  16. const txid = '5cd9fdf3cbed66305daf736b0c2ad1e01773b9a64b1d2d35cb4a0256c6b20092'
  17. /* Set output index. */
  18. const vout = 1
  19. /* Run test. */
  20. const isSpent = await Nito.Blockchain.Query.isSpent(txid, vout)
  21. /* Evaluate test. */
  22. expect(isSpent).toBeFalsy()
  23. })
  24. })