Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
274a733
refactored routes test to folder for multiple tests
MicahMaphet Aug 27, 2025
e228e2c
added address tests
MicahMaphet Aug 28, 2025
0ecfa32
fixed /address/:address/balance route and other improvement
MicahMaphet Aug 29, 2025
443abda
added transaction route test
MicahMaphet Sep 1, 2025
84e3e73
added limit and unspent parameter testing to address
MicahMaphet Sep 1, 2025
a2c5430
added valid/:input route tests
MicahMaphet Sep 2, 2025
8a3f049
removed routes file, as it was replaced
MicahMaphet Sep 3, 2025
2e24c07
added stats route test
MicahMaphet Sep 3, 2025
dfbdbb1
removed redundant streamAddressUtxos method and redundant code in add…
MicahMaphet Sep 4, 2025
dc76305
created wallet.spec.ts and added wallet creation tests
MicahMaphet Sep 7, 2025
0898c21
Merge branch 'master' into route-tests
MicahMaphet Sep 9, 2025
d39439e
added signatures to wallet routes
MicahMaphet Sep 10, 2025
663f064
added wallet route test for updating wallet with an address
MicahMaphet Sep 12, 2025
8806d48
added test for wallet/:pubkey/balance when wallet has utxos
MicahMaphet Sep 13, 2025
abbe539
fixed block updating reprocess option on address update route
MicahMaphet Sep 16, 2025
dc49bce
added wallet /check route tests
MicahMaphet Sep 17, 2025
3066f09
test wallet data fetch route
MicahMaphet Sep 17, 2025
72bedac
added wallet/:pubKey/balance/:time route test
MicahMaphet Sep 17, 2025
57ea1a7
added wallet transactions route test
MicahMaphet Sep 23, 2025
03a6dbf
added missing addresses route test
MicahMaphet Sep 26, 2025
23d36ef
Merge branch 'master' into route-tests
MicahMaphet Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bitcore-test.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"wallets": {
"allowCreationBeforeCompleteSync": true
}
},
"socket": {
"bwsKeys": [
"036df8264584a6398718e88a5bf4dc816c52e5037303934d555dba0ccaa65fbe3f"
]
}
},
"chains": {
Expand Down
4 changes: 0 additions & 4 deletions packages/bitcore-node/src/providers/chain-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class ChainStateProxy implements IChainStateProvider {
return services[chain][network];
}

streamAddressUtxos(params: StreamAddressUtxosParams) {
return this.get(params).streamAddressUtxos(params);
}

streamAddressTransactions(params: StreamAddressUtxosParams) {
return this.get(params).streamAddressTransactions(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ export class InternalStateProvider implements IChainStateService {
return query;
}

streamAddressUtxos(params: StreamAddressUtxosParams) {
const { req, res, args } = params;
const { limit, since } = args;
const query = this.getAddressQuery(params);
Storage.apiStreamingFind(CoinStorage, query, { limit, since, paging: '_id' }, req!, res!);
}

async streamAddressTransactions(params: StreamAddressUtxosParams) {
const { req, res, args } = params;
const { limit, since } = args;
Expand Down
20 changes: 1 addition & 19 deletions packages/bitcore-node/src/routes/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,7 @@ async function streamCoins(req: Request, res) {
}
}

router.get('/:address', function (req: Request, res) {
try {
let { chain, network, address } = req.params;
let { unspent, limit = 10, since } = req.query;
let payload = {
chain,
network,
address,
req,
res,
args: { unspent, limit, since }
} as StreamAddressUtxosParams;
return ChainStateProvider.streamAddressUtxos(payload);
} catch (err: any) {
logger.error('Error getting address: %o', err.stack || err.message || err);
return res.status(500).send(err.message || err);
}
});

router.get('/:address', streamCoins);
router.get('/:address/txs', streamCoins);
router.get('/:address/coins', streamCoins);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export interface IChainStateService {
getWalletBalanceAtTime(
params: GetWalletBalanceAtTimeParams
): Promise<WalletBalanceType>;
streamAddressUtxos(params: StreamAddressUtxosParams): any;
streamAddressTransactions(params: StreamAddressUtxosParams): any;
streamTransactions(params: StreamTransactionsParams): any;
getAuthhead(params: StreamTransactionParams): Promise<AuthheadJSON | undefined>;
Expand Down
25 changes: 25 additions & 0 deletions packages/bitcore-node/test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { WalletStorage } from '../../src/models/wallet';
import { WalletAddressStorage } from '../../src/models/walletAddress';
import { Storage } from '../../src/services/storage';
import { expect } from 'chai';
import { randomBytes } from 'crypto';

export async function resetDatabase() {
console.log('Resetting database');
Expand Down Expand Up @@ -83,5 +84,29 @@ export function expectObjectToHaveProps(obj: any, props: Record<string, string>)
expect(obj[key]).to.be.a(props[key]);
}
};
export function testCoin (coin) {
expect(coin, 'coin is undefined').to.exist;
expect(coin, 'coin is not an object').to.be.an('object');
expect(coin, 'coin test').to.have.property('chain').that.is.a('string', `coin.chain is not a string`);
expect(coin, 'coin test').to.have.property('network').that.is.a('string', 'coin.network is not a string');
expect(coin, 'coin test').to.have.property('mintIndex').that.is.a('number', 'coin.mintIndex is not a number');
expect(coin, 'coin test').to.have.property('mintTxid').that.is.a('string', 'coin.mintTxid is not a string');
expect(coin, 'coin test').to.have.property('address').that.is.a('string', 'coin.address is not a string');
expect(coin, 'coin test').to.have.property('coinbase').that.is.a('boolean', 'coin.coinbase is not a boolean');
expect(coin, 'coin test').to.have.property('mintHeight').that.is.a('number', 'coin.mintHeight is not a number');
expect(coin, 'coin test').to.have.property('script');
expect(coin, 'coin test').to.have.property('spentHeight').that.is.a('number', 'coin.spentHeight is not a number');
expect(coin, 'coin test').to.have.property('value').that.is.a('number', 'coin.value is not a number');
expect(coin, 'coin test').to.have.property('spentTxid').that.is.a('string', 'coin.spentTxid is not a string');
if ('confirmations' in coin) {
expect(coin.confirmations, 'coin.confirmations is not a number').to.be.a('number');
}
}

export const minutesAgo = (minutes: number): Date => new Date(Date.now() - 1000 * 60 * minutes);

export const randomHex = (characters: number): string =>
randomBytes(Math.ceil(characters / 2.0)).toString('hex').slice(0, characters);

export const mongoIdRegex = /^[a-f0-9]{24}$/;
export const base58Regex = /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
Loading