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

Function TestLineageFullFlow

lineage_integration_test.go:152–351  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestLineageFullFlow(t *testing.T) {
153 if testing.Short() {
154 t.Skip("Skipping lineage integration test in short mode")
155 }
156
157 ctx := context.Background()
158 pollInterval := 200 * time.Millisecond
159 pollTimeout := 15 * time.Second
160
161 cnf := &config.Configuration{
162 Redis: config.RedisConfig{
163 Dns: "localhost:6379",
164 },
165 DataSource: config.DataSourceConfig{
166 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
167 },
168 Queue: config.QueueConfig{
169 WebhookQueue: "webhook_queue_test",
170 IndexQueue: "index_queue_test",
171 TransactionQueue: "transaction_queue_test",
172 NumberOfQueues: 1,
173 },
174 Server: config.ServerConfig{
175 SecretKey: "test-secret",
176 },
177 Transaction: config.TransactionConfig{
178 BatchSize: 100,
179 MaxQueueSize: 1000,
180 LockDuration: time.Second * 30,
181 IndexQueuePrefix: "test_index",
182 },
183 }
184 config.ConfigStore.Store(cnf)
185
186 ds, err := database.NewDataSource(cnf)
187 require.NoError(t, err, "Failed to create datasource")
188
189 ledgerforge, err := NewLedgerForge(ds)
190 require.NoError(t, err, "Failed to create LedgerForge instance")
191
192 // Start the lineage outbox processor to process lineage entries asynchronously
193 processor := NewLineageOutboxProcessor(ledgerforge).WithPollInterval(100 * time.Millisecond)
194 processor.Start(ctx)
195 defer processor.Stop()
196
197 suffix := fmt.Sprintf("%d", time.Now().UnixNano())
198
199 identity, err := ds.CreateIdentity(model.Identity{
200 FirstName: fmt.Sprintf("Alice_%s", suffix),
201 LastName: "Smith",
202 Category: "individual",
203 })
204 require.NoError(t, err, "Failed to create identity")
205 t.Logf("Created identity: %s", identity.IdentityID)
206
207 aliceBalance := model.Balance{
208 Currency: "USD",
209 LedgerID: GeneralLedgerID,

Callers

nothing calls this directly

Calls 14

QueueTransactionMethod · 0.95
GetBalanceLineageMethod · 0.95
GetTransactionLineageMethod · 0.95
NewDataSourceFunction · 0.92
NewLedgerForgeFunction · 0.85
pollForLineageMappingsFunction · 0.85
pollForBalanceFunction · 0.85
WithPollIntervalMethod · 0.80
CreateIdentityMethod · 0.65
CreateBalanceMethod · 0.65

Tested by

no test coverage detected