Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mocha tests #203

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/mocha-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ jobs:
uses: douglascamata/setup-docker-macos-action@v1-alpha
id: docker1
continue-on-error: true
with:
lima: v0.18.0
colima: v0.5.6

- name: Setup Docker Colima 2
if: steps.docker1.outcome != 'success'
uses: douglascamata/setup-docker-macos-action@v1-alpha
id: docker2
continue-on-error: true
with:
lima: v0.18.0
colima: v0.5.6

- name: Setup Docker Default
if: steps.docker1.outcome != 'success' && steps.docker2.outcome != 'success'
Expand All @@ -41,7 +47,7 @@ jobs:
mkdir lnd
mkdir clightning
chmod 777 lnd clightning
docker-compose up -d
docker-compose up -d --quiet-pull

- name: Wait for electrum server
timeout-minutes: 2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/mocha-anrdoid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ adb reverse tcp:9737 tcp:9737
adb reverse tcp:18080 tcp:18080
adb reverse tcp:28081 tcp:28081
adb reverse tcp:60001 tcp:60001
adb shell date `date +%m%d%H%M%G.%S`

set +e
yarn test:mocha:android
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/mocha-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ jobs:
uses: douglascamata/setup-docker-macos-action@v1-alpha
id: docker1
continue-on-error: true
with:
lima: v0.18.0
colima: v0.5.6

- name: Setup Docker Colima 2
if: steps.docker1.outcome != 'success'
uses: douglascamata/setup-docker-macos-action@v1-alpha
id: docker2
continue-on-error: true
with:
lima: v0.18.0
colima: v0.5.6

- name: Setup Docker Default
if: steps.docker1.outcome != 'success' && steps.docker2.outcome != 'success'
Expand All @@ -41,7 +47,7 @@ jobs:
mkdir lnd
mkdir clightning
chmod 777 lnd clightning
docker-compose up -d
docker-compose up -d --quiet-pull

- name: Wait for electrum server
timeout-minutes: 2
Expand Down
13 changes: 13 additions & 0 deletions backup-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20

WORKDIR /app

COPY package*.json ./

RUN npm install --production

COPY . .

EXPOSE 3003

