WA-521 Transaction History Service redux integration test
This commit is contained in:
parent
e3dff12766
commit
db35bf80c3
|
@ -46,7 +46,7 @@ const buildTransactionFrom = (safeAddress: string, tx: TxServiceModel, safeSubje
|
|||
return makeTransaction({
|
||||
name,
|
||||
nonce: tx.nonce,
|
||||
value: tx.value,
|
||||
value: Number(tx.value),
|
||||
confirmations,
|
||||
destination: tx.to,
|
||||
data: `0x${tx.data || ''}`,
|
||||
|
|
|
@ -11,8 +11,10 @@ import { getSafeFrom } from '~/test/utils/safeHelper'
|
|||
import { promisify } from '~/utils/promisify'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { safeTransactionsSelector } from '~/routes/safe/store/selectors'
|
||||
import fetchSafe from '~/routes/safe/store/actions/fetchSafe'
|
||||
import { testTransactionFrom, testSizeOfTransactions } from './utils/historyServiceHelper'
|
||||
|
||||
|
||||
describe('Transactions Suite', () => {
|
||||
let store: Store
|
||||
let safeAddress: string
|
||||
|
@ -28,24 +30,29 @@ describe('Transactions Suite', () => {
|
|||
})
|
||||
|
||||
it('retrieves tx info from service having subject available', async () => {
|
||||
const safe: Safe = getSafeFrom(store.getState(), safeAddress)
|
||||
let safe: Safe = getSafeFrom(store.getState(), safeAddress)
|
||||
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
|
||||
const firstTxData = gnosisSafe.contract.addOwnerWithThreshold.getData(accounts[1], 2)
|
||||
const executor = accounts[0]
|
||||
const nonce = Date.now()
|
||||
const firstTxHash = await createTransaction(safe, 'Add Owner Second account', safeAddress, 0, nonce, executor, firstTxData)
|
||||
await store.dispatch(fetchSafe(safe))
|
||||
safe = getSafeFrom(store.getState(), safeAddress)
|
||||
|
||||
const secondTxData = gnosisSafe.contract.addOwnerWithThreshold.getData(accounts[2], 2)
|
||||
const secondTxHash = await createTransaction(safe, 'Add Owner Third account', safeAddress, 0, nonce + 100, executor, secondTxData)
|
||||
await store.dispatch(fetchSafe(safe))
|
||||
safe = getSafeFrom(store.getState(), safeAddress)
|
||||
|
||||
// WHEN
|
||||
store.dispatch(fetchTransactions(safeAddress))
|
||||
await store.dispatch(fetchTransactions(safeAddress))
|
||||
let transactions = safeTransactionsSelector(store.getState(), { safeAddress })
|
||||
testSizeOfTransactions(transactions, 2)
|
||||
|
||||
// THEN
|
||||
const firstTxConfirmations = List([
|
||||
makeConfirmation({
|
||||
owner: makeOwner({ address: executor }),
|
||||
owner: makeOwner({ address: getWeb3().toChecksumAddress(executor), name: 'Adol 1 Eth Account' }),
|
||||
type: 'execution',
|
||||
hash: firstTxHash,
|
||||
}),
|
||||
|
@ -54,7 +61,7 @@ describe('Transactions Suite', () => {
|
|||
|
||||
const secondTxConfirmations = List([
|
||||
makeConfirmation({
|
||||
owner: makeOwner({ address: accounts[0] }),
|
||||
owner: makeOwner({ address: getWeb3().toChecksumAddress(accounts[0]), name: 'Adol 1 Eth Account' }),
|
||||
type: 'confirmation',
|
||||
hash: secondTxHash,
|
||||
}),
|
||||
|
@ -63,11 +70,26 @@ describe('Transactions Suite', () => {
|
|||
|
||||
localStorage.clear()
|
||||
|
||||
store.dispatch(fetchTransactions(safeAddress))
|
||||
await store.dispatch(fetchTransactions(safeAddress))
|
||||
transactions = safeTransactionsSelector(store.getState(), { safeAddress })
|
||||
|
||||
testSizeOfTransactions(transactions, 2)
|
||||
testTransactionFrom(transactions, 0, 'Unknown', nonce, 0, safeAddress, firstTxData, true, firstTxConfirmations)
|
||||
testTransactionFrom(transactions, 1, 'Unknown', nonce + 100, 0, safeAddress, secondTxData, false, secondTxConfirmations)
|
||||
const firstTxConfWithoutStorage = List([
|
||||
makeConfirmation({
|
||||
owner: makeOwner({ address: getWeb3().toChecksumAddress(executor), name: 'UNKNOWN' }),
|
||||
type: 'execution',
|
||||
hash: firstTxHash,
|
||||
}),
|
||||
])
|
||||
testTransactionFrom(transactions, 0, 'Unknown', nonce, 0, safeAddress, firstTxData, true, firstTxConfWithoutStorage)
|
||||
const secondTxConfWithoutStorage = List([
|
||||
makeConfirmation({
|
||||
owner: makeOwner({ address: getWeb3().toChecksumAddress(executor), name: 'UNKNOWN' }),
|
||||
type: 'confirmation',
|
||||
hash: secondTxHash,
|
||||
}),
|
||||
])
|
||||
testTransactionFrom(transactions, 1, 'Unknown', nonce + 100, 0, safeAddress, secondTxData, false, secondTxConfWithoutStorage)
|
||||
})
|
||||
|
||||
it('returns empty list of trnsactions when safe is not configured', async () => {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { List, Map } from 'immutable'
|
||||
import { type Confirmation } from '~/routes/safe/store/model/confirmation'
|
||||
import { type Transaction } from '~/routes/safe/store/model/transaction'
|
||||
import { sameAddress } from '~/logic/wallets/ethAddresses'
|
||||
|
||||
export const testSizeOfSafesWith = (transactions: Map<string, List<Transaction>>, size: number) => {
|
||||
expect(transactions).not.toBe(undefined)
|
||||
|
@ -28,8 +29,8 @@ export const testTransactionFrom = (
|
|||
expect(tx.get('name')).toBe(name)
|
||||
expect(tx.get('nonce')).toBe(nonce)
|
||||
expect(tx.get('value')).toBe(value)
|
||||
expect(tx.get('destination')).toBe(destination)
|
||||
expect(sameAddress(tx.get('destination'), destination)).toBe(true)
|
||||
expect(tx.get('data')).toBe(data)
|
||||
expect(tx.get('isExecuted')).toBe(isExecuted)
|
||||
expect(tx.get('confirmations')).toBe(confirmations)
|
||||
expect(tx.get('confirmations')).toEqual(confirmations)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue