Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Oct 16, 2024
1 parent ba4b03a commit 13300d3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 48 deletions.
92 changes: 46 additions & 46 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"name": "@gobob/bob-sdk",
"version": "2.3.9",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "vitest run test/*.ts",
"deploy-relay": "ts-node src/scripts/relay-genesis.ts",
"update-relay": "ts-node src/scripts/relay-retarget.ts",
"build": "tsc -p tsconfig.json",
"lint": "eslint . --ext .ts",
"format": "prettier --write {examples,src,test}",
"format:check": "prettier --check {examples,src,test}"
},
"files": [
"dist/**/*",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
],
"devDependencies": {
"@types/node": "^22.5.5",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"ecpair": "^2.1.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"mocha": "^10.7.3",
"nock": "^14.0.0-beta.11",
"prettier": "^3.3.3",
"tiny-secp256k1": "^2.2.3",
"ts-node": "^10.0.0",
"typescript": "^5.6.2",
"vitest": "^2.0.5",
"yargs": "^17.5.1"
},
"dependencies": {
"@scure/base": "^1.1.7",
"@scure/btc-signer": "^1.3.2",
"bitcoin-address-validation": "^2.2.3",
"bitcoinjs-lib": "^6.1.6",
"ethers": "^6.13.2"
}
"name": "@gobob/bob-sdk",
"version": "3.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "vitest run test/*.ts",
"deploy-relay": "ts-node src/scripts/relay-genesis.ts",
"update-relay": "ts-node src/scripts/relay-retarget.ts",
"build": "tsc -p tsconfig.json",
"lint": "eslint . --ext .ts",
"format": "prettier --write {examples,src,test}",
"format:check": "prettier --check {examples,src,test}"
},
"files": [
"dist/**/*",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
],
"devDependencies": {
"@types/node": "^22.5.5",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"ecpair": "^2.1.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"mocha": "^10.7.3",
"nock": "^14.0.0-beta.11",
"prettier": "^3.3.3",
"tiny-secp256k1": "^2.2.3",
"ts-node": "^10.0.0",
"typescript": "^5.6.2",
"vitest": "^2.0.5",
"yargs": "^17.5.1"
},
"dependencies": {
"@scure/base": "^1.1.7",
"@scure/btc-signer": "^1.3.2",
"bitcoin-address-validation": "^2.2.3",
"bitcoinjs-lib": "^6.1.6",
"ethers": "^6.13.2"
}
}
7 changes: 6 additions & 1 deletion sdk/src/esplora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ export class EsploraClient {
const chainBalance = response.chain_stats.funded_txo_sum - response.chain_stats.spent_txo_sum;
const mempoolBalance = response.mempool_stats.funded_txo_sum - response.mempool_stats.spent_txo_sum;

// Return as an object with chain, mempool, and total fields
console.log({
chain: chainBalance,
mempool: mempoolBalance,
total: chainBalance + mempoolBalance,
});

return {
chain: chainBalance,
mempool: mempoolBalance,
Expand Down
6 changes: 5 additions & 1 deletion sdk/test/esplora.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ describe('Esplora Tests', () => {
it('should get balance', async () => {
const client = new EsploraClient('testnet');
const balance = await client.getBalance('tb1qjhekcm565spvr0epqu5nvd9mhgwaafg6d0n2yw');
assert.equal(balance, 727499862);
assert.deepEqual(balance, {
chain: 727499862,
mempool: 0,
total: 727499862,
});
});
});

0 comments on commit 13300d3

Please sign in to comment.