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

Function TestLineageInflightCommit

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

Source from the content-addressed store, hash-verified

997}
998
999func TestLineageInflightCommit(t *testing.T) {
1000 if testing.Short() {
1001 t.Skip("Skipping lineage integration test in short mode")
1002 }
1003
1004 ctx := context.Background()
1005
1006 cnf := &config.Configuration{
1007 Redis: config.RedisConfig{
1008 Dns: "localhost:6379",
1009 },
1010 DataSource: config.DataSourceConfig{
1011 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
1012 },
1013 Queue: config.QueueConfig{
1014 WebhookQueue: "webhook_queue_test",
1015 IndexQueue: "index_queue_test",
1016 TransactionQueue: "transaction_queue_test",
1017 NumberOfQueues: 1,
1018 },
1019 Server: config.ServerConfig{
1020 SecretKey: "test-secret",
1021 },
1022 Transaction: config.TransactionConfig{
1023 BatchSize: 100,
1024 MaxQueueSize: 1000,
1025 LockDuration: time.Second * 30,
1026 IndexQueuePrefix: "test_index",
1027 },
1028 }
1029 config.ConfigStore.Store(cnf)
1030
1031 ds, err := database.NewDataSource(cnf)
1032 require.NoError(t, err, "Failed to create datasource")
1033
1034 ledgerforge, err := NewLedgerForge(ds)
1035 require.NoError(t, err, "Failed to create LedgerForge instance")
1036
1037 // Start the lineage outbox processor to process lineage entries asynchronously
1038 processor := NewLineageOutboxProcessor(ledgerforge).WithPollInterval(100 * time.Millisecond)
1039 processor.Start(ctx)
1040 defer processor.Stop()
1041
1042 suffix := fmt.Sprintf("%d", time.Now().UnixNano())
1043
1044 identity, err := ds.CreateIdentity(model.Identity{
1045 FirstName: fmt.Sprintf("Commit_%s", suffix),
1046 LastName: "Test",
1047 Category: "individual",
1048 })
1049 require.NoError(t, err)
1050
1051 balance, err := ds.CreateBalance(model.Balance{
1052 Currency: "USD",
1053 LedgerID: GeneralLedgerID,
1054 IdentityID: identity.IdentityID,
1055 TrackFundLineage: true,
1056 AllocationStrategy: "FIFO",

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected