Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): add Wallet.timeSettings$
add integration test as example of computing tx date
- Loading branch information
1 parent
898b0d5
commit 14467e7
Showing
9 changed files
with
89 additions
and
10 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
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,42 @@ | ||
import { Cardano, createSlotTimeCalc, testnetTimeSettings } from '@cardano-sdk/core'; | ||
import { KeyManagement, SingleAddressWallet, SingleAddressWalletProps } from '../../src'; | ||
import { createStubStakePoolSearchProvider, createStubTimeSettingsProvider } from '@cardano-sdk/util-dev'; | ||
import { firstValueFrom } from 'rxjs'; | ||
import { mockAssetProvider, mockWalletProvider } from '../mocks'; | ||
|
||
const walletProps: SingleAddressWalletProps = { name: 'some-wallet' }; | ||
const networkId = Cardano.NetworkId.mainnet; | ||
const mnemonicWords = KeyManagement.util.generateMnemonicWords(); | ||
const getPassword = async () => Buffer.from('your_password'); | ||
|
||
describe('integration/transactionTime', () => { | ||
let keyAgent: KeyManagement.KeyAgent; | ||
let wallet: SingleAddressWallet; | ||
|
||
beforeAll(async () => { | ||
keyAgent = await KeyManagement.InMemoryKeyAgent.fromBip39MnemonicWords({ | ||
getPassword, | ||
mnemonicWords, | ||
networkId | ||
}); | ||
const walletProvider = mockWalletProvider(); | ||
const stakePoolSearchProvider = createStubStakePoolSearchProvider(); | ||
const timeSettingsProvider = createStubTimeSettingsProvider(testnetTimeSettings); | ||
const assetProvider = mockAssetProvider(); | ||
wallet = new SingleAddressWallet(walletProps, { | ||
assetProvider, | ||
keyAgent, | ||
stakePoolSearchProvider, | ||
timeSettingsProvider, | ||
walletProvider | ||
}); | ||
}); | ||
|
||
it('provides utils necessary for computing transaction time', async () => { | ||
const transactions = await firstValueFrom(wallet.transactions.history.incoming$); | ||
const timeSettings = await firstValueFrom(wallet.timeSettings$); | ||
const slotTimeCalc = createSlotTimeCalc(timeSettings); | ||
const transactionTime = slotTimeCalc(transactions[0].blockHeader.slot); | ||
expect(typeof transactionTime.getTime()).toBe('number'); | ||
}); | ||
}); |
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