feat: [E2E] Indexer tests — MINT/BURN/TRANSFER events + balance tracking#220
feat: [E2E] Indexer tests — MINT/BURN/TRANSFER events + balance tracking#220dhyaniarun1993 merged 12 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces end-to-end tests for the indexer, adding new Makefile targets, DSL helper functions for event polling, and test suites for mint, burn, and transfer operations. The review feedback identifies potential logic issues in the paginated event polling that could lead to missed events, suggests stricter error handling in test helpers to prevent silent failures, and recommends consolidating duplicate decimal comparison logic across the test packages.
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #220 +/- ##
=======================================
Coverage ? 32.67%
=======================================
Files ? 123
Lines ? 8627
Branches ? 0
=======================================
Hits ? 2819
Misses ? 5558
Partials ? 250
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Switch TestIndexer_BurnEvent_AfterWithdrawal from AnvilAccount1 to AnvilAccount0: the PROMPT token supply is minted entirely to the deployer (Account0) at construction, so Account1 has zero balance and its deposit transaction reverts. MaxPartyEventOffset already guards against stale burn events from other tests via the sinceOffset predicate, so Account0 is safe. Also fatal on last-page fetch failure in MaxPartyEventOffset instead of silently falling back to page1 items, which would return a stale lower ledger_offset and defeat the sinceOffset baseline.
…rawal Common.Types.EvmAddress is defined as: newtype EvmAddress = EvmAddress with value : Text The DAML Ledger API v2 requires newtypes to be submitted as a Record wrapping the inner value; sending a plain ValueText causes COMMAND_PREPROCESSING_FAILED. Adds values.NewtypeValue to the values package and uses it in bridge/encode.go for the evmDestination field.
…IsDepositProcessed package ID - values/decode.go: add NewtypeText to extract inner Text from DAML newtype records (EvmAddress is encoded as a single-field Record, not a plain Text value) - bridge/decode.go: use NewtypeText for evmDestination field decoding; previously values.Text() returned "" causing relayer to send withdrawals to the zero address - bridge/encode.go: remove spurious timestamp field from encodeInitiateWithdrawalArgs; the DAML InitiateWithdrawal choice has no timestamp parameter, causing COMMAND_PREPROCESSING_FAILED - identity/client.go: expose PackageID() on the Identity interface and *Client so callers can retrieve the identity package ID - bridge/client.go: fix IsDepositProcessed to use identity package ID for Common.FingerprintAuth templates (PendingDeposit, DepositReceipt); these templates live in identityPackageID, not bridgePackageID, so the prior code always hit TEMPLATES_OR_INTERFACES_NOT_FOUND and lost idempotency
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces end-to-end tests for the indexer and refactors the bridge client to support a two-step withdrawal process (initiate and process). Key changes include adding the ProcessWithdrawal method to the bridge SDK, making user registration idempotent in the test DSL, and implementing several E2E helper methods for polling ledger events. A logic bug was identified in the WaitForPartyEventMatching helper where pagination logic could cause events on page boundaries to be missed.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the E2E testing infrastructure and the Canton bridge client, notably adding support for processing withdrawals and comprehensive indexer testing. Key improvements include DAML Ledger API v2 newtype support, idempotent user registration in the DSL, and utility methods for seeding test accounts with ETH and tokens. Feedback focuses on optimizing the E2E polling logic to iterate backward through events for accuracy and reducing API overhead, as well as ensuring consistent nil-safety for the identity client within the bridge SDK.
dhyaniarun1993
left a comment
There was a problem hiding this comment.
@sadiq1971 Could you summarise the change done in pkg
Each changes in the pkg was required to pass the e2e tests. Here is the summery -
|
Closes #184
Summary
tests/e2e/tests/indexer/— new test package withinit_test.go,helpers_test.go,mint_burn_test.go,transfer_test.goTestIndexer_MintEvent— allocates a fresh Canton party, mints 5 DEMO directly viaIssuerMint, waits for the indexer to record a MINT event with correct fields. UsesNewIndexerStack(Canton + Indexer only; no bridge needed).TestIndexer_BurnEvent_AfterWithdrawal— deposits 2 PROMPT via the bridge, withdraws 1, verifies the indexer records a BURN event with correctfrom_party_id,external_address, and thatTotalSupplydecreases. UsesNewFullStack.TestIndexer_TransferEvent_AfterAPITransfer— registers two external users, mints 50 DEMO to User1, transfers 10 to User2 via the api-server, verifies TRANSFER event fields and both parties' indexer balances. UsesNewAPIStack.TestIndexer_HolderCount_Updates— verifiesToken.HolderCountincrements on first receipt and decrements when a party's balance returns to zero. UsesNewAPIStack.tests/e2e/devstack/dsl/helpers.go— three new DSL methods:WaitForPartyEvent— polls for first event of given type for a partyWaitForPartyEventMatching— same but with a caller-supplied predicate; fetches the last page (byTotal) each tick so new events are always reachable regardless of prior event countWaitForHolderCount— polls untilGetTokenreports the expectedHolderCountMaxPartyEventOffset— returns the highestledger_offsetcurrently indexed for a(partyID, eventType)pair; used to establish a "since" baseline before triggering an operation, preventing stale events from prior runs matching the predicateamountGTE— switched frombig.Floattobig.Rat(exact arithmetic)tests/e2e/devstack/system/system.go—IndexerSystemgains aDSLfield;APISystemgains anIndexerfield so indexer assertions are available without the full stackMakefile—test-e2e-indexertarget now runs the tests (was a stub)Test plan
make test-e2e-indexerpasses against a running devstackTestIndexer_MintEvent— MINT event recorded with correctevent_type,amount,contract_id,ledger_offset,to_party_idTestIndexer_BurnEvent_AfterWithdrawal— BURN event recorded with correct fields;total_supplydecreases;sinceOffsetpredicate prevents stale-event false positives on re-runs againstAnvilAccount1TestIndexer_TransferEvent_AfterAPITransfer— TRANSFER event recorded; both parties' balances correctTestIndexer_HolderCount_Updates—HolderCountincrements and decrements atomically with balance changes