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

Function TestCommitWorkerFullFlow

transaction_test.go:3928–4092  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3926}
3927
3928func TestCommitWorkerFullFlow(t *testing.T) {
3929 // Skip in short mode
3930 if testing.Short() {
3931 t.Skip("Skipping commit worker test in short mode")
3932 }
3933
3934 ctx := context.Background()
3935 cnf := &config.Configuration{
3936 Redis: config.RedisConfig{
3937 Dns: "localhost:6379",
3938 },
3939 DataSource: config.DataSourceConfig{
3940 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
3941 },
3942 Queue: config.QueueConfig{
3943 WebhookQueue: "webhook_queue_test",
3944 IndexQueue: "index_queue_test",
3945 TransactionQueue: "transaction_queue_test",
3946 NumberOfQueues: 1,
3947 },
3948 Server: config.ServerConfig{
3949 SecretKey: "test-secret",
3950 },
3951 Transaction: config.TransactionConfig{
3952 BatchSize: 100,
3953 MaxQueueSize: 1000,
3954 LockDuration: time.Second * 30,
3955 IndexQueuePrefix: "test_index",
3956 },
3957 }
3958 config.ConfigStore.Store(cnf)
3959
3960 ds, err := database.NewDataSource(cnf)
3961 require.NoError(t, err, "Failed to create datasource")
3962
3963 ledgerforge, err := NewLedgerForge(ds)
3964 require.NoError(t, err, "Failed to create LedgerForge instance")
3965
3966 queueName := fmt.Sprintf("%s_%d", cnf.Queue.TransactionQueue, 1)
3967 cleanupWorker := startTestAsynqWorker(t, cnf, ledgerforge, queueName)
3968 defer cleanupWorker()
3969
3970 // Create test balances with initial amounts of zero
3971 sourceBalance := &model.Balance{
3972 Currency: "USD",
3973 LedgerID: "general_ledger_id",
3974 }
3975 destBalance := &model.Balance{
3976 Currency: "USD",
3977 LedgerID: "general_ledger_id",
3978 }
3979
3980 source, err := ds.CreateBalance(*sourceBalance)
3981 require.NoError(t, err, "Failed to create source balance")
3982
3983 dest, err := ds.CreateBalance(*destBalance)
3984 require.NoError(t, err, "Failed to create destination balance")
3985

Callers

nothing calls this directly

Calls 12

QueueTransactionMethod · 0.95
CommitWorkerMethod · 0.95
NewDataSourceFunction · 0.92
GenerateUUIDWithSuffixFunction · 0.92
NewLedgerForgeFunction · 0.85
startTestAsynqWorkerFunction · 0.85
pollForTransactionStatusFunction · 0.70
CreateBalanceMethod · 0.65
GetBalanceByIDLiteMethod · 0.65
GetTransactionByRefMethod · 0.65
GetTransactionMethod · 0.65
FatalMethod · 0.45

Tested by

no test coverage detected