UI for Zipcoin Blue

test.js 821B

1234567891011121314151617181920212223242526272829
  1. var test = require('tape')
  2. var crypto = require('./browser')
  3. var Buffer = require('safe-buffer').Buffer
  4. test('sync', function (t) {
  5. t.test('first', function (t) {
  6. const buf = Buffer.alloc(10)
  7. const before = buf.toString('hex')
  8. crypto.randomFillSync(buf, 5, 5)
  9. const after = buf.toString('hex')
  10. t.notEqual(before, after)
  11. t.equal(before.slice(0, 10), after.slice(0, 10))
  12. t.end()
  13. })
  14. })
  15. test('async', function (t) {
  16. t.test('first', function (t) {
  17. const buf = Buffer.alloc(10)
  18. const before = buf.toString('hex')
  19. crypto.randomFill(buf, 5, 5, function (err, bufa) {
  20. t.error(err)
  21. const after = bufa.toString('hex')
  22. t.notEqual(before, after)
  23. t.equal(before.slice(0, 10), after.slice(0, 10))
  24. t.ok(buf === bufa, 'same buffer')
  25. t.end()
  26. })
  27. })
  28. })