Skip to content

Commit

Permalink
Merge pull request #14 from bitcoinerlab/explorer-bump-more-tests
Browse files Browse the repository at this point in the history
Bump @bitcoinerlab/explorer to 0.3.0 and Enhance Integration Tests
  • Loading branch information
landabaso authored Jul 23, 2024
2 parents e23c652 + 0df61f0 commit 5ba0d7b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 36 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@bitcoinerlab/discovery",
"description": "A TypeScript library for retrieving Bitcoin funds from ranged descriptors, leveraging @bitcoinerlab/explorer for standardized access to multiple blockchain explorers.",
"homepage": "https://github.com/bitcoinerlab/discovery",
"version": "1.2.4",
"version": "1.2.5",
"author": "Jose-Luis Landabaso",
"license": "MIT",
"prettier": "@bitcoinerlab/configs/prettierConfig.json",
Expand Down Expand Up @@ -44,7 +44,7 @@
],
"dependencies": {
"@bitcoinerlab/descriptors": "^2.1.0",
"@bitcoinerlab/explorer": "^0.2.0",
"@bitcoinerlab/explorer": "^0.3.0",
"@bitcoinerlab/secp256k1": "^1.1.1",
"@types/memoizee": "^0.4.8",
"bitcoinjs-lib": "^6.1.5",
Expand Down
69 changes: 44 additions & 25 deletions test/integration/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,49 @@ import { networks } from 'bitcoinjs-lib';
import * as secp256k1 from '@bitcoinerlab/secp256k1';
import * as descriptors from '@bitcoinerlab/descriptors';
import { mnemonicToSeedSync } from 'bip39';
import { ElectrumExplorer } from '@bitcoinerlab/explorer';
import { ElectrumExplorer, EsploraExplorer } from '@bitcoinerlab/explorer';
const { BIP32 } = descriptors.DescriptorsFactory(secp256k1);
import { DiscoveryFactory, TxStatus, Account } from '../../dist';

const onAccountUsed = (_account: Account) => {
//console.log(`TRACE - onAccountUsed(${account}`);
};

console.log(ElectrumExplorer);
void ElectrumExplorer;
void EsploraExplorer;
for (const network of [networks.bitcoin]) {
for (const explorer of [
for (const explorerAndInfo of [
{
explorer: new EsploraExplorer({
url: 'https://blockstream.info/api/',
requestQueueParams: {
//maxConcurrentTasks: 30
//maxConcurrentTasks: 5 //default is 10
//maxAttemptsForHardErrors: 10 //default is 5
}
}),
info: 'EsploraExplorer'
},
{
explorer: new ElectrumExplorer({
//host: 'btc.lastingcoin.net', //time out on bitcoind
//host: 'electrum.bitcoinserver.nl', //ETIMEDOUT - this is a small server, low resources.
//host: 'fulcrum.not.fyi', //TIMEOUT
//host: 'bolt.schulzemic.net', // -> Mega fast
//host: 'fulcrum.theuplink.net', //TIMEOUT
//host: 'f006.fuchsia.fastwebserver.de', fulcrum fast on recache
//host: 'electrum-btc.leblancnet.us', //Electrumx
host: 'electrum1.bluewallet.io', //Also quite fast TBH COLD: FirstCall: 29375 ms - SecondCall: 3714 ms - HOT: SIMILAR
//port: 50002,
port: 443,
protocol: 'ssl',
network,
irrevConfThresh: 3,
maxTxPerScriptPubKey: 1000
}),
info: 'electrum1.bluewallet.io'
}

//Some servers: https://1209k.com/bitcoin-eye/ele.php
//new EsploraExplorer({
// url:
Expand All @@ -45,28 +77,15 @@ for (const network of [networks.bitcoin]) {
// protocol: 'ssl',
// network, irrevConfThresh: 3, maxTxPerScriptPubKey: 1000
//})
new ElectrumExplorer({
//host: 'btc.lastingcoin.net', //time out on bitcoind
//host: 'electrum.bitcoinserver.nl', //ETIMEDOUT - this is a small server, low resources.
//host: 'fulcrum.not.fyi', //TIMEOUT
//host: 'bolt.schulzemic.net', // -> Mega fast
//host: 'fulcrum.theuplink.net', //TIMEOUT
//host: 'f006.fuchsia.fastwebserver.de', fulcrum fast on recache
//host: 'electrum-btc.leblancnet.us', //Electrumx
host: 'electrum1.bluewallet.io', //Also quite fast TBH COLD: FirstCall: 29375 ms - SecondCall: 3714 ms - HOT: SIMILAR
//port: 50002,
port: 443,
protocol: 'ssl',
network,
irrevConfThresh: 3,
maxTxPerScriptPubKey: 1000
})
])
describe(`Discovery on ${network.bech32}`, () => {
describe(`Discovery with ${explorerAndInfo.info} on ${network.bech32}`, () => {
test(
`Discover Abandon`,
async () => {
const { Discovery } = DiscoveryFactory(explorer, network);
const { Discovery } = DiscoveryFactory(
explorerAndInfo.explorer,
network
);
const masterNode = BIP32.fromSeed(
mnemonicToSeedSync(
//'camp foam advice east amount dolphin aspect drift dumb column job absorb' //unused
Expand All @@ -76,14 +95,14 @@ for (const network of [networks.bitcoin]) {
network
);
const discovery = new Discovery();
await explorer.connect();
await explorerAndInfo.explorer.connect();
console.time('FirstCall');
await discovery.fetchStandardAccounts({
masterNode,
onAccountUsed
});
console.timeEnd('FirstCall');
console.time('SecondCall');
console.time('SecondCall'); //This one should be significanlty faster
await discovery.fetchStandardAccounts({
masterNode,
onAccountUsed
Expand Down Expand Up @@ -122,9 +141,9 @@ for (const network of [networks.bitcoin]) {
//);
}
//console.log(JSON.stringify(discovery.getDiscoveryInfo(), null, 2));
await explorer.close();
await explorerAndInfo.explorer.close();
},
60 * 10 * 1000
180 * 10 * 1000 //30 minutes
);
});
}

0 comments on commit 5ba0d7b

Please sign in to comment.