Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
Show All 16 Lines | import { | ||||
generateOpReturnScript, | generateOpReturnScript, | ||||
generateTxInput, | generateTxInput, | ||||
generateTxOutput, | generateTxOutput, | ||||
generateTokenTxInput, | generateTokenTxInput, | ||||
signAndBuildTx, | signAndBuildTx, | ||||
fromXecToSatoshis, | fromXecToSatoshis, | ||||
getWalletBalanceFromUtxos, | getWalletBalanceFromUtxos, | ||||
signUtxosByAddress, | signUtxosByAddress, | ||||
getUtxoWif, | |||||
generateTokenTxOutput, | generateTokenTxOutput, | ||||
getCashtabByteCount, | getCashtabByteCount, | ||||
calcFee, | calcFee, | ||||
toHash160, | toHash160, | ||||
generateGenesisOpReturn, | generateGenesisOpReturn, | ||||
generateSendOpReturn, | generateSendOpReturn, | ||||
generateBurnOpReturn, | generateBurnOpReturn, | ||||
getECPairFromWIF, | getECPairFromWIF, | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | expect(JSON.stringify(sendOpReturnScriptObj.script)).toStrictEqual( | ||||
JSON.stringify(mockSendOpReturnScript), | JSON.stringify(mockSendOpReturnScript), | ||||
); | ); | ||||
expect(JSON.stringify(sendOpReturnScriptObj.script)).toStrictEqual( | expect(JSON.stringify(sendOpReturnScriptObj.script)).toStrictEqual( | ||||
JSON.stringify(legacySendOpReturnScriptObj.script), | JSON.stringify(legacySendOpReturnScriptObj.script), | ||||
); | ); | ||||
}); | }); | ||||
it(`generateSendOpReturnScript() throws error on invalid input`, () => { | it(`generateSendOpReturnScript() throws error on invalid input`, () => { | ||||
const BCH = new BCHJS(); | |||||
const mockSendOpReturnTokenUtxos = null; | const mockSendOpReturnTokenUtxos = null; | ||||
const tokensToSend = 50; | const tokensToSend = 50; | ||||
let errorThrown; | let errorThrown; | ||||
try { | try { | ||||
generateSendOpReturn(mockSendOpReturnTokenUtxos, tokensToSend); | generateSendOpReturn(mockSendOpReturnTokenUtxos, tokensToSend); | ||||
} catch (err) { | } catch (err) { | ||||
errorThrown = err.message; | errorThrown = err.message; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | it(`generateGenesisOpReturn() returns correct script for a valid configObj`, () => { | ||||
); | ); | ||||
expect(JSON.stringify(genesisOpReturnScript)).toStrictEqual( | expect(JSON.stringify(genesisOpReturnScript)).toStrictEqual( | ||||
JSON.stringify(legacyGenesisOpReturnScript), | JSON.stringify(legacyGenesisOpReturnScript), | ||||
); | ); | ||||
}); | }); | ||||
it(`generateGenesisOpReturn() throws error on invalid configObj`, () => { | it(`generateGenesisOpReturn() throws error on invalid configObj`, () => { | ||||
const BCH = new BCHJS(); | |||||
const configObj = null; | const configObj = null; | ||||
let errorThrown; | let errorThrown; | ||||
try { | try { | ||||
generateGenesisOpReturn(configObj); | generateGenesisOpReturn(configObj); | ||||
} catch (err) { | } catch (err) { | ||||
errorThrown = err.message; | errorThrown = err.message; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,414 Lines • Show Last 20 Lines |