add more utility functions and improved tests

This commit is contained in:
nitowa
2023-05-01 20:15:00 +02:00
parent 26e4989f82
commit 50fa056fe3
4 changed files with 71 additions and 22 deletions
+24 -8
View File
@@ -1,8 +1,8 @@
var wtf = require('wtfnode');
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
@@ -36,16 +36,24 @@ describe('XRPIO', () => {
})
it('getAccountSequence', async function(){
// this.skip()
//this.skip()
this.timeout(10000)
const seq = await api.getAccountSequence(sendWallet.address)
expect(seq).to.exist
expect(seq).to.be.a('number')
})
it('estimateFee', async function () {
this.timeout(2000)
const cost = await api.estimateFee(longText)
expect(cost).to.be.a('number')
expect(cost).to.be.lessThan(50)
expect(cost).to.be.greaterThan(30)
})
let txHash
it('writeRaw', async function(){
// this.skip()
//this.skip()
this.timeout(15000)
txHash = await api.writeRaw({data: TEST_DATA}, receiveWallet.address, sendWallet.secret);
expect(txHash).to.exist
@@ -53,13 +61,20 @@ describe('XRPIO', () => {
})
it('readRaw', async function () {
// this.skip()
//this.skip()
this.timeout(15000)
const memo = await api.readRaw(txHash)
expect(memo).to.exist
expect(memo.data).to.be.equal(TEST_DATA)
})
it('readRaw bad hash', function (done){
this.timeout(150000)
api.readRaw("123")
.then(_ => done(new Error('Expected error but succeeded')))
.catch(_ => done())
})
it('treeWrite', async function(){
// this.skip()
this.timeout(45000)
@@ -77,7 +92,7 @@ describe('XRPIO', () => {
})
it('treeWrite XL', async function(){
// this.skip()
//this.skip()
this.timeout(450000)
txHash = await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
expect(txHash).to.exist
@@ -85,7 +100,7 @@ describe('XRPIO', () => {
})
it('treeRead XL', async function(){
// this.skip()
//this.skip()
this.timeout(450000)
const data = await api.treeRead([txHash])
expect(data).to.exist
@@ -93,7 +108,8 @@ describe('XRPIO', () => {
})
it('print open handles', function(){
wtf.dump()
console.log(txHash)
api.disconnect().then(_ => {
wtf.dump()
})
})
})