Skip to content

Commit 28ac6ee

Browse files
committed
fix: mocha tests
1 parent e9b5db8 commit 28ac6ee

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

example/Tests.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,17 @@ class Tests extends Component {
128128
});
129129
// global.fs = require("react-native-fs");
130130
// global.path = require("path-browserify");
131-
global.environment = {
132-
// Default to the host machine when running on Android
133-
// realmBaseUrl: Platform.OS === "android" ? "http://10.0.2.2:9090" : undefined,
134-
...context,
135-
// reactNative: Platform.OS,
136-
// android: Platform.OS === "android",
137-
// ios: Platform.OS === "ios",
138-
};
131+
// global.environment = {
132+
// Default to the host machine when running on Android
133+
// realmBaseUrl: Platform.OS === "android" ? "http://10.0.2.2:9090" : undefined,
134+
// ...context,
135+
// reactNative: Platform.OS,
136+
// android: Platform.OS === "android",
137+
// ios: Platform.OS === "ios",
138+
// };
139+
(global as any).environment = JSON.parse(
140+
Buffer.from(context.c as string, 'hex').toString('utf-8'),
141+
);
139142
// Make the tests reinitializable, to allow test running on changes to the "realm" package
140143
// Probing the existance of `getModules` as this only exists in debug mode
141144
// if ("getModules" in require) {

example/docker/docker-compose.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3'
21
services:
32
bitcoind:
43
container_name: bitcoin
@@ -112,12 +111,10 @@ services:
112111
depends_on:
113112
- bitcoind
114113
expose:
115-
- '18080' # REST
116-
- '18081' # DOCPORT
114+
- '18081' # REST
117115
- '9736' # P2P
118116
- '11001' # RPC
119117
ports:
120-
- '18080:18080'
121118
- '18081:18081'
122119
- '9736:9736'
123120
- '11001:11001'
@@ -135,11 +132,12 @@ services:
135132
- '--dev-bitcoind-poll=2'
136133
- '--dev-fast-gossip'
137134
- '--grpc-port=11001'
135+
- '--log-file=-'
138136
- '--bitcoin-rpcport=18443'
139-
- '--plugin=/opt/c-lightning-rest/plugin.js'
140-
- '--rest-port=18080'
141-
- '--rest-protocol=http'
142-
- '--rest-docport=18081'
137+
- '--clnrest-port=18081'
138+
- '--clnrest-protocol=http'
139+
- '--clnrest-host=0.0.0.0'
140+
- '--developer'
143141

144142
eclair:
145143
container_name: eclair

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"reinstall": "cd ../lib/ && yarn install && yarn build && cd ../example/ && yarn add ../lib && yarn rn-setup",
2121
"clean": "rm -rf node_modules ios/Pods ios/Podfile.lock ios/build && yarn install && cd ios && pod deintegrate && pod install && cd ../",
2222
"rn-setup": "node rn-setup.js",
23-
"test:mocha": "mocha-remote --context lndmacaroon=$(xxd -ps -u -c 1000 docker/lnd/admin.macaroon) clmacaroon=$(xxd -ps -u -c 1000 docker/clightning/access.macaroon)",
24-
"test:mocha:ios": "mocha-remote --context lndmacaroon=$(xxd -ps -u -c 1000 docker/lnd/admin.macaroon) clmacaroon=$(xxd -ps -u -c 1000 docker/clightning/access.macaroon) -- concurrently --kill-others-on-fail npm:m npm:runner-ios",
25-
"test:mocha:android": "mocha-remote --context lndmacaroon=$(xxd -ps -u -c 1000 docker/lnd/admin.macaroon) clmacaroon=$(xxd -ps -u -c 1000 docker/clightning/access.macaroon) -- concurrently --kill-others-on-fail npm:m npm:runner-android",
23+
"test:mocha": "mocha-remote --context c=$(node ./tests/context.js)",
24+
"test:mocha:ios": "mocha-remote --context c=$(node ./tests/context.js) -- concurrently --kill-others-on-fail npm:m npm:runner-ios",
25+
"test:mocha:android": "mocha-remote --context c=$(node ./tests/context.js) -- concurrently --kill-others-on-fail npm:m npm:runner-android",
2626
"m": "react-native start --reset-cache",
2727
"runner-ios": "react-native run-ios --simulator='iPhone 14' --no-packager",
2828
"runner-android": "react-native run-android --no-packager"

example/tests/context.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require('fs');
2+
const run = require('child_process').execSync;
3+
4+
// read lnd macaroon
5+
const lndmacaroon = fs
6+
.readFileSync('docker/lnd/admin.macaroon')
7+
.toString('hex')
8+
.toUpperCase();
9+
10+
// run command to read clightnng rune
11+
const clightning = run(
12+
'cd docker; docker compose exec --user clightning clightning lightning-cli createrune --regtest',
13+
);
14+
const lcrune = JSON.parse(clightning).rune;
15+
16+
const context = { lndmacaroon, lcrune };
17+
const encoded = Buffer.from(JSON.stringify(context)).toString('hex');
18+
console.log(encoded);

0 commit comments

Comments
 (0)