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

Function pollForLineageMappings

lineage_integration_test.go:18–39  ·  view source on GitHub ↗

pollForLineageMappings polls the database until the expected number of lineage mappings appear

(ctx context.Context, ds database.IDataSource, balanceID string, expectedCount int, pollInterval, timeout time.Duration)

Source from the content-addressed store, hash-verified

16
17// pollForLineageMappings polls the database until the expected number of lineage mappings appear
18func pollForLineageMappings(ctx context.Context, ds database.IDataSource, balanceID string, expectedCount int, pollInterval, timeout time.Duration) ([]model.LineageMapping, error) {
19 timeoutCtx, cancel := context.WithTimeout(ctx, timeout)
20 defer cancel()
21
22 ticker := time.NewTicker(pollInterval)
23 defer ticker.Stop()
24
25 for {
26 select {
27 case <-timeoutCtx.Done():
28 return nil, fmt.Errorf("timed out waiting for %d lineage mappings for balance %s: %w", expectedCount, balanceID, timeoutCtx.Err())
29 case <-ticker.C:
30 mappings, err := ds.GetLineageMappings(timeoutCtx, balanceID)
31 if err != nil {
32 continue
33 }
34 if len(mappings) >= expectedCount {
35 return mappings, nil
36 }
37 }
38 }
39}
40
41// pollForBalance polls until the balance reaches the expected value
42func pollForBalance(ctx context.Context, ds database.IDataSource, balanceID string, expectedBalance *big.Int, pollInterval, timeout time.Duration) (*model.Balance, error) {

Callers 6

TestLineageFullFlowFunction · 0.85
TestLineageInflightHoldFunction · 0.85
TestLineageInflightVoidFunction · 0.85

Calls 2

GetLineageMappingsMethod · 0.65
StopMethod · 0.45

Tested by

no test coverage detected