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

Function setupMockDataSource

transaction_benchmark_test.go:92–109  ·  view source on GitHub ↗

setupMockDataSource creates a mock data source with preset responses for benchmarks

()

Source from the content-addressed store, hash-verified

90
91// setupMockDataSource creates a mock data source with preset responses for benchmarks
92func setupMockDataSource() *mocks.MockDataSource {
93 mockDS := new(mocks.MockDataSource)
94
95 sourceBalance := createTestBalance("source-balance-001", 100000)
96 destBalance := createTestBalance("dest-balance-001", 0)
97
98 mockDS.On("TransactionExistsByRef", mock.Anything, mock.Anything).Return(false, nil)
99 mockDS.On("GetBalanceByIDLite", "source-balance-001").Return(sourceBalance, nil)
100 mockDS.On("GetBalanceByIDLite", "dest-balance-001").Return(destBalance, nil)
101 mockDS.On("GetBalanceByID", mock.Anything, mock.Anything, mock.Anything).Return(sourceBalance, nil)
102 mockDS.On("RecordTransactionWithBalancesAndOutbox", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
103 Return(&model.Transaction{TransactionID: "txn-001", Status: "APPLIED"}, nil)
104 mockDS.On("RecordTransaction", mock.Anything, mock.Anything).
105 Return(&model.Transaction{TransactionID: "txn-001", Status: "QUEUED"}, nil)
106 mockDS.On("GetBalanceMonitors", mock.Anything).Return([]model.BalanceMonitor{}, nil)
107
108 return mockDS
109}
110
111// BenchmarkConfigFetch measures the overhead of calling config.Fetch() repeatedly
112// This represents the OLD approach before our optimization

Callers 1

BenchmarkValidateTxnFunction · 0.85

Calls 1

createTestBalanceFunction · 0.85

Tested by

no test coverage detected