Skip to content

Add all test cases to integration tests for indexer - #346

Merged
aditya1702 merged 118 commits into
mainfrom
wbclient
Nov 6, 2025
Merged

Add all test cases to integration tests for indexer#346
aditya1702 merged 118 commits into
mainfrom
wbclient

Conversation

@aditya1702

@aditya1702 aditya1702 commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

What

  • Update fixtures in integration tests to generate transactions with all possible Stellar operations.
  • Add integration tests to assert all state changes that can be generated by wallet backend.

Why

End to end testing of wallet backend indexer

Known limitations

N/A

Issue that this PR addresses

#330 #331

@aditya1702
aditya1702 marked this pull request as ready for review November 3, 2025 16:13

if issuerFlags.IsAuthRequired() {
flags = append(flags, "authorized_flag")
if entryAssetCode == assetCode && entryAssetIssuer == assetIssuer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we remove the null bytes from entryAssetCode but compares against assetCode directly. Do we also need to remove null bytes from assetCode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aristidesstaffieri The assetCode comes from string details from the effects output: https://github.com/stellar/wallet-backend/blob/main/internal/indexer/processors/effects.go#L291.

The entryAssetCode is derived from XDR binary data alphanum4.AssetCode[:], alphanum12.AssetCode[:]. They are fixed length arrays so they have null bytes added at the end for padding. So we have to remove the null bytes to convert the string from USD\x00 to USD

stateChanges = append(stateChanges, p.createStateChange(types.StateChangeCategoryAccount, types.StateChangeReasonCreate, transfer.GetTo(), "", "", builder.Clone().WithFunder(funder)))
case xdr.OperationTypeAccountMerge:
stateChanges = append(stateChanges, p.createStateChange(types.StateChangeCategoryAccount, types.StateChangeReasonMerge, transfer.GetTo(), transfer.GetAmount(), "", builder.Clone()))
stateChanges = append(stateChanges, p.createStateChange(types.StateChangeCategoryAccount, types.StateChangeReasonMerge, transfer.GetTo(), "", "", builder.Clone()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the transfer amount an empty string now?

@aditya1702 aditya1702 Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aristidesstaffieri Hmmm, we are already creating CREDIT/DEBIT state changes for XLM transfers involving the creation and merging of accounts. These separate ACCOUNT CREATE/MERGE are for information purposes so we dont have the amount there

// getTrustlineFlagsFromChanges extracts the trustline flags from transaction changes
func (p *EffectsProcessor) getTrustlineFlagsFromChanges(trustorAddress, assetCode, assetIssuer string, changes []ingest.Change) (xdr.TrustLineFlags, error) {
// Search through changes to find the trustline entry for this specific asset and trustor
for _, change := range changes {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be multiple trustline entries in a list of changes? If so, this returns only the first(which would presumable not be the final state if we had several changes).

@aditya1702 aditya1702 Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aristidesstaffieri These changes are for that particular operation only: https://github.com/stellar/wallet-backend/blob/main/internal/indexer/processors/effects.go#L97. So, technically there wouldnt be any other trustline entries and even if there is, there wouldnt be trustline entry with same asset and trustorAddress

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah gotcha, do you mind adding a comment on why this is ok.

@aditya1702
aditya1702 merged commit 187642f into main Nov 6, 2025
9 checks passed
@aditya1702
aditya1702 deleted the wbclient branch November 6, 2025 20:08
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