您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

primitives.ts 2.8KB

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