import { htmlTxt, longText, makeTestnetWallet, TEST_CONFIG, TEST_DATA } from './CONSTANTS' import { xrpIO } from '../src/xrpIO/xrpl-binding' import * as chai from 'chai'; import { Wallet } from '../src/util/types'; var wtf = require('wtfnode'); const expect = chai.expect let sendWallet: Wallet let receiveWallet: Wallet let api: xrpIO const ONLY_LARGE_TESTS = true describe('XRPIO', () => { before(async function(){ this.timeout(15000) sendWallet = await makeTestnetWallet() receiveWallet = await makeTestnetWallet() await new Promise((res, rej) => setTimeout(res, 10000)) //it takes a moment for the wallets to become active }) beforeEach(async () => { try { api = new xrpIO(TEST_CONFIG.rippleNode, {debug: false, connectionTimeout: 100000}) return await api.connect() } catch (e) { console.log(e) throw e } }) afterEach(async function () { try { return await api.disconnect() } catch (e) { console.log(e) } }) it('getAccountSequence', async function(){ // this.skip() this.timeout(10000) const seq = await api.getAccountSequence(sendWallet.address) expect(seq).to.exist expect(seq).to.be.a('number') }) let txHash it('writeRaw', async function(){ this.skip() this.timeout(15000) txHash = await api.writeRaw({data: TEST_DATA}, receiveWallet.address, sendWallet.secret); expect(txHash).to.exist expect(txHash).to.be.a('string') }) it('readRaw', async function () { this.skip() this.timeout(15000) const memo = await api.readRaw(txHash) expect(memo).to.exist expect(memo.data).to.be.equal(TEST_DATA) }) it('treeWrite', async function(){ this.skip() this.timeout(45000) txHash = await api.treeWrite(longText, receiveWallet.address, sendWallet.secret) expect(txHash).to.exist expect(txHash).to.be.a('string') }) it('treeRead', async function(){ this.skip() this.timeout(45000) txHash = await api.treeRead([txHash]) expect(txHash).to.exist expect(txHash).to.be.equal(longText) }) it('treeWrite XL', async function(){ // this.skip() this.timeout(450000) txHash = await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret) expect(txHash).to.exist expect(txHash).to.be.a('string') }) it('treeRead XL', async function(){ // this.skip() this.timeout(450000) txHash = await api.treeRead([txHash]) expect(txHash).to.exist expect(txHash).to.be.equal(htmlTxt) }) it('print open handles', function(){ wtf.dump() }) })