Skip to content

Commit 9bf029f

Browse files
committed
feat: add sim support to litd
In the commit we add the sinln support to litd nodes.
1 parent f3d59d8 commit 9bf029f

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

src/components/designer/default/AddSimulationModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const AddSimulationModal: React.FC<Props> = ({ network }) => {
113113
name="source"
114114
label={l('source')}
115115
nodeStatus={Status.Started}
116-
implementation={['LND', 'eclair', 'c-lightning']}
116+
implementation={['LND', 'eclair', 'c-lightning', 'litd']}
117117
nodes={nodes}
118118
/>
119119
</Col>
@@ -123,7 +123,7 @@ const AddSimulationModal: React.FC<Props> = ({ network }) => {
123123
name="destination"
124124
label={l('destination')}
125125
nodeStatus={Status.Started}
126-
implementation={['LND', 'eclair', 'c-lightning']}
126+
implementation={['LND', 'eclair', 'c-lightning', 'litd']}
127127
nodes={nodes}
128128
/>
129129
</Col>

src/lib/docker/dockerService.spec.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ describe('DockerService', () => {
889889
eclairNodes: 1,
890890
bitcoindNodes: 1,
891891
tapdNodes: 0,
892-
litdNodes: 0,
892+
litdNodes: 1,
893893
repoState: defaultRepoState,
894894
managedImages: testManagedImages,
895895
customImages: [],
@@ -902,6 +902,7 @@ describe('DockerService', () => {
902902
const clightningNodes = network.nodes.lightning.filter(
903903
n => n.implementation === 'c-lightning',
904904
);
905+
const litdNodes = network.nodes.lightning.filter(n => n.implementation === 'litd');
905906
beforeEach(() => {
906907
// Add simulation config to the test network
907908
network.simulation = {
@@ -966,13 +967,6 @@ describe('DockerService', () => {
966967
);
967968
});
968969

969-
it('should handle errors when using unsupported node types', async () => {
970-
network.nodes.lightning[0].implementation = 'litd';
971-
await expect(dockerService.startSimulation(network)).rejects.toThrow(
972-
'unsupported node implementation: litd',
973-
);
974-
});
975-
976970
it('should handle errors when node is not found', async () => {
977971
network.simulation!.activity[0].source = 'non-existent';
978972
await expect(dockerService.startSimulation(network)).rejects.toThrow(
@@ -999,14 +993,14 @@ describe('DockerService', () => {
999993
);
1000994
});
1001995

1002-
// Now we should be able to use c-lightning in the simulation
996+
// Now we should be able to use c-lightning and litd in the simulation
1003997
it('should add c-lightning to the docker-compose.yml file', async () => {
1004998
network.simulation = {
1005999
activity: [
10061000
{
10071001
id: 0,
10081002
source: clightningNodes[0].name,
1009-
destination: eclairNodes[0].name,
1003+
destination: litdNodes[0].name,
10101004
intervalSecs: 60,
10111005
amountMsat: 1000,
10121006
},

src/lib/docker/dockerService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,17 @@ class DockerService implements DockerLibrary {
470470
};
471471
break;
472472

473-
default:
474-
throw new Error(`unsupported node implementation: ${node.implementation}`);
473+
case 'litd':
474+
const litd = node as LitdNode;
475+
simNode = {
476+
id: litd.name,
477+
address: `host.docker.internal:${litd.ports.grpc}`,
478+
cert: `/home/simln/.${litd.paths.tlsCert.split('volumes/').pop()}`,
479+
macaroon: `/home/simln/.${litd.paths.adminMacaroon
480+
.split('volumes/')
481+
.pop()}`,
482+
};
483+
break;
475484
}
476485

477486
// Add the node to the nodes Set.

src/lib/docker/nodeTemplates.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export const simln = (
199199
`./volumes/${name}:/home/simln/.simln`,
200200
`./volumes/${dockerConfigs.LND.volumeDirName}:/home/simln/.lnd`,
201201
`./volumes/${dockerConfigs['c-lightning'].volumeDirName}:/home/simln/.c-lightning`,
202+
`./volumes/${dockerConfigs.litd.volumeDirName}:/home/simln/.litd`,
202203
],
203204
expose: [],
204205
ports: [],

0 commit comments

Comments
 (0)