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

Function TestRefundWorkerFullFlow

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

Source from the content-addressed store, hash-verified

4273}
4274
4275func TestRefundWorkerFullFlow(t *testing.T) {
4276 // Skip in short mode
4277 if testing.Short() {
4278 t.Skip("Skipping refund worker test in short mode")
4279 }
4280
4281 ctx := context.Background()
4282 cnf := &config.Configuration{
4283 Redis: config.RedisConfig{
4284 Dns: "localhost:6379",
4285 },
4286 DataSource: config.DataSourceConfig{
4287 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
4288 },
4289 Queue: config.QueueConfig{
4290 WebhookQueue: "webhook_queue_test",
4291 IndexQueue: "index_queue_test",
4292 TransactionQueue: "transaction_queue_test",
4293 NumberOfQueues: 1,
4294 },
4295 Server: config.ServerConfig{
4296 SecretKey: "test-secret",
4297 },
4298 Transaction: config.TransactionConfig{
4299 BatchSize: 100,
4300 MaxQueueSize: 1000,
4301 LockDuration: time.Second * 30,
4302 IndexQueuePrefix: "test_index",
4303 },
4304 }
4305 config.ConfigStore.Store(cnf)
4306
4307 ds, err := database.NewDataSource(cnf)
4308 require.NoError(t, err, "Failed to create datasource")
4309
4310 ledgerforge, err := NewLedgerForge(ds)
4311 require.NoError(t, err, "Failed to create LedgerForge instance")
4312
4313 // Create test balances with initial amounts of zero
4314 sourceBalance := &model.Balance{
4315 Currency: "USD",
4316 LedgerID: "general_ledger_id",
4317 }
4318 destBalance := &model.Balance{
4319 Currency: "USD",
4320 LedgerID: "general_ledger_id",
4321 }
4322
4323 source, err := ds.CreateBalance(*sourceBalance)
4324 require.NoError(t, err, "Failed to create source balance")
4325
4326 dest, err := ds.CreateBalance(*destBalance)
4327 require.NoError(t, err, "Failed to create destination balance")
4328
4329 // Step 1: Create a standard (non-inflight) transaction with skip_queue set to true
4330 txnRef := "txn_" + model.GenerateUUIDWithSuffix("refund_flow_test")
4331 txn := &model.Transaction{
4332 Reference: txnRef,

Callers

nothing calls this directly

Calls 12

QueueTransactionMethod · 0.95
RefundWorkerMethod · 0.95
RejectTransactionMethod · 0.95
NewDataSourceFunction · 0.92
GenerateUUIDWithSuffixFunction · 0.92
NewLedgerForgeFunction · 0.85
CreateBalanceMethod · 0.65
GetBalanceByIDLiteMethod · 0.65
GetTransactionByRefMethod · 0.65
GetTransactionMethod · 0.65
FatalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected