MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / pollForTransactionFundAllocation

Function pollForTransactionFundAllocation

lineage_integration_test.go:128–150  ·  view source on GitHub ↗

pollForTransactionFundAllocation polls until the transaction has fund allocation metadata populated

(ctx context.Context, ledgerforge *LedgerForge, transactionID string, expectedCount int, pollInterval, timeout time.Duration)

Source from the content-addressed store, hash-verified

126
127// pollForTransactionFundAllocation polls until the transaction has fund allocation metadata populated
128func pollForTransactionFundAllocation(ctx context.Context, ledgerforge *LedgerForge, transactionID string, expectedCount int, pollInterval, timeout time.Duration) (*TransactionLineage, error) {
129 timeoutCtx, cancel := context.WithTimeout(ctx, timeout)
130 defer cancel()
131
132 ticker := time.NewTicker(pollInterval)
133 defer ticker.Stop()
134
135 for {
136 select {
137 case <-timeoutCtx.Done():
138 return nil, fmt.Errorf("timed out waiting for transaction %s to have %d fund allocations: %w",
139 transactionID, expectedCount, timeoutCtx.Err())
140 case <-ticker.C:
141 lineage, err := ledgerforge.GetTransactionLineage(ctx, transactionID)
142 if err != nil {
143 continue
144 }
145 if len(lineage.FundAllocation) >= expectedCount {
146 return lineage, nil
147 }
148 }
149 }
150}
151
152func TestLineageFullFlow(t *testing.T) {
153 if testing.Short() {

Callers 3

TestLineageFullFlowFunction · 0.85

Calls 2

StopMethod · 0.45
GetTransactionLineageMethod · 0.45

Tested by

no test coverage detected