CMD [ "node", "index.js" ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
</network-security-config>
13 changes: 13 additions & 0 deletions example/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ services:
- '9091:9091'
- '9092:9092'

ldk-backup-server:
container_name: ldk-backup-server
image: synonymsoft/ldk-backup-server:1.0.0
expose:
- '3003'
ports:
- '3003:3003'
environment:
HOST: '0.0.0.0'
PORT: '3003'
SECRET_KEY: 'e3e2d2e410569be1f2219e1ef21f188f7ccff1ce721ea2624263d3fe9878f69e'
PUBLIC_KEY: '0319c4ff23820afec0c79ce3a42031d7fef1dff78b7bdd69b5560684f3e1827675'

volumes:
b_home:

Expand Down
1 change: 1 addition & 0 deletions example/tests/clightning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const clConfig = {
};

describe('Clightning', function () {
this.retries(3);
this.timeout(5 * 60 * 1000); // 5 minutes
let waitForElectrum: any;
const rpc = new BitcoinJsonRpc(bitcoinURL);
Expand Down
12 changes: 8 additions & 4 deletions example/tests/eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const eclairConfig = {
};

describe('Eclair', function () {
this.retries(3);
this.timeout(5 * 60 * 1000); // 5 minutes
let waitForElectrum: any;
const rpc = new BitcoinJsonRpc(bitcoinURL);
Expand Down Expand Up @@ -128,10 +129,13 @@ describe('Eclair', function () {
// network: ldkNetwork(selectedNetwork),
getFees: () => {
return Promise.resolve({
highPriority: 30,
normal: 20,
background: 10,
mempoolMinimum: 5,
onChainSweep: 30,
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 30 * 10),
minAllowedAnchorChannelRemoteFee: 5,
minAllowedNonAnchorChannelRemoteFee: Math.max(5 - 1, 0),
anchorChannelFee: 10,
nonAnchorChannelFee: 20,
channelCloseMinimum: 5,
});
},
});
Expand Down
1 change: 1 addition & 0 deletions example/tests/lnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const lndConfig = {
};

describe('LND', function () {
this.retries(3);
this.timeout(5 * 60 * 1000); // 5 minutes
let waitForElectrum: any;
const rpc = new BitcoinJsonRpc(bitcoinURL);
Expand Down
6 changes: 5 additions & 1 deletion example/tests/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ describe('Unit', function () {
hex: '000000205d1f3ece3bcb0a3530adaae2e4aa47f8aad434db95c6cb6d09d5ac99e3f6df4f0a19fe968830a06dcc49c9cca4acc532226e4c30b741802420e0fdd2b092eccdbf95cb64ffff7f2000000000',
}),
account,
getAddress: async () => 'bcrt1qtk89me2ae95dmlp3yfl4q9ynpux8mxjus4s872',
getAddress: async () => ({
address: 'bcrt1qtk89me2ae95dmlp3yfl4q9ynpux8mxjus4s872',
publicKey:
'0298720ece754e377af1b2716256e63c2e2427ff6ebdc66c2071c43ae80132ca32',
}),
getScriptPubKeyHistory: async () => [],
getFees: () => {
return Promise.resolve({
Expand Down
30 changes: 24 additions & 6 deletions example/tests/utils/test-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as bitcoin from 'bitcoinjs-lib';
import { randomBytes } from 'react-native-randombytes';
import { Platform } from 'react-native';
import {
IAddress,
TAccount,
TAvailableNetworks,
THeader,
Expand Down Expand Up @@ -71,17 +72,31 @@ export default class TestProfile {
getScriptPubKeyHistory: this.getScriptPubKeyHistory,
getFees: () =>
Promise.resolve({
highPriority: 4,
normal: 3,
background: 2,
mempoolMinimum: 1,
onChainSweep: 4,
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 4 * 10),
minAllowedAnchorChannelRemoteFee: 1,
minAllowedNonAnchorChannelRemoteFee: Math.max(1 - 1, 0),
anchorChannelFee: 2,
nonAnchorChannelFee: 3,
channelCloseMinimum: 1,
}),
getTransactionData: this.getTransactionData,
getTransactionPosition: this.getTransactionPosition,
broadcastTransaction: this.broadcastTransaction,
network: ldkNetwork(this.network),
// forceCloseOnStartup: { forceClose: true, broadcastLatestTx: false },
forceCloseOnStartup: undefined,
// trustedZeroConfPeers: [],
backupServerDetails: {
host: 'https://blocktank.synonym.to/staging-backups-ldk',
serverPubKey:
'02c03b8b8c1b5500b622646867d99bf91676fac0f38e2182c91a9ff0d053a21d6d',
},
// backupServerDetails: {
// host: 'http://127.0.0.1:3003',
// serverPubKey:
// '0319c4ff23820afec0c79ce3a42031d7fef1dff78b7bdd69b5560684f3e1827675',
// },
};
};

Expand All @@ -104,7 +119,7 @@ export default class TestProfile {
return { name: this.name, seed: this.seed };
};

public getAddress = async (): Promise<string> => {
public getAddress = async (): Promise<IAddress> => {
const network = getNetwork(this.network);
const mnemonic = bip39.entropyToMnemonic(this.seed);
const mnemonicSeed = await bip39.mnemonicToSeed(mnemonic);
Expand All @@ -117,7 +132,10 @@ export default class TestProfile {
if (!address) {
throw new Error('Failed to generate address');
}
return address;
return {
address: address,
publicKey: keyPair.publicKey.toString('hex'),
};
};

public getScriptPubKeyHistory = async (
Expand Down
Loading