Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: static fee default if fee statistics empty #1139

Merged
merged 3 commits into from Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions __tests__/unit/components/Input/InputFee.spec.js
Expand Up @@ -304,6 +304,18 @@ describe('InputFee', () => {
expect(wrapper.vm.feeChoices.MAXIMUM).toBeWithin(0.03, 0.03000001)
})
})

describe('when the network returns no statistics', () => {
beforeEach(() => {
mockNetwork.feeStatistics = []
})

it('should use it as maximum', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.MAXIMUM).toBe(0.1)
})
})
})

describe('insufficientFundsError', () => {
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/components/Input/InputFee.vue
Expand Up @@ -169,7 +169,15 @@ export default {
}

const { feeStatistics } = this.feeNetwork
return feeStatistics.find(feeConfig => feeConfig.type === this.transactionType).fees
const transactionStatistics = feeStatistics.find(feeConfig => feeConfig.type === this.transactionType)
if (transactionStatistics) {
return transactionStatistics.fees
}

return {
avgFee: this.maxV1fee * 1e8,
maxFee: this.maxV1fee * 1e8
}
},
feeChoiceMin () {
return this.feeChoices.MINIMUM
Expand Down