MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / TestInflightTransactionFlowAsyncPolled

Function TestInflightTransactionFlowAsyncPolled

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

Source from the content-addressed store, hash-verified

4824}
4825
4826func TestInflightTransactionFlowAsyncPolled(t *testing.T) {
4827 // Skip in short mode
4828 if testing.Short() {
4829 t.Skip("Skipping inflight async flow test in short mode")
4830 }
4831
4832 ctx := context.Background()
4833 cnf := &config.Configuration{
4834 Redis: config.RedisConfig{
4835 Dns: "localhost:6379",
4836 },
4837 DataSource: config.DataSourceConfig{
4838 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
4839 },
4840 Queue: config.QueueConfig{
4841 WebhookQueue: "webhook_queue_test_inflight_async",
4842 IndexQueue: "index_queue_test_inflight_async",
4843 TransactionQueue: "transaction_queue_test_inflight_async",
4844 NumberOfQueues: 1,
4845 },
4846 Server: config.ServerConfig{
4847 SecretKey: "test-secret-inflight-async",
4848 },
4849 Transaction: config.TransactionConfig{
4850 BatchSize: 100,
4851 MaxQueueSize: 1000,
4852 LockDuration: time.Second * 30,
4853 IndexQueuePrefix: "test_index_inflight_async",
4854 },
4855 }
4856 config.ConfigStore.Store(cnf)
4857
4858 // Construct the specific transaction queue name
4859 transactionQueueName := fmt.Sprintf("%s_%d", cnf.Queue.TransactionQueue, 1)
4860
4861 ds, err := database.NewDataSource(cnf)
4862 require.NoError(t, err, "Failed to create datasource")
4863
4864 ledgerforgeInstance, err := NewLedgerForge(ds)
4865 require.NoError(t, err, "Failed to create LedgerForge instance")
4866
4867 // Start the test Asynq worker
4868 cleanupWorker := startTestAsynqWorker(t, cnf, ledgerforgeInstance, transactionQueueName)
4869 defer cleanupWorker()
4870
4871 txnRef := "txn_" + model.GenerateUUIDWithSuffix("test_inflight_async")
4872
4873 sourceBalance := &model.Balance{Currency: "USD", LedgerID: "general_ledger_id"}
4874 destBalance := &model.Balance{Currency: "USD", LedgerID: "general_ledger_id"}
4875
4876 source, err := ds.CreateBalance(*sourceBalance)
4877 require.NoError(t, err)
4878 dest, err := ds.CreateBalance(*destBalance)
4879 require.NoError(t, err)
4880
4881 txn := &model.Transaction{
4882 Reference: txnRef,
4883 Source: source.BalanceID,

Callers

nothing calls this directly

Calls 10

QueueTransactionMethod · 0.95
NewDataSourceFunction · 0.92
GenerateUUIDWithSuffixFunction · 0.92
NewLedgerForgeFunction · 0.85
startTestAsynqWorkerFunction · 0.85
createQueueCopyFunction · 0.85
pollForTransactionStatusFunction · 0.70
CreateBalanceMethod · 0.65
GetBalanceByIDLiteMethod · 0.65

Tested by

no test coverage detected