Added several improvements to failed read/write recovery strategies

This commit is contained in:
nitowa
2023-05-13 01:18:43 +02:00
parent b229e70504
commit 3fea9e1ac7
6 changed files with 78 additions and 216 deletions
+30 -1
View File
@@ -7,6 +7,7 @@ const expect = chai.expect
let sendWallet: Wallet
let receiveWallet: Wallet
let poorWallet: Wallet
let api: xrpIO
describe('XRPIO', () => {
@@ -14,6 +15,7 @@ describe('XRPIO', () => {
this.timeout(15000)
sendWallet = await makeTestnetWallet()
receiveWallet = await makeTestnetWallet()
poorWallet = await makeTestnetWallet()
await new Promise((res, rej) => setTimeout(res, 10000)) //it takes a moment for the wallets to become active
})
@@ -35,6 +37,15 @@ describe('XRPIO', () => {
}
})
it('throws error if not enough funds', function(done){
this.timeout(15000)
console.log(poorWallet)
api.sendPayment({}, receiveWallet.address, poorWallet.secret, undefined, String(1000000 * 10001))
.then(_ => done(new Error('Expected error but succeeded')))
.catch(_ => done())
})
it('getTransaction with bad hash', function(done){
this.timeout(10000)
api.getTransaction('73FECDA37ABBB2FC17460C5C2467BE6A0A8E1F4EB081FFFFFFFFFFFFFFFFFFFF') //technically this hash could exist, but probably never will
@@ -142,7 +153,25 @@ describe('XRPIO', () => {
expect(data).to.exist
expect(data).to.be.equal(htmlTxt)
})
it('sends even if rate limit exceeded', async function(){
this.timeout(10 * 60 * 1000) //10m
console.log("Testing if sending past rate limits correctly recovers and finishes. This may take a while.")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("1/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("2/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("3/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("4/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("5/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
console.log("6/7")
await api.treeWrite(htmlTxt, receiveWallet.address, sendWallet.secret)
})
it('print open handles', function(){
api.disconnect().then(_ => {
wtf.dump()