Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {setupInitialState} from './actions' | ||
import {ADALITE_CONFIG} from '../../../frontend/config' | ||
import mockNetwork from '../common/mock' | ||
import {CRYPTO_PROVIDER_TYPES} from '../../../frontend/wallet/constants' | ||
import mnemonicToWalletSecretDef from '../../../frontend/wallet/helpers/mnemonicToWalletSecretDef' | ||
import assert from 'assert' | ||
|
||
let state, action | ||
|
||
beforeEach(() => { | ||
;[state, action] = setupInitialState() | ||
}) | ||
|
||
it('Calculate fee - byron', async () => { | ||
ADALITE_CONFIG.ADALITE_CARDANO_VERSION = 'byron' | ||
const mockNet = mockNetwork(ADALITE_CONFIG) | ||
mockNet.mockBulkAddressSummaryEndpoint() | ||
mockNet.mockGetAccountInfo() | ||
mockNet.mockGetStakePools() | ||
mockNet.mockGetConversionRates() | ||
mockNet.mockUtxoEndpoint() | ||
await action.loadWallet(state, { | ||
cryptoProviderType: CRYPTO_PROVIDER_TYPES.WALLET_SECRET, | ||
walletSecretDef: await mnemonicToWalletSecretDef( | ||
'blame matrix water coil diet seat nerve street movie turkey jump bundle' | ||
), | ||
}) | ||
|
||
state.sendAddress.fieldValue = | ||
'DdzFFzCqrhsvrNGcR93DW8cmrPVVbP6vFxcL1i92WzvqcHrp1K1of4DQ8t8cr3oQgsMbbY1eXKWhrcpfnTohNqrr6zPdLeE3AYBtxxZZ' | ||
state.sendAmount.fieldValue = 10 | ||
state.sendAmount.coins = 10000000 | ||
state.donationAmount.fieldValue = 5 | ||
state.donationAmount.coins = 5000000 | ||
|
||
await action.calculateFee() | ||
assert.equal(state.transactionFee, 179288) | ||
}) | ||
|
||
it('Calculate fee - shelley', async () => { | ||
ADALITE_CONFIG.ADALITE_CARDANO_VERSION = 'shelley' | ||
const mockNet = mockNetwork(ADALITE_CONFIG) | ||
mockNet.mockBulkAddressSummaryEndpoint() | ||
mockNet.mockGetAccountInfo() | ||
mockNet.mockGetStakePools() | ||
mockNet.mockGetConversionRates() | ||
mockNet.mockUtxoEndpoint() | ||
await action.loadWallet(state, { | ||
cryptoProviderType: CRYPTO_PROVIDER_TYPES.WALLET_SECRET, | ||
walletSecretDef: await mnemonicToWalletSecretDef( | ||
'blame matrix water coil diet seat nerve street movie turkey jump bundle' | ||
), | ||
}) | ||
|
||
state.sendAddress.fieldValue = | ||
'addr1qjag9rgwe04haycr283datdrjv3mlttalc2waz34xcct0g4uvf6gdg3dpwrsne4uqng3y47ugp2pp5dvuq0jqlperwj83r4pwxvwuxsgds90s0' | ||
state.sendAmount.fieldValue = 10 | ||
state.sendAmount.coins = 10000000 | ||
state.donationAmount.fieldValue = 5 | ||
state.donationAmount.coins = 5000000 | ||
|
||
await action.calculateFee() | ||
assert.equal(state.transactionFee, 900000) | ||
}) |
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