Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const r = await request(server)
.get('/v1/ticker/ubqeur')
.expect(200)
expectTickerResponse(r)
})
test('when req -> /v1/ticker/ubqltc | resp -> 200', async () => {
const r = await request(server)
.get('/v1/ticker/ubqeur')
.expect(200)
expectTickerResponse(r)
})
test('when req -> /v1/ticker/invalid | resp -> 400', async () =>
await request(server)
.get('/v1/ticker/invalid')
.expect(404))
})
expectStandardResponse(r)
}
})
test('params [] | resp -> 400', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getWork?params=[]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
}
})
test('params [invalid] | resp -> 400', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getWork?params=["invalid"]`)
.expect('Content-Type', /json/)
.expect(400)
expectStandardErrorResponse(r)
}
})
})
})
}
})
test('params [earliest] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["earliest"]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
}
})
test('params [latest] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["latest"]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
}
})
test('params [pending] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["pending"]`)
.expect('Content-Type', /json/)
}
})
test('params [latest] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["latest"]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
}
})
test('params [pending] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["pending"]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
}
})
})
})
.set('Authorization', authHeader)
.send({
url: screencastUrl,
tags: 'foo,bar'
})
const result = await request(app)
.post('/api/screencasts')
.set('Authorization', authHeader)
.send({
url: screencastUrl,
tags: 'foo,bar'
})
expect(result.statusCode).to.equal(409)
})
test('Invalid POST with invalid url should return 400', async () => {
const password = config.adminPassword
const encodedPassword = new Buffer(password).toString('base64')
const authHeader = `Basic: ${encodedPassword}`
const {statusCode} = await request(app)
.post('/api/screencasts')
.set('Authorization', authHeader)
.send({
url: 'foo'
})
expect(statusCode).to.equal(400)
})
test('Invalid POST with missing req body should return 400', async () => {
const password = config.adminPassword
const encodedPassword = new Buffer(password).toString('base64')
for (const network of networks) {
const url = [
`/v1/jsonrpc/${network}/eth_call?params=`,
'[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155", "invalidkey": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "earliest"]'
].join('')
const r = await request(server)
.get(url)
.expect('Content-Type', /json/)
.expect(400)
expectStandardErrorResponse(r)
}
}
)
test('params [{to: 0xb60e8dd61c5d32be8058bb8eb970870f07233155}, earliest] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_call?params=[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "earliest"]`)
.expect('Content-Type', /json/)
.expect(200)
expectStandardResponse(r)
expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x'))
}
})
test('params [{to: 0xb60e8dd61c5d32be8058bb8eb970870f07233155}, latest] | resp -> 200', async () => {
for (const network of networks) {
const r = await request(server)
.get(`/v1/jsonrpc/${network}/eth_call?params=[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "latest"]`)
.expect('Content-Type', /json/)
describe('when req -> /v1/jsonrpc/{network}/ | body: eth_sendRawTransaction', () => {
test('body [method] | resp -> 400', async () => {
for (const network of networks) {
const r = await request(server)
.post(`/v1/jsonrpc/${network}/`)
.send({
method: 'eth_sendRawTransaction'
})
.expect('Content-Type', /json/)
.expect(400)
expectStandardErrorResponse(r)
}
})
test('body [id, method] | resp -> 400', async () => {
for (const network of networks) {
const r = await request(server)
suite('bytes filter', () => {
test('bytes filter', () => {
assert.equal(bytesFilterInstance(0), '0 bytes');
assert.equal(bytesFilterInstance(1000), '1000.0 bytes');
assert.equal(bytesFilterInstance(1024), '1.0 kB');
assert.equal(bytesFilterInstance(5000), '4.9 kB');
assert.equal(bytesFilterInstance(1048576), '1.0 MB');
assert.equal(bytesFilterInstance(104857600), '100.0 MB');
assert.equal(bytesFilterInstance(1073741824), '1.0 GB');
assert.equal(bytesFilterInstance(1099511627776), '1.0 TB');
});
});
suite('Agent manager service', () => {
test('allFeatures', () => {
const cluster: ClusterStats = {supportedFeatures: '+/l9'};
const service = new AgentManager();
const features = service.allFeatures(cluster);
assert.ok(features.includes(IgniteFeatures.INDEXING));
assert.ok(features.includes(IgniteFeatures.WC_SNAPSHOT_CHAIN_MODE));
assert.ok(features.includes(IgniteFeatures.WC_ROLLING_UPGRADE_STATUS));
});
test('noFeaturesOnOldNode', () => {
const cluster: ClusterStats = {supportedFeatures: null};
const service = new AgentManager();
const features = service.allFeatures(cluster);
assert.isNotOk(features.includes(IgniteFeatures.INDEXING));
assert.isNotOk(features.includes(IgniteFeatures.WC_SNAPSHOT_CHAIN_MODE));
assert.isNotOk(features.includes(IgniteFeatures.WC_ROLLING_UPGRADE_STATUS));
});
});
suite.skip('page-configure, ConfigurationDownload service', () => {
test('fails and shows error message when cluster not found', () => {
const service = new Provider(...mocks().values());
return service.downloadClusterConfiguration({_id: 1, name: 'An Cluster'})
.then(() => Promise.reject('Should not happen'))
.catch(() => {
assert.equal(
service.messages.showError.getCall(0).args[0],
'Failed to generate project files. Cluster An Cluster not found',
'shows correct error message when cluster was not found'
);
});
});
test('fails and shows error message when summary zipper fails', () => {
const service = new Provider(...mocks().values());
const cluster = {_id: 1, name: 'An Cluster'};
service.configuration._clusters = [cluster];
service.summaryZipper = () => Promise.reject({message: 'Summary zipper failed.'});
return service.downloadClusterConfiguration(cluster)
.then(() => Promise.reject('Should not happen'))
.catch(() => {
assert.equal(
service.messages.showError.getCall(0).args[0],
'Failed to generate project files. Summary zipper failed.',
'shows correct error message when summary zipper fails'
);
});
});
test('calls correct dependcies', () => {