mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix test, create new value for precision/scale
This commit is contained in:
parent
97d19f0f79
commit
31d17c9e25
@ -10,7 +10,6 @@ var BnInput = require('../../../ui/app/components/bn-as-decimal-input')
|
|||||||
|
|
||||||
describe('BnInput', function () {
|
describe('BnInput', function () {
|
||||||
it('can tolerate a gas decimal number at a high precision', function (done) {
|
it('can tolerate a gas decimal number at a high precision', function (done) {
|
||||||
|
|
||||||
const renderer = ReactTestUtils.createRenderer()
|
const renderer = ReactTestUtils.createRenderer()
|
||||||
|
|
||||||
let valueStr = '20'
|
let valueStr = '20'
|
||||||
@ -27,10 +26,12 @@ describe('BnInput', function () {
|
|||||||
}
|
}
|
||||||
const target = new BN(targetStr, 10)
|
const target = new BN(targetStr, 10)
|
||||||
|
|
||||||
const precision = 1e18 // ether precision
|
const precision = 13 // ether precision
|
||||||
|
const scale = 13
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
value,
|
value,
|
||||||
|
scale,
|
||||||
precision,
|
precision,
|
||||||
onChange: (newBn) => {
|
onChange: (newBn) => {
|
||||||
assert.equal(newBn.toString(), target.toString(), 'should tolerate increase')
|
assert.equal(newBn.toString(), target.toString(), 'should tolerate increase')
|
||||||
|
@ -26,12 +26,12 @@ BnAsDecimalInput.prototype.render = function () {
|
|||||||
const props = this.props
|
const props = this.props
|
||||||
const state = this.state
|
const state = this.state
|
||||||
|
|
||||||
const { value, precision, onChange, min, max } = props
|
const { value, scale, precision, onChange, min, max } = props
|
||||||
|
|
||||||
const suffix = props.suffix
|
const suffix = props.suffix
|
||||||
const style = props.style
|
const style = props.style
|
||||||
const valueString = value.toString(10)
|
const valueString = value.toString(10)
|
||||||
const newValue = downsize(valueString, precision, precision)
|
const newValue = downsize(valueString, scale, precision)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h('.flex-column', [
|
h('.flex-column', [
|
||||||
@ -65,7 +65,7 @@ BnAsDecimalInput.prototype.render = function () {
|
|||||||
const value = (event.target.value === '') ? '' : event.target.value
|
const value = (event.target.value === '') ? '' : event.target.value
|
||||||
|
|
||||||
|
|
||||||
const scaledNumber = upsize(value, precision, precision)
|
const scaledNumber = upsize(value, scale, precision)
|
||||||
const precisionBN = new BN(scaledNumber, 10)
|
const precisionBN = new BN(scaledNumber, 10)
|
||||||
onChange(precisionBN)
|
onChange(precisionBN)
|
||||||
},
|
},
|
||||||
|
@ -156,6 +156,7 @@ PendingTx.prototype.render = function () {
|
|||||||
name: 'Gas Limit',
|
name: 'Gas Limit',
|
||||||
value: gasBn,
|
value: gasBn,
|
||||||
precision: 0,
|
precision: 0,
|
||||||
|
scale: 0,
|
||||||
// The hard lower limit for gas.
|
// The hard lower limit for gas.
|
||||||
min: MIN_GAS_LIMIT_BN.toString(10),
|
min: MIN_GAS_LIMIT_BN.toString(10),
|
||||||
suffix: 'UNITS',
|
suffix: 'UNITS',
|
||||||
@ -179,6 +180,7 @@ PendingTx.prototype.render = function () {
|
|||||||
name: 'Gas Price',
|
name: 'Gas Price',
|
||||||
value: gasPriceBn,
|
value: gasPriceBn,
|
||||||
precision: 9,
|
precision: 9,
|
||||||
|
scale: 9,
|
||||||
suffix: 'GWEI',
|
suffix: 'GWEI',
|
||||||
min: MIN_GAS_PRICE_GWEI_BN.toString(10),
|
min: MIN_GAS_PRICE_GWEI_BN.toString(10),
|
||||||
style: {
|
style: {
|
||||||
|
Loading…
Reference in New Issue
Block a user