Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
Show First 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | expect(tokenInputObj.remainderTokenValue).toStrictEqual( | ||||
new BigNumber(6400), // token change is mockSlpUtxos[0] 400 + mockSlpUtxos[1] 6500 - [tokenAmount] 500 | new BigNumber(6400), // token change is mockSlpUtxos[0] 400 + mockSlpUtxos[1] 6500 - [tokenAmount] 500 | ||||
); | ); | ||||
expect(tokenInputObj.txBuilder.toString()).toStrictEqual( | expect(tokenInputObj.txBuilder.toString()).toStrictEqual( | ||||
mockBurnTokenTxBuilderObj.toString(), | mockBurnTokenTxBuilderObj.toString(), | ||||
); | ); | ||||
}); | }); | ||||
it(`generateTokenTxOutput() returns a valid object for a valid create token tx`, async () => { | it(`generateTokenTxOutput() returns a valid object for a valid create token tx`, async () => { | ||||
const BCH = new BCHJS(); | |||||
let txBuilder = new TransactionBuilder(); | let txBuilder = new TransactionBuilder(); | ||||
const { configObj, wallet } = createTokenMock; | const { configObj, wallet } = createTokenMock; | ||||
const tokenSenderCashAddress = wallet.Path1899.cashAddress; | const tokenSenderCashAddress = wallet.Path1899.cashAddress; | ||||
const tokenOutputObj = generateTokenTxOutput( | const tokenOutputObj = generateTokenTxOutput( | ||||
BCH, | |||||
txBuilder, | txBuilder, | ||||
'GENESIS', | 'GENESIS', | ||||
tokenSenderCashAddress, | tokenSenderCashAddress, | ||||
null, // optional, for SEND or BURN amount | null, // optional, for SEND or BURN amount | ||||
new BigNumber(500), // remainder XEC value | new BigNumber(500), // remainder XEC value | ||||
configObj, | configObj, | ||||
); | ); | ||||
expect(tokenOutputObj.toString()).toStrictEqual( | expect(tokenOutputObj.toString()).toStrictEqual( | ||||
mockCreateTokenOutputsTxBuilderObj.toString(), | mockCreateTokenOutputsTxBuilderObj.toString(), | ||||
); | ); | ||||
}); | }); | ||||
it(`generateTokenTxOutput() returns a valid object for a valid send token tx`, async () => { | it(`generateTokenTxOutput() returns a valid object for a valid send token tx`, async () => { | ||||
const BCH = new BCHJS(); | |||||
let txBuilder = new TransactionBuilder(); | let txBuilder = new TransactionBuilder(); | ||||
const { wallet } = createTokenMock; | const { wallet } = createTokenMock; | ||||
const tokenSenderCashAddress = wallet.Path1899.cashAddress; | const tokenSenderCashAddress = wallet.Path1899.cashAddress; | ||||
const tokenRecipientTokenAddress = wallet.Path1899.slpAddress; | const tokenRecipientTokenAddress = wallet.Path1899.slpAddress; | ||||
const tokenOutputObj = generateTokenTxOutput( | const tokenOutputObj = generateTokenTxOutput( | ||||
BCH, | |||||
txBuilder, | txBuilder, | ||||
'SEND', | 'SEND', | ||||
tokenSenderCashAddress, | tokenSenderCashAddress, | ||||
mockSlpUtxos, | mockSlpUtxos, | ||||
new BigNumber(500), // remainder XEC value | new BigNumber(500), // remainder XEC value | ||||
null, // only for genesis tx | null, // only for genesis tx | ||||
tokenRecipientTokenAddress, // recipient token address | tokenRecipientTokenAddress, // recipient token address | ||||
new BigNumber(50), | new BigNumber(50), | ||||
); | ); | ||||
expect(tokenOutputObj.toString()).toStrictEqual( | expect(tokenOutputObj.toString()).toStrictEqual( | ||||
mockSendTokenOutputsTxBuilderObj.toString(), | mockSendTokenOutputsTxBuilderObj.toString(), | ||||
); | ); | ||||
}); | }); | ||||
it(`generateTokenTxOutput() returns a valid object for a valid burn token tx`, async () => { | it(`generateTokenTxOutput() returns a valid object for a valid burn token tx`, async () => { | ||||
const BCH = new BCHJS(); | |||||
let txBuilder = new TransactionBuilder(); | let txBuilder = new TransactionBuilder(); | ||||
const { wallet } = createTokenMock; | const { wallet } = createTokenMock; | ||||
const tokenSenderCashAddress = wallet.Path1899.cashAddress; | const tokenSenderCashAddress = wallet.Path1899.cashAddress; | ||||
const tokenOutputObj = generateTokenTxOutput( | const tokenOutputObj = generateTokenTxOutput( | ||||
BCH, | |||||
txBuilder, | txBuilder, | ||||
'BURN', | 'BURN', | ||||
tokenSenderCashAddress, | tokenSenderCashAddress, | ||||
mockSlpUtxos, | mockSlpUtxos, | ||||
new BigNumber(500), // remainder XEC value | new BigNumber(500), // remainder XEC value | ||||
null, // only for genesis tx | null, // only for genesis tx | ||||
null, // no token recipients for burn tx | null, // no token recipients for burn tx | ||||
new BigNumber(50), | new BigNumber(50), | ||||
▲ Show 20 Lines • Show All 1,004 Lines • Show Last 20 Lines |