Skip to content

fix: fetch aggregate mempool state endpoint - #3

Open
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:mainfrom
tolga-tom-nook:fix/mempool-state-endpoint
Open

fix: fetch aggregate mempool state endpoint#3
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:mainfrom
tolga-tom-nook:fix/mempool-state-endpoint

Conversation

@tolga-tom-nook

Copy link
Copy Markdown

Summary

Fixes getMempoolState() so it calls the aggregate mempool state endpoint instead of the paginated mempool transaction-list endpoint.

Before this change, getMempoolState() built this URL:

/mempool/transactions?page=...

That returns a transaction list shape (count, page, pages, list) rather than the mempool state shape. This PR switches the method to:

/mempool/state

and strengthens the regression test so it awaits the SDK call and asserts state fields (inputs, outputs, transactions) instead of only checking that a Promise object exists.

RED / GREEN validation

RED proof before the code fix, after strengthening the test:

npx jest src/__tests__/mempool.test.ts --runInBand --no-cache --coverage=false --testNamePattern 'should fetch mempool state'

Failed because the method returned the transaction-list object and did not contain inputs.

GREEN after the fix:

npx jest src/__tests__/mempool.test.ts --runInBand --no-cache --coverage=false --testNamePattern 'should fetch mempool state'

Result:

PASS src/__tests__/mempool.test.ts
Tests: 1 passed, 3 skipped, 4 total

Broader validation:

npx jest src/__tests__/mempool.test.ts --runInBand --no-cache --coverage=false
npx jest --runInBand --no-cache --coverage=false
npm run build
git diff --check

Results:

PASS src/__tests__/mempool.test.ts
Tests: 4 passed, 4 total

PASS src/__tests__/blockchain.test.ts
PASS src/__tests__/mempool.test.ts
PASS src/__tests__/address.test.ts
PASS src/__tests__/transaction.test.ts
PASS src/__tests__/api.test.ts
Test Suites: 5 passed, 5 total
Tests: 22 passed, 22 total

npm run build: passed
git diff --check: clean

Note: targeted ESLint on this repo currently reports pre-existing functional/class-rule errors in src/classes/Mempool.ts and a parser project inclusion error for src/__tests__/mempool.test.ts; these are unrelated to this endpoint change. The focused Jest regression, full Jest suite, build, and diff check pass.

Bounty context: Bitgesell PR bounty/improvement program.

@MyTH-zyxeon

Copy link
Copy Markdown

Review assist for maintainers:

This looks like a focused SDK endpoint correction: getMempoolState() now calls the aggregate /mempool/state endpoint instead of the paginated /mempool/transactions query, and the test now awaits the async call and checks for the aggregate shape (inputs, outputs, transactions). I checked the patch scope and did not see wallet, key, transaction signing, or bridge-runtime behavior changes.

Suggested merge checks:

  • Run the mempool Jest test with the existing SDK test harness and confirm it no longer passes accidentally through an un-awaited Promise.
  • Confirm the public API contract change is intentional: getMempoolState() no longer accepts limit, order, fromTimestamp, or page, because those belong to transaction-list retrieval rather than aggregate state.
  • Verify against the documented/indexed API surface that /mempool/state returns the three aggregate fields asserted here, and keep /mempool/transactions coverage in a separate transaction-list method/test if needed.

Main acceptance criterion: aggregate mempool-state callers should hit /mempool/state deterministically, with async tests proving the returned shape rather than only checking that a Promise object exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants