Changeset View
Changeset View
Standalone View
Standalone View
apps/alias-server/test/utilsTests.js
// Copyright (c) 2023 The Bitcoin developers | // Copyright (c) 2023 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
'use strict'; | 'use strict'; | ||||
const assert = require('assert'); | const assert = require('assert'); | ||||
const { | const { | ||||
getAliasFromHex, | getAliasFromHex, | ||||
getHexFromAlias, | getHexFromAlias, | ||||
getAliasBytecount, | getAliasBytecount, | ||||
isValidAliasString, | isValidAliasString, | ||||
removeUnconfirmedTxsFromTxHistory, | removeUnconfirmedTxsFromTxHistory, | ||||
getOutputScriptFromAddress, | |||||
} = require('../src/utils'); | } = require('../src/utils'); | ||||
const unconfirmedAliasTxs = require('./mocks/unconfirmedAliasTxs'); | const unconfirmedAliasTxs = require('./mocks/unconfirmedAliasTxs'); | ||||
const { | const { | ||||
aliasHexConversions, | aliasHexConversions, | ||||
validAliasStrings, | validAliasStrings, | ||||
invalidAliasStrings, | invalidAliasStrings, | ||||
} = require('./mocks/utilsMocks'); | } = require('./mocks/utilsMocks'); | ||||
const { testAddressAliases } = require('./mocks/aliasMocks'); | const { testAddressAliases } = require('./mocks/aliasMocks'); | ||||
Show All 22 Lines | describe('alias-server utils.js', function () { | ||||
it('removeUnconfirmedTxsFromTxHistory removes unconfirmed txs from an array of chronik tx history', function () { | it('removeUnconfirmedTxsFromTxHistory removes unconfirmed txs from an array of chronik tx history', function () { | ||||
assert.deepEqual( | assert.deepEqual( | ||||
removeUnconfirmedTxsFromTxHistory( | removeUnconfirmedTxsFromTxHistory( | ||||
unconfirmedAliasTxs.concat(testAddressAliases.txHistory), | unconfirmedAliasTxs.concat(testAddressAliases.txHistory), | ||||
), | ), | ||||
testAddressAliases.txHistory, | testAddressAliases.txHistory, | ||||
); | ); | ||||
}); | }); | ||||
// getOutputScriptFromAddress | |||||
it('Returns expected outputScript for a p2pkh address', function () { | |||||
assert.strictEqual( | |||||
getOutputScriptFromAddress( | |||||
'ecash:qp3c268rd5946l2f5m5es4x25f7ewu4sjvpy52pqa8', | |||||
), | |||||
'76a914638568e36d0b5d7d49a6e99854caa27d9772b09388ac', | |||||
); | |||||
}); | |||||
it('Returns expected outputScript for a p2sh address', function () { | |||||
assert.strictEqual( | |||||
getOutputScriptFromAddress( | |||||
'ecash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07', | |||||
), | |||||
'a914d37c4c809fe9840e7bfa77b86bd47163f6fb6c6087', | |||||
); | |||||
}); | |||||
}); | }); |