[#5593] Disallow decimal wei value for gas price

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2018-09-05 19:47:06 +03:00
parent 36c1a23e04
commit ca149062ad
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
2 changed files with 7 additions and 1 deletions

View File

@ -16,7 +16,8 @@
(defmethod invalid-send-parameter? :gas-price [_ value] (defmethod invalid-send-parameter? :gas-price [_ value]
(cond (cond
(not value) :invalid-number (not value) :invalid-number
(< (money/->wei :gwei value) min-gas-price-wei) :not-enough-wei)) (< (money/->wei :gwei value) min-gas-price-wei) :not-enough-wei
(-> (money/->wei :gwei value) .decimalPlaces pos?) :invalid-number))
(defmethod invalid-send-parameter? :default [_ value] (defmethod invalid-send-parameter? :default [_ value]
(when (or (not value) (when (or (not value)

View File

@ -36,6 +36,11 @@
(is (= "invalid" (get-in actual [:gas :value])))) (is (= "invalid" (get-in actual [:gas :value]))))
(testing "it sets max-fee to 0" (testing "it sets max-fee to 0"
(is (= "0" (:max-fee actual)))))) (is (= "0" (:max-fee actual))))))
(testing "gas price in wei should be round"
(let [actual (-> {}
(model/build-edit :gas "21000")
(model/build-edit :gas-price "0.0000000023"))]
(is (get-in actual [:gas-price :invalid?]))))
(testing "an valid edit" (testing "an valid edit"
(let [actual (-> {} (let [actual (-> {}
(model/build-edit :gas "21000") (model/build-edit :gas "21000")