allow passing fromAccountIndex in sendEtherTo helper, use account 9 for testing sending ETH
This commit is contained in:
parent
4955d63bdb
commit
9e6555a6f5
|
@ -18,7 +18,7 @@ import { fillAndSubmitSendFundsForm } from './utils/transactions'
|
||||||
|
|
||||||
afterEach(cleanup)
|
afterEach(cleanup)
|
||||||
|
|
||||||
describe('DOM > Feature > Sending Funds', () => {
|
describe('DOM > Feature > Sending ETH', () => {
|
||||||
let store
|
let store
|
||||||
let safeAddress: string
|
let safeAddress: string
|
||||||
let accounts
|
let accounts
|
||||||
|
@ -32,8 +32,11 @@ describe('DOM > Feature > Sending Funds', () => {
|
||||||
it('Sends ETH with threshold = 1', async () => {
|
it('Sends ETH with threshold = 1', async () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const ethAmount = '5'
|
const ethAmount = '5'
|
||||||
await sendEtherTo(safeAddress, ethAmount)
|
|
||||||
const balanceAfterSendingEthToSafe = await getBalanceInEtherOf(accounts[0])
|
// the tests are run in parallel, lets use account 9 because it's not used anywhere else
|
||||||
|
// (in other tests we trigger transactions and pay gas for it, so we can't really make reliable
|
||||||
|
// assumptions on account's ETH balance)
|
||||||
|
await sendEtherTo(safeAddress, ethAmount, 9)
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
const SafeDom = renderSafeView(store, safeAddress)
|
const SafeDom = renderSafeView(store, safeAddress)
|
||||||
|
@ -45,15 +48,16 @@ describe('DOM > Feature > Sending Funds', () => {
|
||||||
const sendButton = SafeDom.getByTestId('balance-send-btn')
|
const sendButton = SafeDom.getByTestId('balance-send-btn')
|
||||||
fireEvent.click(sendButton)
|
fireEvent.click(sendButton)
|
||||||
|
|
||||||
await fillAndSubmitSendFundsForm(SafeDom, sendButton, ethAmount, accounts[0])
|
const receiverBalanceBeforeTx = await getBalanceInEtherOf(accounts[9])
|
||||||
|
await fillAndSubmitSendFundsForm(SafeDom, sendButton, ethAmount, accounts[9])
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
const safeFunds = await getBalanceInEtherOf(safeAddress)
|
const safeFunds = await getBalanceInEtherOf(safeAddress)
|
||||||
expect(Number(safeFunds)).toBe(0)
|
expect(Number(safeFunds)).toBe(0)
|
||||||
|
const receiverBalanceAfterTx = await getBalanceInEtherOf(accounts[9])
|
||||||
|
|
||||||
const receiverFunds = await getBalanceInEtherOf(accounts[0])
|
|
||||||
const ESTIMATED_GASCOSTS = 0.3
|
const ESTIMATED_GASCOSTS = 0.3
|
||||||
expect(Number(parseInt(receiverFunds, 10) - parseInt(balanceAfterSendingEthToSafe, 10))).toBeGreaterThan(
|
expect(Number(parseInt(receiverBalanceAfterTx, 10) - parseInt(receiverBalanceBeforeTx, 10))).toBeGreaterThan(
|
||||||
parseInt(ethAmount, 10) - ESTIMATED_GASCOSTS,
|
parseInt(ethAmount, 10) - ESTIMATED_GASCOSTS,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe('DOM > Feature > Sending Funds', () => {
|
||||||
|
|
||||||
// Travel confirm modal
|
// Travel confirm modal
|
||||||
fireEvent.click(SafeDom.getByTestId(APPROVE_TX_MODAL_SUBMIT_BTN_TESTID))
|
fireEvent.click(SafeDom.getByTestId(APPROVE_TX_MODAL_SUBMIT_BTN_TESTID))
|
||||||
await sleep(500)
|
await sleep(1500)
|
||||||
|
|
||||||
// EXECUTE TX
|
// EXECUTE TX
|
||||||
fireEvent.click(SafeDom.getByTestId(EXECUTE_TX_BTN_TESTID))
|
fireEvent.click(SafeDom.getByTestId(EXECUTE_TX_BTN_TESTID))
|
||||||
|
|
|
@ -6,11 +6,11 @@ import { toNative } from '~/logic/wallets/tokens'
|
||||||
import TokenOMG from '../../../build/contracts/TokenOMG'
|
import TokenOMG from '../../../build/contracts/TokenOMG'
|
||||||
import TokenRDN from '../../../build/contracts/TokenRDN'
|
import TokenRDN from '../../../build/contracts/TokenRDN'
|
||||||
|
|
||||||
export const sendEtherTo = async (address: string, eth: string) => {
|
export const sendEtherTo = async (address: string, eth: string, fromAccountIndex: number = 0) => {
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
const { toBN, toWei } = web3.utils
|
const { toBN, toWei } = web3.utils
|
||||||
const txData = { from: accounts[0], to: address, value: toBN(toWei(eth, 'ether')) }
|
const txData = { from: accounts[fromAccountIndex], to: address, value: toBN(toWei(eth, 'ether')) }
|
||||||
return web3.eth.sendTransaction(txData)
|
return web3.eth.sendTransaction(txData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue