diff --git a/ftservice/gasprice/gasprice.go b/ftservice/gasprice/gasprice.go index ff8407b7..3d42c83c 100644 --- a/ftservice/gasprice/gasprice.go +++ b/ftservice/gasprice/gasprice.go @@ -120,6 +120,10 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) { price = new(big.Int).Div(prices, weights) } + if price.Cmp(gpo.defaultPrice) < 0 { + price = gpo.defaultPrice + } + gpo.cacheLock.Lock() gpo.lastHead = headHash gpo.lastPrice = price diff --git a/ftservice/gasprice/gasprice_test.go b/ftservice/gasprice/gasprice_test.go index 331ba044..f549ed64 100644 --- a/ftservice/gasprice/gasprice_test.go +++ b/ftservice/gasprice/gasprice_test.go @@ -74,4 +74,19 @@ func TestSuggestPrice(t *testing.T) { t.Fatal(err) } assert.Equal(t, price, gasPrice) + + // test the Minimum configuration + + cfg1 := Config{ + Blocks: 5, + Default: big.NewInt(10), + } + gpo = NewOracle(newTestBlockChain(price), cfg1) + + gasPrice, err = gpo.SuggestPrice(context.Background()) + if err != nil { + t.Fatal(err) + } + assert.Equal(t, big.NewInt(10), gasPrice) + }