Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function navigateTo(url) {
if (process.env.DUMP_HTTP) {
const res = await popsicle.get(url)
/* eslint-disable no-console */
console.log(`GET ${url} ${res.status}`)
console.log(res.headers)
console.log(res.body)
/* eslint-enable no-console */
}
await browser.url(url)
}
it('renders contents of home page', async () => {
const html = (await popsicle.get(process.env.ROOT_URL)).body
expect(html).to.match(/Welcome to Crater!/)
})
it('renders contents of about page', async () => {
function nodeStatus(baseUrl, cb) {
const request = popsicle.get(
`${baseUrl || __testContext.baseUrl}/api/node/status`
);
request.use(popsicle.plugins.parse(['json']));
request.then(res => {
if (res.status !== 200) {
return setImmediate(
cb,
['Received bad response code', res.status, res.url].join(' ')
);
}
return setImmediate(cb, null, res.body.data);
});
request.catch(err => {
doWhilstCb => {
const request = popsicle.get(
`${baseUrl || __testContext.baseUrl}/api/node/status`
);
request.use(popsicle.plugins.parse(['json']));
request.then(res => {
if (res.status !== 200) {
return doWhilstCb(
['Received bad response code', res.status, res.url].join(' ')
);
}
__testContext.debug(
'Waiting for block:'.grey,
'Height:'.grey,
res.body.data.height,
'Target:'.grey,
(function fetchBlockchainStatus() {
popsicle
.get(`${baseUrl}/api/node/status`)
.then(res => {
retries -= 1;
res = JSON.parse(res.body);
if (!res.data.loaded && retries >= 0) {
if (!doNotLogRetries) {
__testContext.debug(
`Retrying ${totalRetries -
retries} time loading blockchain in next ${timeout /
1000.0} seconds...`
);
}
return setTimeout(() => {
fetchBlockchainStatus();
}, timeout);
}
getNodeStatus(port, ip) {
return popsicle
.get({
url: endpoints.versions[currentVersion].getNodeStatus(
ip || '127.0.0.1',
port || 4000
),
headers,
})
.then(res => {
return JSON.parse(res.body).data;
});
},
export const getDynamicFees = () => new Promise(async (resolve, reject) => {
try {
const config = getBtcConfig(0);
const response = await popsicle.get(config.minerFeesURL)
.use(popsicle.plugins.parse('json'));
const json = response.body;
if (response) {
resolve({
Low: json.hourFee,
Medium: json.halfHourFee,
High: json.fastestFee,
});
} else {
reject(json);
}
} catch (error) {
reject(error);
}
});
}) => new Promise((resolve, reject) => {
serverUrl = networkConfig ? getServerUrl(networkConfig) : serverUrl;
popsicle.get(`${serverUrl}${path}?${new URLSearchParams(searchParams)}`)
.use(popsicle.plugins.parse('json'))
.then((response) => {
if (response.statusType() === 2) {
resolve(transformResponse(response.body));
} else {
reject(new Error(response.body.message || response.body.error));
}
}).catch((error) => {
if (error.code === 'EUNAVAILABLE') {
const networkName = getNetworkNameBasedOnNethash(networkConfig);
error = new Error(i18n.t('Unable to connect to {{networkName}}', { networkName }));
}
reject(error);
});
});