fix(sortAllTxs): Renaming Electrumx.sort0ConfTxs to sortAllTxs

This commit is contained in:
Chris Troutner
2021-01-27 07:24:28 -08:00
parent 338788c46d
commit d8437cf3fb
3 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -651,8 +651,8 @@ class ElectrumX {
}
/**
* @api Electrumx.sort0ConfTxs() sort0ConfTxs()
* @apiName ElectrumX sort0ConfTxs
* @api Electrumx.sortAllTxs() sortAllTxs()
* @apiName ElectrumX sortAllTxs
* @apiGroup ElectrumX
* @apiDescription Sort the output of Electrum.transactions() by block height.
*
@@ -666,7 +666,7 @@ class ElectrumX {
* @apiExample Example usage:
* (async () => {
* const txs = await bchjs.Electrumx.transactions('bitcoincash:qpdh9s677ya8tnx7zdhfrn8qfyvy22wj4qa7nwqa5v')
* const sortedTxs = await bchjs.Electrumx.sort0ConfTxs(txs.transactions, 'ASCENDING')
* const sortedTxs = await bchjs.Electrumx.sortAllTxs(txs.transactions, 'ASCENDING')
* console.log(sortedTxs)
* })()
*
@@ -682,7 +682,7 @@ class ElectrumX {
* // ]
*/
// Substitute zero-conf txs with the current block-height + 1
async sort0ConfTxs (txs, sortingOrder = 'DESCENDING') {
async sortAllTxs (txs, sortingOrder = 'DESCENDING') {
try {
// Calculate the height of the next block
const nextBlock = (await this.blockchain.getBlockCount()) + 1
+2 -2
View File
@@ -369,12 +369,12 @@ describe('#ElectrumX', () => {
})
})
describe('#sort0ConfTxs', () => {
describe('#sortAllTxs', () => {
it('should GET transaction history for a single address', async () => {
const addr = 'bitcoincash:qpdh9s677ya8tnx7zdhfrn8qfyvy22wj4qa7nwqa5v'
const txs = await bchjs.Electrumx.transactions(addr)
const sortedTransactions = await bchjs.Electrumx.sort0ConfTxs(
const sortedTransactions = await bchjs.Electrumx.sortAllTxs(
txs.transactions
)
// console.log(
+4 -4
View File
@@ -456,12 +456,12 @@ describe('#ElectrumX', () => {
})
// These tests use mocked data that contains unconfirmed transactions.
describe('#sort0ConfTxs', () => {
describe('#sortAllTxs', () => {
it('should sort in ascending', async () => {
// Stub network calls
sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141)
const result = await bchjs.Electrumx.sort0ConfTxs(mockData.txHistoryWithUnconfirmed.transactions, 'ASCENDING')
const result = await bchjs.Electrumx.sortAllTxs(mockData.txHistoryWithUnconfirmed.transactions, 'ASCENDING')
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isBelow(result[0].height, result[1].height)
@@ -471,7 +471,7 @@ describe('#ElectrumX', () => {
// Stub network calls
sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141)
const result = await bchjs.Electrumx.sort0ConfTxs(mockData.txHistoryWithUnconfirmed.transactions)
const result = await bchjs.Electrumx.sortAllTxs(mockData.txHistoryWithUnconfirmed.transactions)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isAbove(result[1].height, result[2].height)
@@ -482,7 +482,7 @@ describe('#ElectrumX', () => {
// Stub network calls
sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141)
await bchjs.Electrumx.sort0ConfTxs('abc')
await bchjs.Electrumx.sortAllTxs('abc')
assert.fail('Unexpected result')
} catch (err) {