diff --git a/.travis.yml b/.travis.yml index cf00c3b6f..71ac52431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ before_script: - export AQUARIUS_URI="http://172.15.0.5:5000" - export DEPLOY_CONTRACTS="true" - export CONTRACTS_VERSION=v0.5.7 + - export PROVIDER_VERSION=latest - bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & - cd .. - ./scripts/waitforcontracts.sh diff --git a/src/provider/Provider.ts b/src/provider/Provider.ts index eb6e20f68..715ad9938 100644 --- a/src/provider/Provider.ts +++ b/src/provider/Provider.ts @@ -73,6 +73,23 @@ export class Provider extends Instantiable { } } + public async checkURL(url: string): Promise> { + const args = { url } + try { + const response = await this.ocean.utils.fetch.post( + this.getCheckURLEndpoint(), + decodeURI(JSON.stringify(args)) + ) + + const result = await response.json() + + return result.result + } catch (e) { + this.logger.error(e) + throw new Error('HTTP request failed') + } + } + /** Get nonce from provider * @param {String} consumerAddress * @return {Promise} string @@ -281,6 +298,10 @@ export class Provider extends Instantiable { return `${this.url}${apiPath}/encrypt` } + public getCheckURLEndpoint(): string { + return `${this.url}${apiPath}/checkURL` + } + public getPublishEndpoint(): string { return `${this.url}${apiPath}/publish` } diff --git a/test/integration/Provider.test.ts b/test/integration/Provider.test.ts index 7c0334b75..c0c5e93ca 100644 --- a/test/integration/Provider.test.ts +++ b/test/integration/Provider.test.ts @@ -16,4 +16,10 @@ describe('Provider tests', () => { const valid = await ocean.provider.isValidProvider('http://127.0.0.1:8030') assert(valid === true) }) + it('Check a valid URL', async () => { + const url = 'https://s3.amazonaws.com/testfiles.oceanprotocol.com/info.0.json' + const response = await ocean.provider.checkURL(url) + assert(response.contentLength === '1161') + assert(response.contentType === 'application/json') + }) }) diff --git a/test/unit/balancer/Balancer.test.ts b/test/unit/balancer/Balancer.test.ts index 8fa9f3a44..1957b75c8 100644 --- a/test/unit/balancer/Balancer.test.ts +++ b/test/unit/balancer/Balancer.test.ts @@ -427,18 +427,18 @@ describe('Balancer flow', () => { assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance)) assert(parseFloat(poolShares) > parseFloat(newpoolShares)) }) - it('ALice should know how many tokens she will get for removing all liquidity', async () => { + it('Alice should know how many tokens she will get for removing all liquidity', async () => { const aliceShares = await Pool.sharesBalance(alice, greatPool) const amounts = await Pool.getTokensRemovedforPoolShares(greatPool, aliceShares) assert(parseFloat(amounts.dtAmount) > 0) assert(parseFloat(amounts.oceanAmount) > 0) }) - it('ALice should get all her shares for all the pools', async () => { + it('Alice should get all her shares for all the pools', async () => { const aliceShares = await Pool.getPoolSharesByAddress(alice) assert(aliceShares.length > 0) }) - it('ALice should remove all liquidity', async () => { + it('Alice should remove all liquidity', async () => { const aliceShares = await Pool.sharesBalance(alice, greatPool) const aliceDtBalance = await datatoken.balance(tokenAddress, alice) const aliceOceanBalance = await datatoken.balance(oceanTokenAddress, alice) @@ -450,12 +450,12 @@ describe('Balancer flow', () => { assert(parseFloat(aliceOceanBalance) < parseFloat(newAliceOceanBalance)) assert(parseFloat(aliceShares) > parseFloat(newAliceShares)) }) - it('ALice should get all the pools that she created', async () => { + it('Alice should get all the pools that she created', async () => { const alicePools = await Pool.getPoolsbyCreator(alice) assert(alicePools.length > 0) }) - it('ALice should get the logs for her pool', async () => { + it('Alice should get the logs for her pool', async () => { const poolLogs = await Pool.getPoolLogs(greatPool, null) assert(poolLogs.length > 0) })