From 547ed2ead988d2017cea3f66d0a2776c1ff18759 Mon Sep 17 00:00:00 2001 From: Micah Riggan Date: Thu, 21 Nov 2019 11:48:14 -0500 Subject: [PATCH] Adding docker-compose for XRP, adding two tests to verify they do things --- .docker/rippled.Dockerfile | 25 +++++++++ .docker/rippled.cfg | 55 +++++++++++++++++++ bitcore-test.config.json | 12 ++++ docker-compose.test.yml | 5 ++ packages/bitcore-node/package.json | 2 +- packages/bitcore-node/src/routes/api/block.ts | 2 +- .../integration/ripple/csp.integration.ts | 19 +++++++ 7 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 .docker/rippled.Dockerfile create mode 100644 .docker/rippled.cfg create mode 100644 packages/bitcore-node/test/integration/ripple/csp.integration.ts diff --git a/.docker/rippled.Dockerfile b/.docker/rippled.Dockerfile new file mode 100644 index 00000000000..76425c1df3e --- /dev/null +++ b/.docker/rippled.Dockerfile @@ -0,0 +1,25 @@ +FROM node:10-stretch + +RUN apt-get update +RUN apt-get install sudo +RUN adduser --disabled-password --gecos '' docker +RUN adduser docker sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER docker + +RUN sudo apt -y update +RUN sudo apt -y install apt-transport-https ca-certificates wget gnupg +RUN wget -q -O - "https://repos.ripple.com/repos/api/gpg/key/public" | sudo apt-key add - +RUN echo "deb https://repos.ripple.com/repos/rippled-deb stretch stable" | sudo tee -a /etc/apt/sources.list.d/ripple.list +RUN sudo apt -y update +RUN sudo apt -y install rippled + +RUN sudo rm /etc/opt/ripple/rippled.cfg +COPY ./.docker/rippled.cfg /home/docker +RUN sudo cp /home/docker/rippled.cfg /etc/opt/ripple/rippled.cfg + +ENTRYPOINT ["sudo", "rippled", "-a", "--start", "--conf=/home/docker/rippled.cfg"] +EXPOSE 6006 +EXPOSE 6005 +EXPOSE 5005 +EXPOSE 5004 diff --git a/.docker/rippled.cfg b/.docker/rippled.cfg new file mode 100644 index 00000000000..30f32b4802c --- /dev/null +++ b/.docker/rippled.cfg @@ -0,0 +1,55 @@ +[server] +port_rpc_admin_local +port_peer +port_ws_admin_local + +[port_rpc_admin_local] +port = 5005 +ip = 0.0.0.0 +admin = 0.0.0.0 +protocol = http + +[port_peer] +port = 51235 +ip = 0.0.0.0 +protocol = peer + +[port_ws_admin_local] +port = 6006 +ip = 0.0.0.0 +admin = 0.0.0.0 +protocol = ws + +#------------------------------------------------------------------------------- + +[node_size] +medium + +[node_db] +type=RocksDB +path=/var/lib/rippled/regtest/db/rocksdb +open_files=2000 +filter_bits=12 +cache_mb=256 +file_size_mb=8 +file_size_mult=2 +online_delete=2000 +advisory_delete=0 + +[database_path] +/var/lib/rippled/regtest/db + +[debug_logfile] +/var/lib/rippled/regtest/debug.log + +[sntp_servers] +time.windows.com +time.apple.com +time.nist.gov +pool.ntp.org + +[rpc_startup] +{ "command": "log_level", "severity": "warning" } + +[ssl_verify] +1 diff --git a/bitcore-test.config.json b/bitcore-test.config.json index 1ca20bc335b..30140f568d6 100644 --- a/bitcore-test.config.json +++ b/bitcore-test.config.json @@ -1,5 +1,6 @@ { "bitcoreNode": { + "modules": ["./bitcoin", "./bitcoin-cash", "./ethereum", "./ripple"], "services": { "api": { "wallets": { @@ -40,6 +41,17 @@ "port": 8546 } } + }, + "XRP": { + "mainnet": { + "chainSource": "rpc", + "provider": { + "host": "rippled", + "protocol": "ws", + "port": "6006", + "dataHost": "rippled" + } + } } } } diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 1b17f37d628..998e77f2adc 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -17,6 +17,7 @@ services: - db - bitcoin - parity + - rippled db: image: mongo @@ -56,6 +57,10 @@ services: --unlock 00a329c0648769a73afac7f9381e08fb43dbea72 --password /data/pw + rippled: + build: + context: . + dockerfile: ./.docker/rippled.Dockerfile networks: default: diff --git a/packages/bitcore-node/package.json b/packages/bitcore-node/package.json index 5fe020dae83..2f6170ba0fd 100644 --- a/packages/bitcore-node/package.json +++ b/packages/bitcore-node/package.json @@ -35,7 +35,7 @@ "test:integration": "npm run tsc && node ./build/test/runners/integration.js", "benchmark": "npm run tsc && node build/test/benchmark/benchmark.js", "api": "npm run tsc && node build/src/workers/api.js", - "api:debug": "npm run tsc && node build/src/workers/api.js --DEBUG true", + "api:debug": "npm run tsc && node --inspect build/src/workers/api.js --DEBUG true", "api:cluster": "npm run tsc && node build/src/workers/api.js --CLUSTER true", "pruning": "npm run tsc && node build/src/workers/pruning.js --EXIT true", "p2p": "npm run tsc && node build/src/workers/p2p.js" diff --git a/packages/bitcore-node/src/routes/api/block.ts b/packages/bitcore-node/src/routes/api/block.ts index 35f681997bc..d646e5948f6 100644 --- a/packages/bitcore-node/src/routes/api/block.ts +++ b/packages/bitcore-node/src/routes/api/block.ts @@ -30,7 +30,7 @@ router.get('/', async function(req: Request, res: Response) { router.get('/tip', async function(req: Request, res: Response) { let { chain, network } = req.params; try { - let tip = await ChainStateProvider.getBlock({ chain, network }); + let tip = await ChainStateProvider.getLocalTip({ chain, network }); return res.json(tip); } catch (err) { console.error(err); diff --git a/packages/bitcore-node/test/integration/ripple/csp.integration.ts b/packages/bitcore-node/test/integration/ripple/csp.integration.ts new file mode 100644 index 00000000000..0b36021fdb9 --- /dev/null +++ b/packages/bitcore-node/test/integration/ripple/csp.integration.ts @@ -0,0 +1,19 @@ +import { XRP } from '../../../src/modules/ripple/api/csp'; +import { expect } from 'chai'; +const chain = 'XRP'; +const network = 'mainnet'; + +describe('Ripple Api', () => { + it('should be able to get the ledger', async () => { + const client = await XRP.getClient(network); + const ledger = await client.getLedger(); + expect(ledger).to.exist; + expect(ledger.ledgerHash).to.exist; + }); + + it('should be able to get local tip', async () => { + const tip = await XRP.getLocalTip({ chain, network }); + expect(tip).to.exist; + expect(tip.hash).to.exist; + }); +});