Skip to content

Commit

Permalink
Merge pull request #2637 from myxmaster/add-lndmobile-channel-tests
Browse files Browse the repository at this point in the history
Tests for channel backup functions (lndmobile/channel.ts)
  • Loading branch information
kaloudis authored Dec 16, 2024
2 parents 56cb0b5 + 3961cd3 commit c53f3e6
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lndmobile/channel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
jest.mock('./utils', () => ({
sendCommand: jest.fn()
}));

import { sendCommand } from './utils';
import {
exportAllChannelBackups,
restoreChannelBackups,
verifyChanBackup
} from './channel';
import { lnrpc } from '../proto/lightning';

describe('channel', () => {
const testBackupBase64 = 'dGVzdGJhY2t1cA==';

describe('exportAllChannelBackups', () => {
it('calls sendCommand with correct parameters', async () => {
await exportAllChannelBackups();
expect(sendCommand).toHaveBeenCalledWith({
request: lnrpc.ChanBackupExportRequest,
response: lnrpc.ChanBackupSnapshot,
method: 'ExportAllChannelBackups',
options: {}
});
});
});

describe('restoreChannelBackups', () => {
it('calls sendCommand with correct parameters', async () => {
await restoreChannelBackups(testBackupBase64);
expect(sendCommand).toHaveBeenCalledWith({
request: lnrpc.RestoreChanBackupRequest,
response: lnrpc.RestoreBackupResponse,
method: 'RestoreChannelBackups',
options: {
multi_chan_backup: expect.any(Uint8Array)
}
});
});
});

describe('verifyChanBackup', () => {
it('calls sendCommand with correct parameters', async () => {
await verifyChanBackup(testBackupBase64);
expect(sendCommand).toHaveBeenCalledWith({
request: lnrpc.ChanBackupSnapshot,
response: lnrpc.VerifyChanBackupResponse,
method: 'VerifyChanBackup',
options: {
multi_chan_backup: {
multi_chan_backup: expect.any(Uint8Array)
}
}
});
});
});
});

0 comments on commit c53f3e6

Please sign in to comment.