Browse Source

feat(c-lightning): add support for c-lightning v0.8.1

master
jamaljsr 5 years ago
parent
commit
8423ce7149
  1. 2
      README.md
  2. 2
      docker/clightning/Dockerfile
  3. 3
      docker/clightning/docker-entrypoint.sh
  4. 6
      docker/nodes.json
  5. 11
      src/lib/docker/repoService.spec.ts
  6. 6
      src/utils/constants.ts
  7. 5
      src/utils/tests/helpers.ts

2
README.md

@ -33,7 +33,7 @@ Supported Network Node Versions:
- LND v0.8.2, v0.8.0 & v0.7.1 - LND v0.8.2, v0.8.0 & v0.7.1
- Bitcoin Core v0.19.0.1 & v0.18.1 - Bitcoin Core v0.19.0.1 & v0.18.1
- c-lightning v0.8.0 - c-lightning v0.8.1 & v0.8.0
- eclair (coming soon?) \*need to gauge demand for this implementation\* - eclair (coming soon?) \*need to gauge demand for this implementation\*
## Dependencies ## Dependencies

2
docker/clightning/Dockerfile

@ -134,7 +134,7 @@ RUN apt-get update -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install c-lightning-REST API plugin # install c-lightning-REST API plugin
RUN git clone --branch fix/channels https://github.com/jamaljsr/c-lightning-rest /opt/c-lightning-rest/ \ RUN git clone https://github.com/Ride-The-Lightning/c-lightning-REST.git /opt/c-lightning-rest/ \
&& cd /opt/c-lightning-rest \ && cd /opt/c-lightning-rest \
&& npm install \ && npm install \
&& chmod -R a+rw /opt/c-lightning-rest && chmod -R a+rw /opt/c-lightning-rest

3
docker/clightning/docker-entrypoint.sh

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
set -e set -e
# give bitcoind a second to bootup
sleep 1
# containers on linux share file permissions with hosts. # containers on linux share file permissions with hosts.
# assigning the same uid/gid from the host user # assigning the same uid/gid from the host user
# ensures that the files can be read/write from both sides # ensures that the files can be read/write from both sides

6
docker/nodes.json

@ -1,5 +1,5 @@
{ {
"version": 3, "version": 4,
"images": { "images": {
"LND": { "LND": {
"latest": "0.9.0-beta", "latest": "0.9.0-beta",
@ -12,8 +12,8 @@
} }
}, },
"c-lightning": { "c-lightning": {
"latest": "0.8.0", "latest": "0.8.1",
"versions": ["0.8.0"] "versions": ["0.8.1", "0.8.0"]
}, },
"eclair": { "eclair": {
"latest": "", "latest": "",

11
src/lib/docker/repoService.spec.ts

@ -3,6 +3,7 @@ import { repoService } from 'lib/docker';
import { DockerRepoState } from 'types'; import { DockerRepoState } from 'types';
import { defaultRepoState } from 'utils/constants'; import { defaultRepoState } from 'utils/constants';
import * as files from 'utils/files'; import * as files from 'utils/files';
import { clone } from 'utils/tests';
jest.mock('utils/files', () => ({ jest.mock('utils/files', () => ({
write: jest.fn(), write: jest.fn(),
@ -17,7 +18,7 @@ describe('RepoService', () => {
await repoService.save(defaultRepoState); await repoService.save(defaultRepoState);
expect(filesMock.write).toBeCalledWith( expect(filesMock.write).toBeCalledWith(
expect.stringContaining('nodes.json'), expect.stringContaining('nodes.json'),
expect.stringContaining('"version": 2'), expect.stringContaining(`"version": ${defaultRepoState.version}`),
); );
}); });
@ -38,7 +39,7 @@ describe('RepoService', () => {
const localState = defaultRepoState; const localState = defaultRepoState;
const updatedState: DockerRepoState = { const updatedState: DockerRepoState = {
...defaultRepoState, ...defaultRepoState,
version: 3, version: defaultRepoState.version + 1,
images: { images: {
...defaultRepoState.images, ...defaultRepoState.images,
bitcoind: { bitcoind: {
@ -51,7 +52,7 @@ describe('RepoService', () => {
beforeEach(fetchMock.reset); beforeEach(fetchMock.reset);
it('should return no updates for the same version', async () => { it('should return no updates for the same version', async () => {
fetchMock.once('end:/nodes.json', localState); fetchMock.once('end:/nodes.json', clone(localState));
const result = await repoService.checkForUpdates(localState); const result = await repoService.checkForUpdates(localState);
expect(result.state).toEqual(localState); expect(result.state).toEqual(localState);
expect(result.updates).not.toBeDefined(); expect(result.updates).not.toBeDefined();
@ -59,7 +60,7 @@ describe('RepoService', () => {
it('should return no updates for new version with no new images', async () => { it('should return no updates for new version with no new images', async () => {
fetchMock.once('end:/nodes.json', { fetchMock.once('end:/nodes.json', {
...localState, ...clone(localState),
version: localState.version + 1, version: localState.version + 1,
}); });
const result = await repoService.checkForUpdates(localState); const result = await repoService.checkForUpdates(localState);
@ -68,7 +69,7 @@ describe('RepoService', () => {
}); });
it('should return updated state with new versions', async () => { it('should return updated state with new versions', async () => {
fetchMock.once('end:/nodes.json', updatedState); fetchMock.once('end:/nodes.json', clone(updatedState));
const result = await repoService.checkForUpdates(localState); const result = await repoService.checkForUpdates(localState);
expect(result.state).toEqual(updatedState); expect(result.state).toEqual(updatedState);
expect(result.updates).toBeDefined(); expect(result.updates).toBeDefined();

6
src/utils/constants.ts

@ -114,7 +114,7 @@ export const REPO_STATE_URL =
* are pushed to Docker Hub, this list should be updated along with the /docker/nodes.json file. * are pushed to Docker Hub, this list should be updated along with the /docker/nodes.json file.
*/ */
export const defaultRepoState: DockerRepoState = { export const defaultRepoState: DockerRepoState = {
version: 2, version: 4,
images: { images: {
LND: { LND: {
latest: '0.9.0-beta', latest: '0.9.0-beta',
@ -129,8 +129,8 @@ export const defaultRepoState: DockerRepoState = {
}, },
}, },
'c-lightning': { 'c-lightning': {
latest: '0.8.0', latest: '0.8.1',
versions: ['0.8.0'], versions: ['0.8.1', '0.8.0'],
}, },
eclair: { eclair: {
latest: '', latest: '',

5
src/utils/tests/helpers.ts

@ -22,6 +22,11 @@ export const mockProperty = <T extends {}, K extends keyof T>(
Object.defineProperty(object, property, { get: () => value }); Object.defineProperty(object, property, { get: () => value });
}; };
/**
* Poor man's deep clone. Useful for tests to avoid another dependency
*/
export const clone = (data: object) => JSON.parse(JSON.stringify(data));
/** /**
* Suppresses console errors when executing some code. * Suppresses console errors when executing some code.
* For example: antd Modal.confirm logs a console error when onOk fails * For example: antd Modal.confirm logs a console error when onOk fails

Loading…
Cancel
Save