Skip to content

Commit

Permalink
fix: mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Jan 24, 2024
1 parent 213b26a commit 089e0e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
11 changes: 7 additions & 4 deletions example/tests/eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,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
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
25 changes: 19 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,26 @@ 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',
},
};
};

Expand All @@ -104,7 +114,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 +127,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

0 comments on commit 089e0e8

Please sign in to comment.