Skip to content

Add Blend v2 integration test suite#664

Open
aditya1702 wants to merge 11 commits into
blend/pr5-graphqlfrom
blend/pr6-integration-tests
Open

Add Blend v2 integration test suite#664
aditya1702 wants to merge 11 commits into
blend/pr5-graphqlfrom
blend/pr6-integration-tests

Conversation

@aditya1702

@aditya1702 aditya1702 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Deploys the full Blend v2 protocol stack (Comet BLND:USDC LP, mock SEP-40 oracle, emitter, pool factory, backstop, one pool with USDC/XLM reserves) on the standalone integration-test network — replicating blend-utils' mock-example.ts deployment order (pinned commit b05242df, wasm provenance + sha256s in infrastructure/testdata/blend/README.md) — then executes real Blend operations and asserts DB state and GraphQL responses through both ingestion paths.

Coverage

  • Operations (11/15 LENDING reasons end-to-end): SUPPLY, WITHDRAW, SUPPLY_COLLATERAL, WITHDRAW_COLLATERAL, BORROW, REPAY, CLAIM (pool + backstop source), LIQUIDATION (oracle-forced undercollateralization → new_auction → 50% fill; both counterparty rows + auction position folds), BACKSTOP_DEPOSIT, BACKSTOP_WITHDRAW_QUEUE, BACKSTOP_WITHDRAW_CANCEL.
  • Read side: reserve rates/APYs vs mock-oracle prices, Comet LP valuation (backstop USD), oracle price snapshots (SEP-40 leg + Comet BLND/LP legs), emissions accrual and claims (claimedBlnd, backstopClaimedLp, token_id = -1 backstop streams), exact net_supplied/net_borrowed cost-basis folds, Q4W JSONB with the ~17-day expiration observed live over GraphQL while queued.
  • Ingestion paths: BlendMigrationTestSuite runs protocol-setupprotocol-migrate current-stateprotocol-migrate history (datastore backend, MinIO-fed by the ledger exporter) with cursor-handoff pre/post assertions — the history mode's first automated coverage. BlendLiveIngestionTestSuite restarts ingest with BLEND_PRICE_INTERVAL / BLEND_BACKSTOP_LP_CONTRACT_ID and asserts the full Freighter-facing GraphQL surface (blendPools, blendPool, blendEarnOptions, account.blendPositions, LENDING state changes).

Not covered end-to-end (unit tests only)

  • BACKSTOP_WITHDRAW — the Q4W lockup is 17 days of wall-clock time; ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING only accelerates ledger cadence, not close time, so the lockup cannot elapse on standalone.
  • FLASH_LOAN — needs a custom receiver contract.
  • BAD_DEBT / DEFAULTED_DEBT — require draining the backstop below threshold plus a full liquidation leaving residual debt.

Production changes

  • blndTokenAddress (internal/services/blend/validator.go) gains a standalone-network case: the suite issues BLND from the network master account (keypair.Root of the passphrase), so its SAC address is a fixed constant, letting pool-CLAIM rows carry the real BLND token_id on standalone. Pinned by a unit test and asserted at deploy time in the test setup.
  • pkg/wbclient gains Blend query methods (GetBlendPools, GetBlendPool, GetBlendEarnOptions, GetAccountBlendPositions) and LendingChange state-change decoding, with unit tests.

Test infrastructure added

  • Per-actor Soroban executor (executeSorobanOperationAs): arbitrary tx source, RPC-fresh sequences, simulation-provided auth nonces (the existing helper hardcodes nonce 0, safe only for the master account's first use).
  • Salted contract deploys + address precompute, used to break the emitter↔backstop circular dependency by precomputing the backstop's address before deployment.
  • Typed wrappers for every pool/backstop/emitter/oracle/Comet call, ScVal builders with symbol-sorted UDT maps (unit-tested), and named fixture constants so assertions reference the same values the operations used.

Blend phase adds ~100s to make integration-test (total run ~4.5 min, well under the 30m timeout). Verified green twice, including a FORCE_REBUILD=true from-scratch run.

🤖 Generated with Claude Code


Update — assert claimed totals

Adds assertions that the supplier's pool claim and the whale's backstop claim fold positive totals into blend_pool_claimed / blend_backstop_claimed (via the new readers, after phase-2 ingestion), plus a guard that phase-1 (no claims) leaves both tables empty.

@aditya1702
aditya1702 force-pushed the blend/pr6-integration-tests branch from 6f67e5f to 39422d7 Compare July 15, 2026 20:52
@aditya1702
aditya1702 force-pushed the blend/pr6-integration-tests branch from 39422d7 to a98eef2 Compare July 16, 2026 16:56
@aditya1702
aditya1702 force-pushed the blend/pr6-integration-tests branch from a98eef2 to 8cc6a07 Compare July 16, 2026 20:07
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.

1 participant