Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
Show All 10 Lines | import { | ||||
confirmNonEtokenUtxos, | confirmNonEtokenUtxos, | ||||
isLegacyMigrationRequired, | isLegacyMigrationRequired, | ||||
toLegacyCash, | toLegacyCash, | ||||
toLegacyToken, | toLegacyToken, | ||||
toLegacyCashArray, | toLegacyCashArray, | ||||
parseOpReturn, | parseOpReturn, | ||||
isExcludedUtxo, | isExcludedUtxo, | ||||
whichUtxosWereAdded, | whichUtxosWereAdded, | ||||
whichUtxosWereConsumed, | |||||
} from '@utils/cashMethods'; | } from '@utils/cashMethods'; | ||||
import { | import { | ||||
unbatchedArray, | unbatchedArray, | ||||
arrayBatchedByThree, | arrayBatchedByThree, | ||||
} from '../__mocks__/mockBatchedArrays'; | } from '../__mocks__/mockBatchedArrays'; | ||||
import { | import { | ||||
validAddressArrayInput, | validAddressArrayInput, | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | import { | ||||
utxosAddedBySingleXecSendTx, | utxosAddedBySingleXecSendTx, | ||||
currentUtxosAfterSingleXecSendTxTemplate, | currentUtxosAfterSingleXecSendTxTemplate, | ||||
utxosAddedBySingleXecSendTxTemplate, | utxosAddedBySingleXecSendTxTemplate, | ||||
currentUtxosAfterEtokenSendTxTemplate, | currentUtxosAfterEtokenSendTxTemplate, | ||||
utxosAddedByEtokenSendTxTemplate, | utxosAddedByEtokenSendTxTemplate, | ||||
previousUtxosBeforeEtokenSendTx, | previousUtxosBeforeEtokenSendTx, | ||||
currentUtxosAfterEtokenSendTx, | currentUtxosAfterEtokenSendTx, | ||||
utxosAddedByEtokenSendTx, | utxosAddedByEtokenSendTx, | ||||
utxosConsumedByEtokenSendTx, | |||||
utxosConsumedByEtokenSendTxTemplate, | |||||
utxosConsumedBySingleXecSendTx, | |||||
utxosConsumedBySingleXecSendTxTemplate, | |||||
utxosConsumedBySendAllTx, | |||||
utxosConsumedBySendAllTxTemplate, | |||||
} from '../__mocks__/incrementalUtxoMocks'; | } from '../__mocks__/incrementalUtxoMocks'; | ||||
describe('Correctly executes cash utility functions', () => { | describe('Correctly executes cash utility functions', () => { | ||||
it(`Correctly converts smallest base unit to smallest decimal for cashDecimals = 2`, () => { | it(`Correctly converts smallest base unit to smallest decimal for cashDecimals = 2`, () => { | ||||
expect(fromSmallestDenomination(1, 2)).toBe(0.01); | expect(fromSmallestDenomination(1, 2)).toBe(0.01); | ||||
}); | }); | ||||
it(`Correctly converts largest base unit to smallest decimal for cashDecimals = 2`, () => { | it(`Correctly converts largest base unit to smallest decimal for cashDecimals = 2`, () => { | ||||
expect(fromSmallestDenomination(1000000012345678, 2)).toBe( | expect(fromSmallestDenomination(1000000012345678, 2)).toBe( | ||||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | describe('Correctly executes cash utility functions', () => { | ||||
test('whichUtxosWereAdded correctly identifies added change utxos from a send eToken tx', async () => { | test('whichUtxosWereAdded correctly identifies added change utxos from a send eToken tx', async () => { | ||||
expect( | expect( | ||||
whichUtxosWereAdded( | whichUtxosWereAdded( | ||||
previousUtxosBeforeEtokenSendTx, | previousUtxosBeforeEtokenSendTx, | ||||
currentUtxosAfterEtokenSendTx, | currentUtxosAfterEtokenSendTx, | ||||
), | ), | ||||
).toStrictEqual(utxosAddedByEtokenSendTx); | ).toStrictEqual(utxosAddedByEtokenSendTx); | ||||
}); | }); | ||||
test('whichUtxosWereConsumed correctly identifies no utxos consumed after a received XEC tx [template]', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosTemplate, | |||||
currentUtxosAfterSingleXecReceiveTxTemplate, | |||||
), | |||||
).toStrictEqual(false); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies no utxos consumed a received XEC tx', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeSingleXecReceiveTx, | |||||
currentUtxosAfterSingleXecReceiveTx, | |||||
), | |||||
).toStrictEqual(false); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies no consumed utxos after receiving an XEC multi-send tx [template]', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosTemplate, | |||||
currentUtxosAfterMultiXecReceiveTxTemplate, | |||||
), | |||||
).toStrictEqual(false); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies no consumed utxos after receiving an XEC multi-send tx', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeMultiXecReceiveTx, | |||||
currentUtxosAfterMultiXecReceiveTx, | |||||
), | |||||
).toStrictEqual(false); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a single send XEC tx', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeSingleXecSendTx, | |||||
currentUtxosAfterSingleXecSendTx, | |||||
), | |||||
).toStrictEqual(utxosConsumedBySingleXecSendTx); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a send all XEC tx [template]', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeSendAllTxTemplate, | |||||
currentUtxosAfterSendAllTxTemplate, | |||||
), | |||||
).toStrictEqual(utxosConsumedBySendAllTxTemplate); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a send all XEC tx', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeSendAllTx, | |||||
currentUtxosAfterSendAllTx, | |||||
), | |||||
).toStrictEqual(utxosConsumedBySendAllTx); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a single send XEC tx [template]', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosTemplate, | |||||
currentUtxosAfterSingleXecSendTxTemplate, | |||||
), | |||||
).toStrictEqual(utxosConsumedBySingleXecSendTxTemplate); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a send eToken tx [template]', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosTemplate, | |||||
currentUtxosAfterEtokenSendTxTemplate, | |||||
), | |||||
).toStrictEqual(utxosConsumedByEtokenSendTxTemplate); | |||||
}); | |||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a send eToken tx', async () => { | |||||
expect( | |||||
whichUtxosWereConsumed( | |||||
previousUtxosBeforeEtokenSendTx, | |||||
currentUtxosAfterEtokenSendTx, | |||||
), | |||||
).toStrictEqual(utxosConsumedByEtokenSendTx); | |||||
}); | |||||
}); | }); |