-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ref-imp): added bitcoin lock monitor events
- Loading branch information
1 parent
51b8cf8
commit 009202d
Showing
7 changed files
with
99 additions
and
35 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
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
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
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,18 @@ | ||
import BitcoinClient from './BitcoinClient'; | ||
|
||
/** | ||
* Monitor for the running Bitcoin service. | ||
*/ | ||
export default class Monitor { | ||
|
||
public constructor (private bitcoinClient: BitcoinClient) { } | ||
|
||
/** | ||
* Gets the size of the operation queue. | ||
*/ | ||
public async getWalletBalance (): Promise<any> { | ||
const walletBalanceInSatoshis = await this.bitcoinClient.getBalanceInSatoshis(); | ||
const walletBalanceInBtc = walletBalanceInSatoshis / 100000000; | ||
return { walletBalanceInBtc }; | ||
} | ||
} |
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
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
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,19 @@ | ||
import Monitor from '../../lib/bitcoin/Monitor'; | ||
|
||
describe('BitcoinFileReader', () => { | ||
let monitor: Monitor; | ||
beforeAll(() => { | ||
const mockBitcoinClient = { getBalanceInSatoshis: () => {} }; | ||
monitor = new Monitor(mockBitcoinClient as any); | ||
}); | ||
|
||
describe('getWalletBalance', async () => { | ||
it('should get wallet balance', async () => { | ||
const mockBalance = 123; | ||
spyOn(monitor['bitcoinClient'], 'getBalanceInSatoshis').and.returnValue(Promise.resolve(mockBalance)); | ||
|
||
const balance = await monitor.getWalletBalance(); | ||
expect(balance).toEqual({ walletBalanceInBtc: 0.00000123 }); | ||
}); | ||
}); | ||
}); |