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

Function TestCreateBulkTransactionsInflightAsync

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

Source from the content-addressed store, hash-verified

5656}
5657
5658func TestCreateBulkTransactionsInflightAsync(t *testing.T) {
5659 // Skip in short mode
5660 if testing.Short() {
5661 t.Skip("Skipping bulk inflight transaction test in short mode")
5662 }
5663
5664 ctx := context.Background()
5665 cnf := &config.Configuration{
5666 Redis: config.RedisConfig{
5667 Dns: "localhost:6379",
5668 },
5669 DataSource: config.DataSourceConfig{
5670 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
5671 },
5672 Queue: config.QueueConfig{
5673 WebhookQueue: "webhook_queue_test_bulk_inflight",
5674 IndexQueue: "index_queue_test_bulk_inflight",
5675 TransactionQueue: "transaction_queue_test_bulk_inflight",
5676 NumberOfQueues: 1,
5677 },
5678 Server: config.ServerConfig{
5679 SecretKey: "test-secret",
5680 },
5681 Transaction: config.TransactionConfig{
5682 BatchSize: 100,
5683 MaxQueueSize: 1000,
5684 LockDuration: time.Second * 30,
5685 IndexQueuePrefix: "test_index",
5686 },
5687 }
5688 config.ConfigStore.Store(cnf)
5689
5690 ds, err := database.NewDataSource(cnf)
5691 require.NoError(t, err, "Failed to create datasource")
5692
5693 ledgerforge, err := NewLedgerForge(ds)
5694 require.NoError(t, err, "Failed to create LedgerForge instance")
5695
5696 // Start the test Asynq worker to process inflight transactions
5697 transactionQueueName := fmt.Sprintf("%s_%d", cnf.Queue.TransactionQueue, 1)
5698 cleanupWorker := startTestAsynqWorker(t, cnf, ledgerforge, transactionQueueName)
5699 defer cleanupWorker()
5700
5701 // Create test balances
5702 sourceBalance := &model.Balance{
5703 Currency: "USD",
5704 LedgerID: "general_ledger_id",
5705 }
5706 destBalance1 := &model.Balance{
5707 Currency: "USD",
5708 LedgerID: "general_ledger_id",
5709 }
5710 destBalance2 := &model.Balance{
5711 Currency: "USD",
5712 LedgerID: "general_ledger_id",
5713 }
5714
5715 source, err := ds.CreateBalance(*sourceBalance)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected