move to new xrpl library
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
+58
-64
@@ -1,18 +1,18 @@
|
||||
import { RippleAPI } from 'ripple-lib'
|
||||
import { htmlTxt, longText, makeTestnetWallet, TEST_CONFIG, TEST_DATA } from './CONSTANTS'
|
||||
import { getLatestSequence, sendPayment, treeRead, treeWrite } from '../src/xrpIO/ripple-binding'
|
||||
import { xrpIO } from '../src/xrpIO/xrpl-binding'
|
||||
import * as chai from 'chai';
|
||||
import { Wallet } from '../src/util/types';
|
||||
const utf8 = require('utf8')
|
||||
const base64 = require('base-64')
|
||||
var wtf = require('wtfnode');
|
||||
const expect = chai.expect
|
||||
|
||||
let sendWallet: Wallet
|
||||
let receiveWallet: Wallet
|
||||
let api: RippleAPI
|
||||
let api: xrpIO
|
||||
|
||||
const ONLY_LARGE_TESTS = true
|
||||
|
||||
describe('XRPIO', () => {
|
||||
before(async function () {
|
||||
before(async function(){
|
||||
this.timeout(15000)
|
||||
sendWallet = await makeTestnetWallet()
|
||||
receiveWallet = await makeTestnetWallet()
|
||||
@@ -21,7 +21,7 @@ describe('XRPIO', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
api = new RippleAPI({ server: TEST_CONFIG.rippleNode })
|
||||
api = new xrpIO(TEST_CONFIG.rippleNode, {debug: false, connectionTimeout: 100000})
|
||||
return await api.connect()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -37,70 +37,64 @@ describe('XRPIO', () => {
|
||||
}
|
||||
})
|
||||
|
||||
let latestSeq
|
||||
describe('plumbing', () => {
|
||||
it('getLatestSequence', async () => {
|
||||
latestSeq = await getLatestSequence(api, sendWallet.address)
|
||||
expect(latestSeq).to.exist
|
||||
expect(latestSeq).to.be.a('number')
|
||||
expect(latestSeq).to.be.greaterThan(0)
|
||||
})
|
||||
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')
|
||||
})
|
||||
|
||||
describe('payment', () => {
|
||||
it('sendPayment', async function () {
|
||||
this.timeout(10000)
|
||||
const result = await sendPayment(api, [{ data: "123" }], sendWallet.address, receiveWallet.address, sendWallet.secret, latestSeq + 1)
|
||||
expect(result).to.exist
|
||||
expect(result.resultCode).to.be.equal('tesSUCCESS')
|
||||
})
|
||||
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')
|
||||
})
|
||||
|
||||
describe('I/O', () => {
|
||||
let treeRoot
|
||||
it(`can tree write (${TEST_DATA.length} bytes)`, async function () {
|
||||
this.timeout(10000)
|
||||
treeRoot = await treeWrite(api, TEST_DATA, sendWallet, receiveWallet.address)
|
||||
})
|
||||
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('can tree read', async function () {
|
||||
this.timeout(15000)
|
||||
const data = await treeRead(api, [treeRoot])
|
||||
expect(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(`can tree write large (${longText.length} bytes)`, async function () {
|
||||
this.timeout(30000)
|
||||
treeRoot = await treeWrite(api, longText, sendWallet, receiveWallet.address)
|
||||
})
|
||||
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('can tree read large', async function () {
|
||||
this.timeout(30000)
|
||||
const data = await treeRead(api, [treeRoot])
|
||||
expect(data).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(`can tree write extra large (${htmlTxt.length} bytes)`, async function () {
|
||||
this.timeout(300000)
|
||||
treeRoot = await treeWrite(api, htmlTxt, sendWallet, receiveWallet.address)
|
||||
})
|
||||
|
||||
it('can tree read extra large', async function () {
|
||||
this.timeout(300000)
|
||||
const data = await treeRead(api, [treeRoot])
|
||||
expect(data).to.be.equal(htmlTxt)
|
||||
})
|
||||
|
||||
it("can r/w binary", async function () {
|
||||
this.timeout(10000);
|
||||
|
||||
const bytes = utf8.encode(TEST_DATA)
|
||||
const encoded = base64.encode(bytes)
|
||||
const txHash = await treeWrite(api, encoded, sendWallet, receiveWallet.address)
|
||||
const res = await treeRead(api, [txHash])
|
||||
const decoded_bytes = base64.decode(res)
|
||||
const text = utf8.decode(decoded_bytes)
|
||||
expect(text).to.be.equal(TEST_DATA)
|
||||
})
|
||||
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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user