Skip to content

Commit 9ead0c0

Browse files
Merge pull request #5039 from BitGo/BTC-1565
feat(sdk-core): fix deriveLightningServiceSharedSecret test
2 parents df6a0fc + 696c91a commit 9ead0c0

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

modules/sdk-core/test/unit/bitgo/lightning/lightningUtils.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import assert from 'assert';
2-
import * as sinon from 'sinon';
32
import { importMacaroon } from 'macaroon';
4-
import * as statics from '@bitgo/statics';
53
import * as utxolib from '@bitgo/utxo-lib';
64

75
import { accounts, signerRootKey } from './createWatchOnlyFixture';
@@ -17,7 +15,6 @@ import {
1715
deriveLightningServiceSharedSecret,
1816
} from './../../../../src/bitgo/lightning/lightningUtils';
1917

20-
import * as lightningUtils from '../../../../src/bitgo/lightning/lightningUtils';
2118
import { getSharedSecret } from '../../../../src';
2219

2320
describe('lightning utils', function () {
@@ -91,25 +88,15 @@ describe('lightning utils', function () {
9188
it(`deriveLightningServiceSharedSecret`, function () {
9289
const userAuthXprv =
9390
'xprv9s21ZrQH143K4NPkV8riiTnFf72MRyQDVHMmmpekGF1w5QkS2MfTei9KXYvrZVMop4zQ4arnzSF7TRp3Cy73AWaDdADiYMCi5qpYW1bUa5m';
94-
const lightningServicePubKey = '03b6fe266b3f8ae110b877d942765e9cea9e82faf03cdbb6d0effe980b6371b9c2';
95-
const lightningServicePrvKey = '8b95613f4341e347743bd2625728d87bc6f0a119acb6ae9121afeee2b2a650f7';
96-
97-
const coin = statics.coins.get('tlnbtc');
98-
assert(coin instanceof statics.LightningCoin);
99-
100-
const getStaticsLightningNetworkStub = sinon.stub(lightningUtils, 'getStaticsLightningNetwork').returns({
101-
...coin.network,
102-
lightningServicePubKey,
103-
});
104-
105-
const secret = deriveLightningServiceSharedSecret('tlnbtc', userAuthXprv);
106-
getStaticsLightningNetworkStub.restore();
91+
const lightningServicePubKey = getStaticsLightningNetwork('tlnbtc').lightningServicePubKey;
10792

10893
const expectedSecret = getSharedSecret(
109-
Buffer.from(lightningServicePrvKey, 'hex'),
110-
utxolib.bip32.fromBase58(userAuthXprv).neutered()
94+
utxolib.bip32.fromBase58(userAuthXprv),
95+
Buffer.from(lightningServicePubKey, 'hex')
11196
);
11297

98+
const secret = deriveLightningServiceSharedSecret('tlnbtc', userAuthXprv);
99+
113100
assert.deepStrictEqual(secret, expectedSecret);
114101
});
115102
});

0 commit comments

Comments
 (0)