Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
Show All 27 Lines | import { | ||||
getUtxoWif, | getUtxoWif, | ||||
generateTokenTxOutput, | generateTokenTxOutput, | ||||
getCashtabByteCount, | getCashtabByteCount, | ||||
calcFee, | calcFee, | ||||
toHash160, | toHash160, | ||||
generateGenesisOpReturn, | generateGenesisOpReturn, | ||||
generateSendOpReturn, | generateSendOpReturn, | ||||
generateBurnOpReturn, | generateBurnOpReturn, | ||||
getECPairFromWIF, | |||||
} from 'utils/cashMethods'; | } from 'utils/cashMethods'; | ||||
import { currency } from 'components/Common/Ticker'; | import { currency } from 'components/Common/Ticker'; | ||||
import { | import { | ||||
validAddressArrayInput, | validAddressArrayInput, | ||||
validAddressArrayInputMixedPrefixes, | validAddressArrayInputMixedPrefixes, | ||||
validAddressArrayOutput, | validAddressArrayOutput, | ||||
validLargeAddressArrayInput, | validLargeAddressArrayInput, | ||||
validLargeAddressArrayOutput, | validLargeAddressArrayOutput, | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
import { | import { | ||||
mockSingleInputUtxo, | mockSingleInputUtxo, | ||||
mockMultipleInputUtxos, | mockMultipleInputUtxos, | ||||
mockSingleOutput, | mockSingleOutput, | ||||
mockMultipleOutputs, | mockMultipleOutputs, | ||||
} from '../__mocks__/mockTxBuilderData'; | } from '../__mocks__/mockTxBuilderData'; | ||||
import createTokenMock from '../../hooks/__mocks__/createToken'; | import createTokenMock from '../../hooks/__mocks__/createToken'; | ||||
import TransactionBuilder from 'utils/txBuilder'; | import TransactionBuilder from 'utils/txBuilder'; | ||||
import { mockWif, mockStringifiedECPair } from '../__mocks__/mockECPair'; | |||||
it(`generateSendOpReturn() returns correct script object for valid tokenUtxo and send quantity`, () => { | it(`generateSendOpReturn() returns correct script object for valid tokenUtxo and send quantity`, () => { | ||||
const BCH = new BCHJS(); | const BCH = new BCHJS(); | ||||
const tokensToSend = 50; | const tokensToSend = 50; | ||||
const sendOpReturnScriptObj = generateSendOpReturn( | const sendOpReturnScriptObj = generateSendOpReturn( | ||||
mockSendOpReturnTokenUtxos, | mockSendOpReturnTokenUtxos, | ||||
tokensToSend, | tokensToSend, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 1,636 Lines • ▼ Show 20 Lines | it(`getCashtabByteCount for 1 input, 2000 outputs returns the same value as BCH.BitcoinCash.getByteCount( | ||||
expect(getCashtabByteCount(1, 2000)).toBe( | expect(getCashtabByteCount(1, 2000)).toBe( | ||||
BCH.BitcoinCash.getByteCount({ P2PKH: 1 }, { P2PKH: 2000 }), | BCH.BitcoinCash.getByteCount({ P2PKH: 1 }, { P2PKH: 2000 }), | ||||
); | ); | ||||
}); | }); | ||||
it('calculates fee correctly for 2 P2PKH outputs', () => { | it('calculates fee correctly for 2 P2PKH outputs', () => { | ||||
const utxosMock = [{}, {}]; | const utxosMock = [{}, {}]; | ||||
expect(calcFee(utxosMock, 2, 1.01)).toBe(378); | expect(calcFee(utxosMock, 2, 1.01)).toBe(378); | ||||
}); | }); | ||||
it(`Gets correct EC Pair from WIF`, () => { | |||||
expect(JSON.stringify(getECPairFromWIF(mockWif))).toBe( | |||||
mockStringifiedECPair, | |||||
); | |||||
}); | |||||
}); | }); |