a zip code crypto-currency system good for red ONLY

test.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var test = require('tape')
  2. var randomBytes = require('./')
  3. test('sync', function (t) {
  4. t.plan(4)
  5. t.equals(randomBytes(0).length, 0, 'len: ' + 0)
  6. t.equals(randomBytes(3).length, 3, 'len: ' + 3)
  7. t.equals(randomBytes(30).length, 30, 'len: ' + 30)
  8. t.equals(randomBytes(300).length, 300, 'len: ' + 300)
  9. })
  10. test('async', function (t) {
  11. t.plan(4)
  12. randomBytes(0, function (err, resp) {
  13. if (err) throw err
  14. t.equals(resp.length, 0, 'len: ' + 0)
  15. })
  16. randomBytes(3, function (err, resp) {
  17. if (err) throw err
  18. t.equals(resp.length, 3, 'len: ' + 3)
  19. })
  20. randomBytes(30, function (err, resp) {
  21. if (err) throw err
  22. t.equals(resp.length, 30, 'len: ' + 30)
  23. })
  24. randomBytes(300, function (err, resp) {
  25. if (err) throw err
  26. t.equals(resp.length, 300, 'len: ' + 300)
  27. })
  28. })
  29. if (process.browser) {
  30. test('requesting to much throws', function (t) {
  31. t.plan(1)
  32. t.throws(function () {
  33. randomBytes(65537)
  34. })
  35. })
  36. test('requesting to much throws async', function (t) {
  37. t.plan(1)
  38. t.throws(function () {
  39. randomBytes(65537, function () {
  40. t.ok(false, 'should not get here')
  41. })
  42. })
  43. })
  44. }