You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

primitives.ts 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { htmlTxt, longText, makeTestnetWallet, TEST_CONFIG, TEST_DATA } from './CONSTANTS'
  2. import { xrpIO } from '../src/xrpIO/xrpl-binding'
  3. import * as chai from 'chai';
  4. import { Wallet } from '../src/util/types';
  5. var wtf = require('wtfnode');
  6. const expect = chai.expect
  7. let sendWallet: Wallet
  8. let receiveWallet: Wallet
  9. let api: xrpIO
  10. const ONLY_LARGE_TESTS = true
  11. describe('XRPIO', () => {
  12. before(async function(){
  13. this.timeout(15000)
  14. sendWallet = await makeTestnetWallet()
  15. receiveWallet = await makeTestnetWallet()
  16. await new Promise((res, rej) => setTimeout(res, 10000)) //it takes a moment for the wallets to become active
  17. })
  18. beforeEach(async () => {
  19. try {
  20. api = new xrpIO(TEST_CONFIG.rippleNode, {debug: false, connectionTimeout: 100000})
  21. return await api.connect()
  22. } catch (e) {
  23. console.log(e)
  24. throw e
  25. }
  26. })
  27. afterEach(async function () {
  28. try {
  29. return await api.disconnect()
  30. } catch (e) {
  31. console.log(e)
  32. }
  33. })
  34. it('getAccountSequence', async function(){
  35. // this.skip()
  36. this.timeout(10000)
  37. const seq = await api.getAccountSequence(sendWallet.address)
  38. expect(seq).to.exist
  39. expect(seq).to.be.a('number')
  40. })
  41. let txHash
  42. it('writeRaw', async function(){
  43. this.skip()
  44. this.timeout(15000)
  45. txHash = await api.writeRaw({data: TEST_DATA}, receiveWallet.address, sendWallet.secret);
  46. expect(txHash).to.exist
  47. expect(txHash).to.be.a('string')
  48. })
  49. it('readRaw', async function () {
  50. this.skip()
  51. this.timeout(15000)
  52. const memo = await api.readRaw(txHash)
  53. expect(memo).to.exist
  54. expect(memo.data).to.be.equal(TEST_DATA)
  55. })
  56. it('treeWrite', async function(){
  57. this.skip()
  58. this.timeout(45000)
  59. txHash = await api.treeWrite(longText, receiveWallet.address, sendWallet.secret)
  60. expect(txHash).to.exist
  61. expect(txHash).to.be.a('string')
  62. })
  63. it('treeRead', async function(){
  64. this.skip()
  65. this.timeout(45000)
  66. txHash = await api.treeRead([txHash])
  67. expect(txHash).to.exist
  68. expect(txHash).to.be.equal(longText)
  69. })
  70. it('treeWrite XL', async function(){
  71. // this.skip()
  72. this.timeout(450000)
  73. txHash = await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
  74. expect(txHash).to.exist
  75. expect(txHash).to.be.a('string')
  76. })
  77. it('treeRead XL', async function(){
  78. // this.skip()
  79. this.timeout(450000)
  80. txHash = await api.treeRead([txHash])
  81. expect(txHash).to.exist
  82. expect(txHash).to.be.equal(htmlTxt)
  83. })
  84. it('print open handles', function(){
  85. wtf.dump()
  86. })
  87. })