run prettier format

This commit is contained in:
Fred K. Schott
2019-12-17 10:35:59 -08:00
parent 64e0d098e7
commit 2145c104fd
174 changed files with 4152 additions and 3228 deletions

View File

@@ -1,67 +1,73 @@
import _ from 'lodash';
import assert from 'assert-diff';
import setupAPI from './setup-api';
import responses from './fixtures/responses';
import ledgerClosed from './fixtures/rippled/ledger-close.json';
import {RippleAPI} from 'ripple-api';
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
import _ from 'lodash'
import assert from 'assert-diff'
import setupAPI from './setup-api'
import responses from './fixtures/responses'
import ledgerClosed from './fixtures/rippled/ledger-close.json'
import {RippleAPI} from 'ripple-api'
const schemaValidator = RippleAPI._PRIVATE.schemaValidator
const TIMEOUT = 20000;
const TIMEOUT = 20000
function checkResult(expected, schemaName, response) {
if (expected.txJSON) {
assert(response.txJSON);
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON));
assert(response.txJSON)
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON))
}
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'));
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'))
if (schemaName) {
schemaValidator.schemaValidate(schemaName, response);
schemaValidator.schemaValidate(schemaName, response)
}
return response;
return response
}
describe('RippleAPIBroadcast', function() {
this.timeout(TIMEOUT);
beforeEach(setupAPI.setupBroadcast);
afterEach(setupAPI.teardown);
this.timeout(TIMEOUT)
beforeEach(setupAPI.setupBroadcast)
afterEach(setupAPI.teardown)
it('base', function() {
const expected = {request_server_info: 1};
this.mocks.forEach(mock => mock.expect(_.assign({}, expected)));
assert(this.api.isConnected());
return this.api.getServerInfo().then(
_.partial(checkResult, responses.getServerInfo, 'getServerInfo'));
});
const expected = {request_server_info: 1}
this.mocks.forEach(mock => mock.expect(_.assign({}, expected)))
assert(this.api.isConnected())
return this.api
.getServerInfo()
.then(_.partial(checkResult, responses.getServerInfo, 'getServerInfo'))
})
it('ledger', function(done) {
let gotLedger = 0;
let gotLedger = 0
this.api.on('ledger', () => {
gotLedger++;
});
const ledgerNext = _.assign({}, ledgerClosed);
ledgerNext.ledger_index++;
gotLedger++
})
const ledgerNext = _.assign({}, ledgerClosed)
ledgerNext.ledger_index++
this.api._apis.forEach(api => api.connection._send(JSON.stringify({
command: 'echo',
data: ledgerNext
})));
this.api._apis.forEach(api =>
api.connection._send(
JSON.stringify({
command: 'echo',
data: ledgerNext
})
)
)
setTimeout(() => {
assert.strictEqual(gotLedger, 1);
done();
}, 1250);
});
assert.strictEqual(gotLedger, 1)
done()
}, 1250)
})
it('error propagation', function(done) {
this.api.once('error', (type, info) => {
assert.strictEqual(type, 'type');
assert.strictEqual(info, 'info');
done();
});
this.api._apis[1].connection._send(JSON.stringify({
command: 'echo',
data: {error: 'type', error_message: 'info'}
}));
});
});
assert.strictEqual(type, 'type')
assert.strictEqual(info, 'info')
done()
})
this.api._apis[1].connection._send(
JSON.stringify({
command: 'echo',
data: {error: 'type', error_message: 'info'}
})
)
})
})