-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2637 from myxmaster/add-lndmobile-channel-tests
Tests for channel backup functions (lndmobile/channel.ts)
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
}); |