Fixing estimate gas in case histogram is not available (#4387)
This commit is contained in:
parent
3bdd32f9ec
commit
fb7c6c2867
@ -124,7 +124,12 @@ export default class GasPriceEditor {
|
|||||||
@action loadDefaults () {
|
@action loadDefaults () {
|
||||||
Promise
|
Promise
|
||||||
.all([
|
.all([
|
||||||
this._api.parity.gasPriceHistogram(),
|
// NOTE fetching histogram may fail if there is not enough data.
|
||||||
|
// We fallback to empty histogram.
|
||||||
|
this._api.parity.gasPriceHistogram().catch(() => ({
|
||||||
|
bucket_bounds: [],
|
||||||
|
counts: []
|
||||||
|
})),
|
||||||
this._api.eth.gasPrice()
|
this._api.eth.gasPrice()
|
||||||
])
|
])
|
||||||
.then(([histogram, _price]) => {
|
.then(([histogram, _price]) => {
|
||||||
|
@ -62,6 +62,31 @@ describe('ui/GasPriceEditor/store', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('constructor (defaults) when histogram not available', () => {
|
||||||
|
const api = {
|
||||||
|
eth: {
|
||||||
|
gasPrice: sinon.stub().resolves(GASPRICE)
|
||||||
|
},
|
||||||
|
parity: {
|
||||||
|
gasPriceHistogram: sinon.stub().rejects('Data not available')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store = new Store(api, { gasLimit: GASLIMIT });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('retrieves the histogram and gasPrice', done => {
|
||||||
|
expect(api.eth.gasPrice).to.have.been.called;
|
||||||
|
expect(api.parity.gasPriceHistogram).to.have.been.called;
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
expect(store.histogram).not.to.be.null;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('setters', () => {
|
describe('setters', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = new Store(null, { gasLimit: GASLIMIT });
|
store = new Store(null, { gasLimit: GASLIMIT });
|
||||||
|
Loading…
Reference in New Issue
Block a user