2018-05-05 17:11:53 +02:00
|
|
|
import assert from 'assert'
|
2018-05-14 14:13:55 +02:00
|
|
|
import sinon from 'sinon'
|
2020-01-09 04:34:58 +01:00
|
|
|
import {
|
2018-05-05 17:11:53 +02:00
|
|
|
accountsWithSendEtherInfoSelector,
|
2020-03-06 22:34:56 +01:00
|
|
|
getCurrentAccountWithSendEtherInfo,
|
|
|
|
} from '../../../selectors/selectors'
|
|
|
|
import {
|
2018-05-22 17:16:53 +02:00
|
|
|
getBlockGasLimit,
|
2018-05-05 17:11:53 +02:00
|
|
|
getAmountConversionRate,
|
|
|
|
getConversionRate,
|
|
|
|
getCurrentCurrency,
|
|
|
|
getCurrentNetwork,
|
2018-10-26 10:26:43 +02:00
|
|
|
getNativeCurrency,
|
2018-05-05 17:11:53 +02:00
|
|
|
getForceGasMin,
|
|
|
|
getGasLimit,
|
|
|
|
getGasPrice,
|
|
|
|
getGasTotal,
|
|
|
|
getPrimaryCurrency,
|
2018-05-22 10:10:06 +02:00
|
|
|
getRecentBlocks,
|
2018-05-05 17:11:53 +02:00
|
|
|
getSelectedIdentity,
|
|
|
|
getSelectedToken,
|
2018-05-14 14:13:55 +02:00
|
|
|
getSelectedTokenContract,
|
2018-05-05 17:11:53 +02:00
|
|
|
getSelectedTokenExchangeRate,
|
|
|
|
getSelectedTokenToFiatRate,
|
|
|
|
getSendAmount,
|
|
|
|
getSendEditingTransactionId,
|
|
|
|
getSendErrors,
|
|
|
|
getSendFrom,
|
|
|
|
getSendFromBalance,
|
|
|
|
getSendFromObject,
|
2018-08-16 09:43:13 +02:00
|
|
|
getSendHexDataFeatureFlagState,
|
2018-05-05 17:11:53 +02:00
|
|
|
getSendMaxModeState,
|
|
|
|
getSendTo,
|
|
|
|
getSendToAccounts,
|
|
|
|
getTokenBalance,
|
|
|
|
getTokenExchangeRate,
|
|
|
|
getUnapprovedTxs,
|
2020-01-09 04:34:58 +01:00
|
|
|
} from '../send.selectors.js'
|
2018-05-05 17:11:53 +02:00
|
|
|
import mockState from './send-selectors-test-data'
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('send selectors', function () {
|
2018-05-14 14:57:36 +02:00
|
|
|
const tempGlobalEth = Object.assign({}, global.eth)
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2018-05-14 14:13:55 +02:00
|
|
|
global.eth = {
|
|
|
|
contract: sinon.stub().returns({
|
2020-02-15 21:34:12 +01:00
|
|
|
at: (address) => 'mockAt:' + address,
|
2018-05-14 14:57:36 +02:00
|
|
|
}),
|
2018-05-14 14:13:55 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
afterEach(function () {
|
2018-05-14 14:13:55 +02:00
|
|
|
global.eth = tempGlobalEth
|
|
|
|
})
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('accountsWithSendEtherInfoSelector()', function () {
|
|
|
|
it('should return an array of account objects with name info from identities', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
accountsWithSendEtherInfoSelector(mockState),
|
|
|
|
[
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x47c9d71831c76efe',
|
|
|
|
nonce: '0x1b',
|
|
|
|
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
|
|
|
|
name: 'Send Account 1',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x37452b1315889f80',
|
|
|
|
nonce: '0xa',
|
|
|
|
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
|
|
name: 'Send Account 2',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x30c9d71831c76efe',
|
|
|
|
nonce: '0x1c',
|
|
|
|
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
|
|
|
|
name: 'Send Account 3',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x0',
|
|
|
|
nonce: '0x0',
|
|
|
|
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
|
|
|
|
name: 'Send Account 4',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// describe('autoAddToBetaUI()', () => {
|
|
|
|
// it('should', () => {
|
|
|
|
// assert.deepEqual(
|
|
|
|
// autoAddToBetaUI(mockState),
|
|
|
|
|
|
|
|
// )
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getAmountConversionRate()', function () {
|
|
|
|
it('should return the token conversion rate if a token is selected', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getAmountConversionRate(mockState),
|
|
|
|
2401.76400654
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return the eth conversion rate if no token is selected', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
const editedMockState = {
|
|
|
|
metamask: Object.assign({}, mockState.metamask, { selectedTokenAddress: null }),
|
|
|
|
}
|
|
|
|
assert.equal(
|
|
|
|
getAmountConversionRate(editedMockState),
|
|
|
|
1200.88200327
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getBlockGasLimit', function () {
|
|
|
|
it('should return the current block gas limit', function () {
|
2018-05-22 17:16:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getBlockGasLimit(mockState),
|
|
|
|
'0x4c1878'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getConversionRate()', function () {
|
|
|
|
it('should return the eth conversion rate', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getConversionRate(mockState),
|
|
|
|
1200.88200327
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getCurrentAccountWithSendEtherInfo()', function () {
|
|
|
|
it('should return the currently selected account with identity info', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getCurrentAccountWithSendEtherInfo(mockState),
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x0',
|
|
|
|
nonce: '0x0',
|
|
|
|
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
|
|
|
|
name: 'Send Account 4',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getCurrentCurrency()', function () {
|
|
|
|
it('should return the currently selected currency', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getCurrentCurrency(mockState),
|
|
|
|
'USD'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getNativeCurrency()', function () {
|
|
|
|
it('should return the ticker symbol of the selected network', function () {
|
2018-10-26 10:26:43 +02:00
|
|
|
assert.equal(
|
|
|
|
getNativeCurrency(mockState),
|
|
|
|
'ETH'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getCurrentNetwork()', function () {
|
|
|
|
it('should return the id of the currently selected network', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getCurrentNetwork(mockState),
|
|
|
|
'3'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getForceGasMin()', function () {
|
|
|
|
it('should get the send.forceGasMin property', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getForceGasMin(mockState),
|
|
|
|
true
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getGasLimit()', function () {
|
|
|
|
it('should return the send.gasLimit', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getGasLimit(mockState),
|
|
|
|
'0xFFFF'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getGasPrice()', function () {
|
|
|
|
it('should return the send.gasPrice', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getGasPrice(mockState),
|
|
|
|
'0xaa'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getGasTotal()', function () {
|
|
|
|
it('should return the send.gasTotal', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getGasTotal(mockState),
|
2018-09-13 10:47:05 +02:00
|
|
|
'a9ff56'
|
2018-05-05 17:11:53 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getPrimaryCurrency()', function () {
|
|
|
|
it('should return the symbol of the selected token', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getPrimaryCurrency(mockState),
|
|
|
|
'DEF'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getRecentBlocks()', function () {
|
|
|
|
it('should return the recent blocks', function () {
|
2018-05-22 10:10:06 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getRecentBlocks(mockState),
|
|
|
|
['mockBlock1', 'mockBlock2', 'mockBlock3']
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSelectedIdentity()', function () {
|
|
|
|
it('should return the identity object of the currently selected address', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSelectedIdentity(mockState),
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
|
|
|
|
name: 'Send Account 4',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSelectedToken()', function () {
|
|
|
|
it('should return the currently selected token if selected', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSelectedToken(mockState),
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
address: '0x8d6b81208414189a58339873ab429b6c47ab92d3',
|
|
|
|
decimals: 4,
|
|
|
|
symbol: 'DEF',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return the send token if none is currently selected, but a send token exists', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
const mockSendToken = {
|
2018-05-14 14:13:55 +02:00
|
|
|
address: '0x123456708414189a58339873ab429b6c47ab92d3',
|
|
|
|
decimals: 4,
|
|
|
|
symbol: 'JKL',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
const editedMockState = {
|
|
|
|
metamask: Object.assign({}, mockState.metamask, {
|
|
|
|
selectedTokenAddress: null,
|
|
|
|
send: {
|
|
|
|
token: mockSendToken,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
assert.deepEqual(
|
|
|
|
getSelectedToken(editedMockState),
|
|
|
|
Object.assign({}, mockSendToken)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSelectedTokenContract()', function () {
|
|
|
|
it('should return the contract at the selected token address', function () {
|
2018-05-14 14:13:55 +02:00
|
|
|
assert.equal(
|
|
|
|
getSelectedTokenContract(mockState),
|
|
|
|
'mockAt:0x8d6b81208414189a58339873ab429b6c47ab92d3'
|
|
|
|
)
|
|
|
|
})
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return null if no token is selected', function () {
|
2018-05-14 14:13:55 +02:00
|
|
|
const modifiedMetamaskState = Object.assign({}, mockState.metamask, { selectedTokenAddress: false })
|
|
|
|
assert.equal(
|
|
|
|
getSelectedTokenContract(Object.assign({}, mockState, { metamask: modifiedMetamaskState })),
|
|
|
|
null
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSelectedTokenExchangeRate()', function () {
|
|
|
|
it('should return the exchange rate for the selected token', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSelectedTokenExchangeRate(mockState),
|
|
|
|
2.0
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSelectedTokenToFiatRate()', function () {
|
|
|
|
it('should return rate for converting the selected token to fiat', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSelectedTokenToFiatRate(mockState),
|
|
|
|
2401.76400654
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendAmount()', function () {
|
|
|
|
it('should return the send.amount', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSendAmount(mockState),
|
|
|
|
'0x080'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendEditingTransactionId()', function () {
|
|
|
|
it('should return the send.editingTransactionId', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSendEditingTransactionId(mockState),
|
|
|
|
97531
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendErrors()', function () {
|
|
|
|
it('should return the send.errors', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSendErrors(mockState),
|
2018-05-14 14:13:55 +02:00
|
|
|
{ someError: null }
|
2018-05-05 17:11:53 +02:00
|
|
|
)
|
2018-08-16 09:43:13 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendHexDataFeatureFlagState()', function () {
|
|
|
|
it('should return the sendHexData feature flag state', function () {
|
2018-08-16 09:43:13 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSendHexDataFeatureFlagState(mockState),
|
|
|
|
true
|
|
|
|
)
|
2018-05-05 17:11:53 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendFrom()', function () {
|
|
|
|
it('should return the send.from', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSendFrom(mockState),
|
2020-03-11 19:40:35 +01:00
|
|
|
'0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
2018-05-05 17:11:53 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendFromBalance()', function () {
|
|
|
|
it('should get the send.from balance if it exists', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSendFromBalance(mockState),
|
2020-03-11 19:40:35 +01:00
|
|
|
'0x37452b1315889f80'
|
2018-05-05 17:11:53 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should get the selected account balance if the send.from does not exist', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
const editedMockState = {
|
|
|
|
metamask: Object.assign({}, mockState.metamask, {
|
|
|
|
send: {
|
|
|
|
from: null,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
assert.equal(
|
|
|
|
getSendFromBalance(editedMockState),
|
|
|
|
'0x0'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendFromObject()', function () {
|
|
|
|
it('should return send.from if it exists', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSendFromObject(mockState),
|
|
|
|
{
|
2020-03-11 19:40:35 +01:00
|
|
|
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
|
|
balance: '0x37452b1315889f80',
|
|
|
|
code: '0x',
|
|
|
|
nonce: '0xa',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-03-11 19:40:35 +01:00
|
|
|
it('should return the current account if send.from does not exist', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
const editedMockState = {
|
|
|
|
metamask: Object.assign({}, mockState.metamask, {
|
|
|
|
send: {
|
|
|
|
from: null,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
assert.deepEqual(
|
|
|
|
getSendFromObject(editedMockState),
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x0',
|
|
|
|
nonce: '0x0',
|
|
|
|
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
|
2018-05-05 17:11:53 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendMaxModeState()', function () {
|
|
|
|
it('should return send.maxModeOn', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSendMaxModeState(mockState),
|
|
|
|
false
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendTo()', function () {
|
|
|
|
it('should return send.to', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getSendTo(mockState),
|
|
|
|
'0x987fedabc'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getSendToAccounts()', function () {
|
|
|
|
it('should return an array including all the users accounts and the address book', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getSendToAccounts(mockState),
|
|
|
|
[
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x47c9d71831c76efe',
|
|
|
|
nonce: '0x1b',
|
|
|
|
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
|
|
|
|
name: 'Send Account 1',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x37452b1315889f80',
|
|
|
|
nonce: '0xa',
|
|
|
|
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
|
|
name: 'Send Account 2',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x30c9d71831c76efe',
|
|
|
|
nonce: '0x1c',
|
|
|
|
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
|
|
|
|
name: 'Send Account 3',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
code: '0x',
|
|
|
|
balance: '0x0',
|
|
|
|
nonce: '0x0',
|
|
|
|
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
|
|
|
|
name: 'Send Account 4',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
address: '0x06195827297c7a80a443b6894d3bdb8824b43896',
|
|
|
|
name: 'Address Book Account 1',
|
2019-07-31 21:56:44 +02:00
|
|
|
chainId: '3',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getTokenBalance()', function () {
|
|
|
|
it('should', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getTokenBalance(mockState),
|
|
|
|
3434
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getTokenExchangeRate()', function () {
|
|
|
|
it('should return the passed tokens exchange rates', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.equal(
|
|
|
|
getTokenExchangeRate(mockState, 'GHI'),
|
|
|
|
31.01
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getUnapprovedTxs()', function () {
|
|
|
|
it('should return the unapproved txs', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
assert.deepEqual(
|
|
|
|
getUnapprovedTxs(mockState),
|
|
|
|
{
|
2018-05-14 14:13:55 +02:00
|
|
|
4768706228115573: {
|
|
|
|
id: 4768706228115573,
|
|
|
|
time: 1487363153561,
|
|
|
|
status: 'unapproved',
|
|
|
|
gasMultiplier: 1,
|
|
|
|
metamaskNetworkId: '3',
|
|
|
|
txParams: {
|
|
|
|
from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
|
|
to: '0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761',
|
|
|
|
value: '0xde0b6b3a7640000',
|
|
|
|
metamaskId: 4768706228115573,
|
|
|
|
metamaskNetworkId: '3',
|
|
|
|
gas: '0x5209',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
2018-05-14 14:13:55 +02:00
|
|
|
gasLimitSpecified: false,
|
|
|
|
estimatedGas: '0x5209',
|
|
|
|
txFee: '17e0186e60800',
|
|
|
|
txValue: 'de0b6b3a7640000',
|
|
|
|
maxCost: 'de234b52e4a0800',
|
|
|
|
gasPrice: '4a817c800',
|
2018-05-05 17:11:53 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|