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

Function TestVoidWorkerFullFlow

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

Source from the content-addressed store, hash-verified

4092}
4093
4094func TestVoidWorkerFullFlow(t *testing.T) {
4095 // Skip in short mode
4096 if testing.Short() {
4097 t.Skip("Skipping void worker test in short mode")
4098 }
4099
4100 ctx := context.Background()
4101 cnf := &config.Configuration{
4102 Redis: config.RedisConfig{
4103 Dns: "localhost:6379",
4104 },
4105 DataSource: config.DataSourceConfig{
4106 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
4107 },
4108 Queue: config.QueueConfig{
4109 WebhookQueue: "webhook_queue_test",
4110 IndexQueue: "index_queue_test",
4111 TransactionQueue: "transaction_queue_test",
4112 NumberOfQueues: 1,
4113 },
4114 Server: config.ServerConfig{
4115 SecretKey: "test-secret",
4116 },
4117 Transaction: config.TransactionConfig{
4118 BatchSize: 100,
4119 MaxQueueSize: 1000,
4120 LockDuration: time.Second * 30,
4121 IndexQueuePrefix: "test_index",
4122 },
4123 }
4124 config.ConfigStore.Store(cnf)
4125
4126 ds, err := database.NewDataSource(cnf)
4127 require.NoError(t, err, "Failed to create datasource")
4128
4129 ledgerforge, err := NewLedgerForge(ds)
4130 require.NoError(t, err, "Failed to create LedgerForge instance")
4131
4132 // Create test balances with initial amounts of zero
4133 sourceBalance := &model.Balance{
4134 Currency: "USD",
4135 LedgerID: "general_ledger_id",
4136 }
4137 destBalance := &model.Balance{
4138 Currency: "USD",
4139 LedgerID: "general_ledger_id",
4140 }
4141
4142 source, err := ds.CreateBalance(*sourceBalance)
4143 require.NoError(t, err, "Failed to create source balance")
4144
4145 dest, err := ds.CreateBalance(*destBalance)
4146 require.NoError(t, err, "Failed to create destination balance")
4147
4148 // Step 1: Create an inflight transaction with skip_queue set to true
4149 txnRef := "txn_" + model.GenerateUUIDWithSuffix("void_flow_test")
4150 txn := &model.Transaction{
4151 Reference: txnRef,

Callers

nothing calls this directly

Calls 11

QueueTransactionMethod · 0.95
VoidWorkerMethod · 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