mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 07:35:52 +00:00
committed by
Mayukha Vadari
parent
8c5bc22317
commit
e200de3073
@@ -1,48 +1,48 @@
|
||||
import { Client, BroadcastClient } from "xrpl-local";
|
||||
import { Client, BroadcastClient } from 'xrpl-local'
|
||||
|
||||
import { PortResponse } from "./mockRippled";
|
||||
import { PortResponse } from './mockRippled'
|
||||
|
||||
const port = 34371;
|
||||
const baseUrl = "ws://testripple.circleci.com:";
|
||||
const port = 34371
|
||||
const baseUrl = 'ws://testripple.circleci.com:'
|
||||
|
||||
function setup(this: any, port_ = port) {
|
||||
const tclient = new Client(baseUrl + port_);
|
||||
async function setup(this: any, port_ = port) {
|
||||
const tclient = new Client(baseUrl + port_)
|
||||
return tclient
|
||||
.connect()
|
||||
.then(() => {
|
||||
.then(async () => {
|
||||
return tclient.connection.request({
|
||||
command: "test_command",
|
||||
command: 'test_command',
|
||||
data: { openOnOtherPort: true },
|
||||
});
|
||||
})
|
||||
})
|
||||
.then((got) => {
|
||||
.then(async (got) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.client = new Client(baseUrl + (got as PortResponse).result.port);
|
||||
this.client.connect().then(resolve).catch(reject);
|
||||
});
|
||||
this.client = new Client(baseUrl + (got as PortResponse).result.port)
|
||||
this.client.connect().then(resolve).catch(reject)
|
||||
})
|
||||
})
|
||||
.then(async () => {
|
||||
return tclient.disconnect()
|
||||
})
|
||||
.then(() => {
|
||||
return tclient.disconnect();
|
||||
});
|
||||
}
|
||||
|
||||
function setupBroadcast(this: any) {
|
||||
const servers = [port, port + 1].map((port_) => baseUrl + port_);
|
||||
this.client = new BroadcastClient(servers);
|
||||
async function setupBroadcast(this: any) {
|
||||
const servers = [port, port + 1].map((port_) => baseUrl + port_)
|
||||
this.client = new BroadcastClient(servers)
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.client.connect().then(resolve).catch(reject);
|
||||
});
|
||||
this.client.connect().then(resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
|
||||
function teardown(this: any) {
|
||||
if (this.client.isConnected()) {
|
||||
return this.client.disconnect();
|
||||
return this.client.disconnect()
|
||||
}
|
||||
return undefined;
|
||||
return undefined
|
||||
}
|
||||
|
||||
export default {
|
||||
setup,
|
||||
teardown,
|
||||
setupBroadcast,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user