mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 23:55:49 +00:00
Revert "Revert "Merge pull request #1052 from FredKSchott/tests-to-ts-03""
This reverts commit b648387a57.
This commit is contained in:
53
test/integration/connection-test.ts
Normal file
53
test/integration/connection-test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import Connection from '../../src/common/connection';
|
||||
|
||||
const request1 = {
|
||||
command: 'server_info'
|
||||
};
|
||||
|
||||
const request2 = {
|
||||
command: 'account_info',
|
||||
account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59'
|
||||
};
|
||||
|
||||
const request3 = {
|
||||
command: 'account_info'
|
||||
};
|
||||
|
||||
const request4 = {
|
||||
command: 'account_info',
|
||||
account: 'invalid'
|
||||
};
|
||||
|
||||
function makeRequest(connection, request) {
|
||||
return connection.request(request).then((response) => {
|
||||
console.log(request);
|
||||
console.log(JSON.stringify(response, null, 2));
|
||||
}).catch((error) => {
|
||||
console.log(request);
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
function main() {
|
||||
const connection = new Connection('wss://s1.ripple.com');
|
||||
connection.connect().then(() => {
|
||||
console.log('Connected');
|
||||
Promise.all([
|
||||
makeRequest(connection, request1),
|
||||
makeRequest(connection, request2),
|
||||
makeRequest(connection, request3),
|
||||
makeRequest(connection, request4)
|
||||
]).then(() => {
|
||||
console.log('Done');
|
||||
});
|
||||
connection.getLedgerVersion().then(console.log);
|
||||
connection.on('ledgerClosed', ledger => {
|
||||
console.log(ledger);
|
||||
connection.getLedgerVersion().then(console.log);
|
||||
});
|
||||
connection.hasLedgerVersions(1, 100).then(console.log);
|
||||
connection.hasLedgerVersions(16631039, 16631040).then(console.log);
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user