-
Notifications
You must be signed in to change notification settings - Fork 117
feat: use test server from go-libs #846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request introduces a comprehensive upgrade to version 3 of the The changes are primarily focused on library version migration and do not fundamentally alter the core functionality of the code. The modifications span test files, storage implementations, API controllers, and utility packages. Key areas of impact include test server initialization, client access logic, and response structure handling. Changes
Sequence DiagramsequenceDiagram
participant Client
participant TestServer
participant DeferredConfig
participant Instrumentation
Client->>TestServer: Initialize with DeferTestServer
TestServer->>DeferredConfig: Retrieve connection options
DeferredConfig-->>TestServer: Return configuration
TestServer->>Instrumentation: Apply instrumentation
Instrumentation-->>TestServer: Configure logging, debug settings
Client->>TestServer: Wait for server readiness
TestServer-->>Client: Server ready
Client->>TestServer: Perform operations
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
e7cd793
to
9eb8988
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
test/e2e/api_accounts_metadata_test.go (1)
30-30
: Discarding the subscription objectBy ignoring the subscription object (
_, events = Subscribe(...)
), the test no longer holds a reference to unsubscribe. Confirm if an ephemeral subscription is intended or consider retaining the subscription to unsubscribe for more controlled resource management.pkg/testserver/utils.go (1)
36-46
:DeferTestWorker
lacks instrumentation options.Unlike
DeferTestServer
, theDeferTestWorker
function doesn't set up any instrumentation. Consider whether worker instances should also have instrumentation for consistency.Consider adding appropriate instrumentation for worker instances:
func DeferTestWorker(debug bool, output io.Writer, configurationProvider func() WorkerConfiguration) *utils.Deferred[*Worker] { return testservice.DeferNew[WorkerConfiguration](cmd.NewRootCommand, func() testservice.Configuration[WorkerConfiguration] { return testservice.Configuration[WorkerConfiguration]{ CommonConfiguration: testservice.CommonConfiguration{ Debug: debug, Output: output, }, Configuration: configurationProvider(), } - }) + }, + testservice.WithLogger(core.GinkgoT()), + testservice.WithInstruments(testservice.WorkerInstrumentation()), // Add appropriate worker instrumentation + ) }pkg/testserver/helpers.go (1)
75-86
: ImprovedSubscribe
function with better return values.The
Subscribe
function now accepts a standardrequire.TestingT
interface and returns both the subscription and a message channel, making it more flexible and useful. The error handling is also improved.However, I notice that there's no automatic cleanup for the NATS connection, which could lead to resource leaks.
Consider adding cleanup for the NATS connection:
func Subscribe(t require.TestingT, server *Server) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) conn, err := nats.Connect(server.GetConfiguration().Configuration.NatsURL) require.NoError(t, err) + + // Add cleanup for the connection + if cleanup, ok := t.(interface{ Cleanup(func()) }); ok { + cleanup.Cleanup(func() { + conn.Close() + }) + } subscription, err := conn.Subscribe(server.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) return subscription, ret }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (27)
pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(13 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/server.go
(2 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(2 hunks)test/e2e/api_accounts_list_test.go
(1 hunks)test/e2e/api_accounts_metadata_test.go
(1 hunks)test/e2e/api_balances_aggregated_test.go
(1 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(1 hunks)test/e2e/api_ledgers_import_test.go
(2 hunks)test/e2e/api_ledgers_list_test.go
(1 hunks)test/e2e/api_ledgers_metadata_test.go
(1 hunks)test/e2e/api_logs_list_test.go
(1 hunks)test/e2e/api_transactions_create_test.go
(3 hunks)test/e2e/api_transactions_list_test.go
(1 hunks)test/e2e/api_transactions_metadata_test.go
(1 hunks)test/e2e/api_transactions_revert_test.go
(2 hunks)test/e2e/api_volumes_test.go
(1 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(2 hunks)test/e2e/app_multiple_instance_test.go
(3 hunks)test/e2e/v1_api_balances_test.go
(2 hunks)test/performance/pkg/write/local_env_test.go
(1 hunks)test/stress/stress_test.go
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (17)
test/e2e/api_accounts_list_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)
pkg/testserver/api.go (4)
pkg/testserver/client.go (1)
Client
(8-12)pkg/client/ledger.go (1)
Ledger
(19-24)pkg/client/v2.go (1)
V2
(19-21)pkg/testserver/server.go (1)
Server
(95-95)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)
test/e2e/api_transactions_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)
test/performance/pkg/write/local_env_test.go (1)
pkg/testserver/server.go (1)
ServeConfiguration
(30-41)
pkg/generate/generator_test.go (4)
pkg/testserver/utils.go (1)
NewTestServer
(28-34)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(16-19)
test/e2e/app_logs_blocks_async_test.go (4)
pkg/testserver/utils.go (2)
DeferTestServer
(11-26)DeferTestWorker
(36-46)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/worker.go (1)
WorkerConfiguration
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(62-73)
test/e2e/api_ledgers_create_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)
test/e2e/app_multiple_instance_test.go (4)
cmd/root.go (1)
NewRootCommand
(24-53)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(29-31)
test/e2e/api_bulk_test.go (4)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/api.go (1)
CreateLedger
(16-19)pkg/testserver/helpers.go (1)
Subscribe
(75-86)
pkg/testserver/client.go (1)
pkg/testserver/server.go (1)
ServeConfiguration
(30-41)
test/e2e/api_accounts_metadata_test.go (3)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/helpers.go (1)
Subscribe
(75-86)
pkg/testserver/server.go (3)
cmd/serve.go (8)
BindFlag
(58-58)AutoUpgradeFlag
(61-61)WorkerEnabledFlag
(67-67)ExperimentalFeaturesFlag
(70-70)BulkMaxSizeFlag
(62-62)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)pkg/testserver/worker.go (1)
WorkerConfiguration
(9-13)cmd/worker.go (1)
WorkerConfiguration
(21-24)
pkg/testserver/utils.go (2)
pkg/testserver/server.go (2)
ServeConfiguration
(30-41)Server
(95-95)pkg/testserver/worker.go (2)
WorkerConfiguration
(9-13)Worker
(28-28)
pkg/testserver/worker.go (2)
pkg/testserver/server.go (1)
PostgresConfiguration
(11-11)cmd/worker.go (1)
WorkerConfiguration
(21-24)
test/e2e/api_ledgers_list_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)
test/e2e/api_transactions_create_test.go (5)
pkg/testserver/utils.go (1)
DeferTestServer
(11-26)pkg/testserver/server.go (2)
ServeConfiguration
(30-41)PostgresConfiguration
(11-11)pkg/testserver/helpers.go (1)
Subscribe
(75-86)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateTransaction
(37-45)
🔇 Additional comments (72)
pkg/testserver/client.go (1)
1-12
: Well-structured client function implementation.This implementation provides a clean abstraction for creating clients from test servers, which will make tests more maintainable and consistent. The function takes a service with appropriate configuration and returns a properly configured client.
test/performance/pkg/write/local_env_test.go (1)
61-61
: Clean migration to ServeConfiguration.The change correctly migrates from the old
Configuration
type to the newServeConfiguration
type, maintaining compatibility with the existing code structure while aligning with the broader refactoring effort across the codebase.test/e2e/api_transactions_list_test.go (1)
32-36
: Improved test server initialization.The change from
NewTestServer
toDeferTestServer
withServeConfiguration
streamlines the test setup. The new implementation correctly uses thePostgresConfiguration
function to convert connection options, and adds the NATS URL configuration.test/e2e/api_ledgers_list_test.go (1)
22-28
: Consistent refactoring to use ServeConfiguration.This change follows the pattern seen in other test files, replacing
NewTestServer
withDeferTestServer
and using the newServeConfiguration
type. The additional parametersMaxPageSize
andDefaultPageSize
are correctly preserved in the new configuration structure.test/stress/stress_test.go (1)
30-35
: Test server initialization updated to use the new APIThe test server initialization has been refactored to use
DeferTestServer
function instead of the previousNewTestServer
. The configuration structure is now flatter, using the newServeConfiguration
type from go-libs.test/e2e/api_ledgers_metadata_test.go (1)
19-23
: Updated test server initialization to use the new APITest server initialization has been refactored to use the
DeferTestServer
function andServeConfiguration
type, which is consistent with the pattern used in other test files. This change simplifies the configuration structure.test/e2e/api_logs_list_test.go (1)
25-29
: Updated test server initialization to use the new APITest server initialization has been refactored to use the
DeferTestServer
function andServeConfiguration
type, matching the pattern used across the codebase. This change ensures a consistent approach to test server configuration.pkg/testserver/api.go (7)
16-19
: Client access refactored to use new utility functionThe code has been updated to use
Client(srv)
instead ofsrv.Client()
, using the new centralized client function. This pattern is consistently applied throughout the file, making client access more uniform.
21-27
: Updated client access methodClient access has been changed to use the centralized
Client(srv)
function, which improves consistency across the codebase.
29-31
: Simplified client access patternUpdated to use the new
Client(srv)
method, which provides a more consistent way to obtain client instances.
33-35
: Consistent client access methodChanged to use the centralized
Client(srv)
function, following the pattern used throughout the file.
37-45
: Updated client access for transaction creationThe method for obtaining a client has been updated to use
Client(srv)
, maintaining the same functionality with a more consistent approach.
47-53
: Refactored client access for bulk operationsClient access has been updated to use the centralized function while maintaining the same error handling and return logic.
55-228
: Consistent update pattern across all API methodsAll remaining functions in the file have been updated to use the
Client(srv)
pattern instead ofsrv.Client()
. The change is applied consistently throughout the file, making client access more uniform while preserving the same business logic and error handling.test/e2e/api_transactions_revert_test.go (2)
29-33
: Test server configuration updated to use DeferTestServer.The test server initialization has been refactored to use
DeferTestServer
with the newServeConfiguration
structure instead of the previousNewTestServer
withConfiguration
. This improves resource management by using a deferred initialization pattern and simplifies the configuration by using direct property assignment.
49-49
: Event subscription simplified.The subscription pattern has been updated to discard the first return value (the subscription object) and only capture the events channel, which aligns with the new pattern used across the test suite.
test/e2e/api_balances_aggregated_test.go (1)
24-28
: Test server configuration updated to use DeferTestServer.The server initialization has been refactored to use
DeferTestServer
with the newServeConfiguration
structure. This simplifies the configuration by directly using thePostgresConfiguration
function to convert connection options, and maintains consistent initialization patterns across test files.test/e2e/api_bulk_test.go (4)
9-9
: Added import for testservice package.The new import for
testservice
is required to support theGetServerURL
function used later in this file, which is part of the refactoring to use the test server from go-libs.
39-45
: Test server configuration updated to use DeferTestServer.The server initialization has been refactored to use
DeferTestServer
with theServeConfiguration
structure, matching the pattern used across the test suite. The BulkMaxSize configuration is preserved in the new structure.
51-51
: Event subscription simplified.The subscription pattern has been updated to discard the first return value (the subscription object) and only capture the events channel, matching the pattern used in other test files.
241-241
: URL construction centralized using testservice.The HTTP request URL construction now uses
testservice.GetServerURL(testServer.GetValue())
instead of directly accessingtestServer.GetValue().URL()
. This provides a more centralized and consistent way to obtain server URLs across the test suite.test/e2e/api_transactions_metadata_test.go (1)
24-28
: Test server configuration updated to use DeferTestServer.The server initialization has been refactored to use
DeferTestServer
with theServeConfiguration
structure, consistent with changes across the test suite. This improves resource management through deferred initialization and simplifies the configuration.test/e2e/api_accounts_list_test.go (1)
29-33
: LGTM: Improved test server configuration.The refactoring to use
DeferTestServer
with a simplerServeConfiguration
structure streamlines the test setup and aligns with the new pattern from go-libs. This approach is more maintainable as it separates the debug/output concerns from the server configuration.test/e2e/api_volumes_test.go (1)
34-37
: LGTM: Consistent refactoring of test server initialization.This change follows the same pattern as in other test files, using
DeferTestServer
with a cleanerServeConfiguration
structure. The configuration correctly maintains the existing functionality while simplifying the structure.test/e2e/api_ledgers_create_test.go (1)
24-29
: LGTM: Standardized test server initialization with experimental features.The change to
DeferTestServer
withServeConfiguration
maintains the importantExperimentalFeatures
flag while adopting the new test server pattern. This provides consistency with other test files while preserving the test-specific configuration.pkg/generate/generator_test.go (5)
10-10
: LGTM: Added required testservice import.Added the necessary import for the new test service functionality.
24-33
: LGTM: Updated test server initialization pattern.The test server initialization has been refactored to use the new
NewTestServer
function with proper configuration. This provides better consistency with the rest of the codebase and leverages the structured approach of the test service library.
34-34
: LGTM: Updated server start method with proper context.The server start method now correctly uses the testing context created earlier in the test.
39-39
: LGTM: Updated client access pattern.Changed from the method-style client access to the new function-based pattern
Client(testServer)
, which aligns with the new implementation in pkg/testserver/client.go.
55-55
: LGTM: Consistent client access update.Updated the client access in the action application to use the same
Client(testServer)
pattern as earlier in the file.test/e2e/app_multiple_instance_test.go (6)
8-9
: Imports look good.These new imports for
testservice
andcmd
align well with the refactoring to a more modular test server design.
39-50
: New test server instantiation is clear.Using
testservice.New
with a typed configuration and the ledger root command not only simplifies server initialization but also keeps the test setup consistent across the codebase. No issues here.
52-55
: Instrumentation addition is beneficial.Applying HTTP server instrumentation via
testservice.WithInstruments
is a tidy way to collect test metrics and diagnostics.
56-56
: Server startup verification is correct.Ensuring the server starts successfully via Ginkgo’s
Expect
pattern is a robust approach.
58-58
: Concurrent server collection is fine.Sending the test server to a channel is a straightforward concurrency pattern. No issues detected.
73-73
: Client access approach updated properly.Switching to
Client(server).Ledger.GetInfo(ctx)
conforms to the new test client structure. This is consistent and clear.pkg/testserver/server.go (6)
6-7
: Imports are aligned with the new architecture.Incorporating the
publish
andtestservice
packages aligns with the overall refactoring toward a more generic test-service approach.
11-11
: Type alias for PostgresConfiguration is concise.Aliasing
bunconnect.ConnectionOptions
makes it easy to expand or adjust database connection behavior without duplicating logic.
13-28
: CLI argument generation appears correct.This function neatly transforms connection options into CLI flags. The approach is sound and maintainable.
30-41
: ServeConfiguration struct is well-structured.All relevant fields for serving the application are encapsulated, including NATS URL and experimental feature flags.
43-93
: Flag building logic is thorough.Generating command-line flags based on the
ServeConfiguration
fields is clear and adjustable. No issues noted.
95-95
: Server type alias improves readability.Using
type Server = testservice.Service[ServeConfiguration]
avoids repetition and leverages the existing test service code.test/e2e/api_ledgers_import_test.go (2)
27-33
: Switch to DeferTestServer is consistent.Creating the server via
DeferTestServer
with a directServeConfiguration
consolidates setup and cleanup while maintaining clarity.
334-334
: Database connection updated appropriately.Invoking
ConnectToDatabase
with the new context approach ensures consistent logging and potential cancellation handling in tests.test/e2e/app_logs_blocks_async_test.go (4)
31-35
: Refactor: Switch to DeferTestServer for improved resource managementUsing
DeferTestServer
ensures that the server setup and teardown are managed more cleanly within tests, aligning with the new ServeConfiguration approach and promoting maintainability.
38-42
: Refactor: Adopt DeferTestWorker for worker setupDeferring the worker creation provides consistent initialization and teardown for the background process. This is congruent with the overall shift toward a unified configuration pattern.
83-83
: ConnectToDatabase usage promotes consistent cleanupReplacing direct database calls with
ConnectToDatabase
integrates automatic cleanup and error handling, reducing boilerplate and potential resource leaks.
86-86
: Database query with NewSelect looks correctUsing bun’s
db.NewSelect().Model(&ret).ModelTableExpr("_default.logs_blocks").Scan(ctx)
is a clear approach to database querying. Looks good and matches bun’s typical usage patterns.test/e2e/api_accounts_metadata_test.go (1)
22-25
: Refactor: Use DeferTestServerTransitioning to
DeferTestServer
is consistent with the new configuration model and helps unify server setup across tests.pkg/testserver/worker.go (5)
4-4
: Added import for testserviceImporting
testservice
supports the new approach to deferring service creation. This change is aligned with the broader refactoring.
6-6
: Added import for strconvRequired for converting integer configuration fields to string arguments. This is straightforward and necessary for command-line flags.
10-10
: WorkerConfiguration now includes PostgresConfigurationIncorporating the database configuration at the worker level unifies the approach to database connectivity and aligns with the new Serve/Worker configuration patterns.
15-17
: Implementing GetArgs for worker processAppending base flags and database arguments in
GetArgs()
is a neat way to generate all necessary command-line flags at once. This approach is both flexible and extensible if more flags are needed later.
28-28
: Type alias Worker = testservice.Service[WorkerConfiguration]Using a type alias simplifies the code, reduces duplication, and promotes a consistent configuration paradigm across server and worker services.
test/e2e/v1_api_balances_test.go (2)
25-30
: Updated test server initialization to useDeferTestServer
.The code has been refactored to use the new
DeferTestServer
function from the testserver package, replacing the previousNewTestServer
approach. The configuration structure has been simplified from nestedConfiguration
to a flatterServeConfiguration
.
75-76
: Client access pattern updated.The client access pattern has been changed from
testServer.GetValue().Client().Ledger.V1.GetBalances
toClient(testServer.GetValue()).Ledger.V1.GetBalances
. This aligns with the new pattern established in the testserver package.pkg/testserver/utils.go (2)
11-26
: Well-structured implementation ofDeferTestServer
.The
DeferTestServer
function provides a clean abstraction for creating a deferred test server with appropriate configuration and instrumentation. It properly wraps the underlyingtestservice.DeferNew
function and adds useful defaults like HTTP server instrumentation.
28-34
: Clean implementation ofNewTestServer
.This function provides a clean way to create a test server with custom configuration and options. The HTTP server instrumentation is automatically added to the provided options.
test/e2e/api_transactions_create_test.go (3)
38-44
: Updated test server initialization to useDeferTestServer
.The code has been refactored to use the new
DeferTestServer
function from the testserver package, replacing the previousNewTestServer
approach. The configuration structure has been simplified toServeConfiguration
while maintaining all necessary properties.
576-577
: Client access pattern updated.The client access pattern has been changed from
testServer.GetValue().Client().Ledger.V1.CreateTransaction
toClient(testServer.GetValue()).Ledger.V1.CreateTransaction
. This aligns with the new pattern established in the testserver package.
67-67
:✅ Verification successful
Updated Subscribe usage pattern.
The
Subscribe
function now returns both a subscription and a channel, with the code now specifically capturing only the channel and discarding the subscription. This aligns with the updatedSubscribe
function signature in the helpers.go file.Verify that discarding the subscription doesn't lead to resource leaks:
🏁 Script executed:
#!/bin/bash # Search for all instances of Subscribe usage to see if any files are properly handling subscription cleanup # Check for instances where subscription is captured but not cleaned up rg -A 5 "^[^/]*_, \w+ = Subscribe\(" --glob "test/**/*.go" # Check for instances where subscription is directly captured and look for cleanup rg -A 10 "^[^/]*\w+, \w+ = Subscribe\(" --glob "test/**/*.go"Length of output: 5962
Resource Leak Verification – Discarding the Subscription Is Safe
The grep results confirm that using
_, events = Subscribe(GinkgoT(), testServer.GetValue())
is the common pattern across tests. This update aligns with the newSubscribe
signature in helpers.go, where only the channel is needed while the subscription is disposed of internally. No evidence of resource leaks was detected from our search, suggesting that the design handles cleanup without explicit disposal in the test code.pkg/testserver/helpers.go (1)
62-73
: ImprovedConnectToDatabase
with context support.The
ConnectToDatabase
function has been enhanced to accept a context parameter for better control over database operations. It now also properly handles database connections usingbunconnect.OpenSQLDB
and ensures clean resource management through the cleanup function.test/e2e/app_lifecycle_test.go (10)
13-13
: New import reflects the refactoring to use go-libs.The addition of the testservice package from go-libs supports the migration from the local test server implementation to the shared library one.
39-45
: Test server initialization approach updated.The initialization has been refactored from
NewTestServer
toDeferTestServer
with the newServeConfiguration
type, which is part of the migration to use the test server from go-libs.
50-50
: Updated Subscribe function call.The Subscribe function now receives the test server value from GetValue(), which aligns with the new go-libs approach.
55-55
: Improved client access using Client helper.Instead of directly accessing the test server, the code now uses the
Client()
helper function, which provides a more consistent and encapsulated way to interact with the server.
81-81
: Context-aware database connection.The
ConnectToDatabase
function now properly accepts a context as its first parameter, improving context propagation throughout the test.
138-143
: Explicit server lifecycle management.The server restart has been replaced with explicit Stop and Start operations, with a proper timeout context for the stop operation. This provides better control over the server lifecycle.
200-205
: Consistent test server configuration pattern.The second test server instance has been refactored using the same pattern as the first one, ensuring consistency across the test suite.
242-246
: Consistent test server configuration pattern.The third test server instance follows the same refactored pattern, maintaining consistency throughout the test file.
264-264
: Context-aware database connection.Similar to the previous database connection, this one now correctly passes the context as the first parameter.
282-282
: Improved server URL access.Using
testservice.GetServerURL()
instead of direct access to the server URL provides better encapsulation and is consistent with the go-libs approach.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #846 +/- ##
==========================================
- Coverage 82.48% 82.14% -0.34%
==========================================
Files 140 140
Lines 7595 7596 +1
==========================================
- Hits 6265 6240 -25
- Misses 1015 1039 +24
- Partials 315 317 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
test/e2e/api_accounts_list_test.go (1)
9-12
: Avoid '.' imports for better clarity.
While not incorrect, using a dot import can overshadow standard library functions and reduce code clarity. Consider importing under a named alias if needed.test/e2e/api_bulk_test.go (2)
9-12
: Move away from dot imports for clarity.
Dot imports can hide potential name collisions and hamper readability. Prefer a named import for testing utilities.
58-58
: Consider storing the subscription to manage lifecycle.
Currently the first return value ofSubscribe
is discarded. If unsubscribing or tracking is needed, saving the subscription in a variable is recommended to avoid potential resource leaks.- _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) + subscription, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) // subscription.Unsubscribe() // perhaps during teardowntest/e2e/api_balances_aggregated_test.go (1)
8-10
: Dot imports can reduce clarity.
Rather than dot-importing testing utilities, consider a named alias to improve legibility and avoid overshadowing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
docker-compose.yml
is excluded by!**/*.yml
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (47)
deployments/pulumi/pkg/provision/component.go
(2 hunks)deployments/pulumi/pkg/provision/configmap.go
(1 hunks)internal/api/bulking/mocks_ledger_controller_test.go
(0 hunks)internal/api/common/mocks_ledger_controller_test.go
(0 hunks)internal/api/common/mocks_system_controller_test.go
(0 hunks)internal/api/v1/mocks_ledger_controller_test.go
(0 hunks)internal/api/v1/mocks_system_controller_test.go
(0 hunks)internal/api/v2/mocks_ledger_controller_test.go
(0 hunks)internal/api/v2/mocks_system_controller_test.go
(0 hunks)internal/controller/ledger/controller_generated_test.go
(0 hunks)internal/controller/ledger/controller_with_too_many_client_handling_generated_test.go
(0 hunks)internal/controller/ledger/listener_generated_test.go
(0 hunks)internal/controller/ledger/mocks_test.go
(0 hunks)internal/controller/ledger/numscript_parser_generated_test.go
(0 hunks)internal/controller/ledger/numscript_runtime_generated_test.go
(0 hunks)internal/controller/ledger/store_generated_test.go
(0 hunks)internal/storage/driver/buckets_generated_test.go
(0 hunks)internal/storage/driver/ledger_generated_test.go
(0 hunks)internal/storage/driver/system_generated_test.go
(0 hunks)pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(14 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(2 hunks)test/e2e/api_accounts_metadata_test.go
(2 hunks)test/e2e/api_balances_aggregated_test.go
(2 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(2 hunks)test/e2e/api_ledgers_import_test.go
(3 hunks)test/e2e/api_ledgers_list_test.go
(2 hunks)test/e2e/api_ledgers_metadata_test.go
(2 hunks)test/e2e/api_logs_list_test.go
(2 hunks)test/e2e/api_transactions_create_test.go
(4 hunks)test/e2e/api_transactions_list_test.go
(2 hunks)test/e2e/api_transactions_metadata_test.go
(2 hunks)test/e2e/api_transactions_revert_test.go
(3 hunks)test/e2e/api_volumes_test.go
(2 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(4 hunks)test/e2e/app_multiple_instance_test.go
(4 hunks)test/e2e/v1_api_balances_test.go
(3 hunks)test/performance/pkg/write/local_env_test.go
(1 hunks)test/stress/stress_test.go
(2 hunks)
💤 Files with no reviewable changes (17)
- internal/storage/driver/buckets_generated_test.go
- internal/controller/ledger/controller_generated_test.go
- internal/api/v1/mocks_system_controller_test.go
- internal/controller/ledger/listener_generated_test.go
- internal/api/v2/mocks_ledger_controller_test.go
- internal/api/common/mocks_system_controller_test.go
- internal/storage/driver/system_generated_test.go
- internal/controller/ledger/store_generated_test.go
- internal/api/bulking/mocks_ledger_controller_test.go
- internal/storage/driver/ledger_generated_test.go
- internal/controller/ledger/numscript_parser_generated_test.go
- internal/api/common/mocks_ledger_controller_test.go
- internal/api/v2/mocks_system_controller_test.go
- internal/api/v1/mocks_ledger_controller_test.go
- internal/controller/ledger/numscript_runtime_generated_test.go
- internal/controller/ledger/controller_with_too_many_client_handling_generated_test.go
- internal/controller/ledger/mocks_test.go
🚧 Files skipped from review as they are similar to previous changes (6)
- pkg/testserver/client.go
- test/e2e/api_volumes_test.go
- test/performance/pkg/write/local_env_test.go
- test/e2e/api_transactions_revert_test.go
- test/e2e/app_multiple_instance_test.go
- pkg/testserver/api.go
🧰 Additional context used
🧬 Code Definitions (19)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_bulk_test.go (3)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/api.go (1)
CreateLedger
(17-20)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_balances_aggregated_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/app_logs_blocks_async_test.go (4)
pkg/testserver/utils.go (2)
DeferTestServer
(18-25)DeferTestWorker
(36-46)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)pkg/testserver/worker.go (2)
LogsHashBlockCRONSpecInstrumentation
(15-19)LogsHashBlockMaxSizeInstrumentation
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/e2e/api_transactions_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_import_test.go (4)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/e2e/api_ledgers_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/generate/generator_test.go (3)
pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(17-20)
test/e2e/api_accounts_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_ledgers_list_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (2)
MaxPageSizeInstrumentation
(21-25)DefaultPageSizeInstrumentation
(27-31)
test/e2e/api_accounts_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/server.go (1)
cmd/serve.go (4)
ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/api_ledgers_create_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_transactions_create_test.go (5)
pkg/testserver/server.go (1)
ExperimentalNumscriptRewriteInstrumentation
(15-19)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateTransaction
(38-46)
test/e2e/api_transactions_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
test/e2e/app_lifecycle_test.go (5)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (2)
Subscribe
(77-88)ConnectToDatabase
(64-75)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(30-32)test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)
test/e2e/v1_api_balances_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/client.go (1)
Client
(8-12)
test/e2e/api_logs_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Tests
🔇 Additional comments (78)
deployments/pulumi/pkg/provision/configmap.go (1)
37-37
: Configuration file reference updated to versioned formatThe key in the ConfigMap's Data field has been updated from "config.yaml" to "config-v2.1.yaml" to use the versioned configuration filename. This change aligns with similar updates in component.go.
deployments/pulumi/pkg/provision/component.go (2)
119-120
: Updated configuration file reference to versioned formatThe configuration file path in the container arguments has been updated from "/config.yaml" to "/config-v2.1.yaml" to use the versioned configuration file.
138-140
: Updated volume mount paths to versioned formatThe mount path and subpath have been updated to reference the versioned configuration file "config-v2.1.yaml", maintaining consistency with the other configuration reference changes.
pkg/testserver/matchers.go (2)
10-10
: Added import for testservice package.The import for the
testservice
package has been added to support the refactoring from theServer
type to thetestservice.Service
type.
25-27
: Updated type assertion to use testservice.Service.The type assertion and corresponding error message have been updated to use
*testservice.Service
instead of*Server
, which aligns with the PR objective of refactoring to use the test server from go-libs.#!/bin/bash # Verify that other references to Server type have been updated throughout the codebase rg '\*Server' --type gotest/e2e/api_transactions_list_test.go (2)
11-13
: Added imports for test-related packages.The imports from go-libs testing packages have been added to support the new test server initialization approach.
35-42
: Refactored test server initialization.The test server initialization has been refactored to use
DeferTestServer
instead of directly instantiating a configuration structure. This approach:
- Uses
DeferMapDeferred
to obtain connection options from the database- Configures instrumentation with
testservice.WithInstruments
- Adds logging with
testservice.WithLogger
The change is consistent with the PR objective of using the test server from go-libs.
test/e2e/api_logs_list_test.go (2)
9-11
: Added imports for test-related packages.The imports from go-libs testing packages have been added to support the new test server initialization approach.
28-35
: Refactored test server initialization.The test server initialization has been refactored to use
DeferTestServer
instead of directly instantiating a configuration structure. This approach follows the same pattern as in other test files:
- Uses
DeferMapDeferred
to obtain connection options from the database- Configures instrumentation with
testservice.WithInstruments
- Adds logging with
testservice.WithLogger
The change is consistent with the PR objective of using the test server from go-libs.
test/stress/stress_test.go (2)
7-8
: Added imports for test-related packages.The imports from go-libs testing packages have been added to support the new test server initialization approach.
32-37
:❓ Verification inconclusive
Refactored test server initialization for stress tests.
The test server initialization has been refactored to use
DeferTestServer
, consistent with other test files. However, unlike the other test files, this implementation:
- Only includes the experimental features instrumentation
- Does not include logging configuration with
testservice.WithLogger
Consider whether logging should be consistently applied across all test files.
🏁 Script executed:
#!/bin/bash # Check if other stress test files include logger configuration rg "WithLogger" --type go test/stress/Length of output: 38
Action: Verify Consistent Logging in Test Server Initialization
The refactored initialization in
test/stress/stress_test.go
(lines 32–37) now usesDeferTestServer
with only the experimental instrumentation:testServer := DeferTestServer( DeferMapDeferred(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( ExperimentalFeaturesInstrumentation(), ), )In contrast, other test files appear to include additional logging configuration using
testservice.WithLogger
. However, a search for"WithLogger"
in thetest/stress/
directory produced no results, which leaves us with low-confidence evidence on whether this logging configuration is applied elsewhere in our tests.Please manually verify:
- Whether test files outside of
test/stress/
usetestservice.WithLogger
with their test server initialization.- If consistent logging is desired across all test files, consider adding
testservice.WithLogger
to this initialization.test/e2e/api_ledgers_list_test.go (3)
9-11
: Good addition of go-libs testing importsThe imports from go-libs testing packages follow the PR's objective to use test server from go-libs.
25-34
: Well-structured test server initializationThe refactoring from direct instantiation to
DeferTestServer
improves code modularity and follows a consistent pattern. The use of testservice instrumentation for debug, output, and page size configuration is clear and maintainable.
36-36
: Increased test coverage with more ledgersThe test has been updated to create 20 ledgers instead of 10, which provides more thorough test coverage.
test/e2e/api_ledgers_metadata_test.go (2)
7-9
: Good addition of go-libs testing importsThe addition of go-libs testing packages is consistent with the PR objective.
22-29
: Clean server initialization with DeferTestServerThe migration from the previous implementation to
DeferTestServer
enhances code clarity and maintainability. The modular approach with separated instrumentation is well-structured.test/e2e/api_transactions_metadata_test.go (2)
8-10
: Good addition of go-libs testing importsThe updated imports align with the PR's objective to use the test server from go-libs.
27-34
: Well-structured test server initializationThe refactoring to
DeferTestServer
with clear instrumentation options improves code organization and follows the same pattern as other files in this PR.test/e2e/app_logs_blocks_async_test.go (5)
9-11
: Good addition of go-libs testing importsThe imported packages from go-libs testing modules align with the PR's goal.
24-26
: Cleaner variable initializationExtracting
connectionOptions
as a separate variable that's derived from the database improves code readability and reduces duplication in the test server and worker initialization.
35-43
: Well-structured test server initializationThe implementation using
DeferTestServer
with appropriate instrumentation options, including experimental features, is clean and follows a consistent pattern.
45-48
: Good worker configurationUsing
DeferTestWorker
with specific CRON specification and max block size instrumentation provides a clean way to configure the worker component for testing.
87-87
: Improved database connection handlingUsing
ConnectToDatabase
instead of directly accessing the database through the test server simplifies error handling and follows the new pattern established in this PR.test/e2e/api_accounts_list_test.go (1)
33-41
: Good use of the new deferred test server setup.
This streamlined approach withDeferTestServer
and modular instrumentation aligns well with the PR objectives. Implementation looks correct.test/e2e/api_bulk_test.go (3)
40-41
: Deferred mapping for NATS URL is consistent with new architecture.
DeferringnatsURL
ensures it's only retrieved when needed, improving test setup simplicity.
43-50
: Initialization of test server is well-structured.
The refactor toDeferTestServer
with instrumentation is an improvement, simplifying test configuration.
248-248
: Usingtestservice.GetServerURL
enhances consistency.
Centralizing how the request URL is constructed helps maintain uniform test code. No issues identified.test/e2e/api_balances_aggregated_test.go (1)
27-34
: Deferred test server setup looks solid.
Transitioning toDeferTestServer
aligns with the new approach and simplifies configuration. Implementation appears correct.test/e2e/api_ledgers_import_test.go (4)
10-12
: Good update to the imports for test infrastructure.The new imports appropriately reflect the updated testing infrastructure from go-libs, including platform-specific testing utilities for Postgres and the more generic test service framework.
26-29
: Clean refactoring of test setup variables.The new approach using
UseTemplatedDatabase()
,logging.TestingContext()
, andDeferMapDeferred
creates a more structured and maintainable test setup. This pattern follows go-libs best practices for test resource management.
31-39
: Improved server initialization using DeferTestServer.The refactoring replaces custom server configuration with the standardized
DeferTestServer
approach from go-libs. This improves consistency and maintainability by:
- Centralizing connection options handling
- Using the testservice instrumentation framework for logging and debugging
- Properly configuring experimental features
This change aligns with the PR's objective to use the test server from go-libs.
341-341
: Updated database connection with proper context.The database connection now correctly uses the logging context created at the beginning of the test, improving context propagation throughout the test.
pkg/generate/generator_test.go (4)
10-11
: Good update to the imports for testservice framework.The updated imports appropriately include the test service framework and utilities from go-libs.
25-33
: Improved test server setup with NewTestServer.The refactoring replaces direct server instantiation with the
NewTestServer
function from go-libs. This provides:
- Cleaner connection options handling with
NewDeferredWithValue
- Proper test logger configuration
- Standardized instrumentation setup
This implementation follows the go-libs pattern for test service setup.
39-39
: Updated client access pattern.Changed from using a method on the server to the standalone
Client()
function. This is consistent with the new pattern used throughout the codebase and provides a more functional approach to client access.
55-55
: Consistent client access pattern.The action application is now using the same
Client()
function pattern, maintaining consistency across the test file.test/e2e/api_ledgers_create_test.go (3)
9-12
: Good update to the imports for test infrastructure.The updated imports correctly include platform-specific testing tools for both Postgres and NATS, along with the general test service framework.
24-27
: Clean refactoring of test setup variables.The new setup cleanly initializes the database, context, and NATS URL using deferred patterns from go-libs. The use of
DeferMapDeferred
for the NATS URL extraction is particularly elegant.
29-38
: Improved server initialization with DeferTestServer.The refactoring replaces the custom server configuration with the standardized
DeferTestServer
approach. This implementation:
- Properly configures Postgres connection options
- Sets up multiple instrumentation functions including NATS, debug output, and experimental features
- Configures the logger with GinkgoT
This change aligns with the PR objective to use test server from go-libs and improves the maintainability of the test.
test/e2e/v1_api_balances_test.go (3)
9-11
: Good update to the imports for test infrastructure.The updated imports correctly include the platform-specific testing utilities for Postgres and the test service framework, enabling the refactored server initialization.
28-35
: Improved server initialization with DeferTestServer.The refactoring replaces custom server configuration with the standardized
DeferTestServer
approach. This implementation:
- Uses connection options from the Postgres database
- Configures debug and output instrumentation
- Sets up proper logging
This change aligns with the PR objective to use test server from go-libs.
80-80
: Updated client access pattern.Changed from using a method directly on the server to the standalone
Client()
function. This is consistent with the new pattern used throughout the codebase and provides a more functional approach to client access.pkg/testserver/worker.go (4)
4-4
: Import aligns with testservice usage.
No issues with this addition.
6-6
: Import for numeric conversion is appropriate.
This is correctly used to convert integer values to strings.
9-11
: Instrumentation for max block size.
This function effectively appends the correct CLI flag using the provided size parameter.
15-17
: Instrumentation for CRON spec.
Similar pattern as above, cleanly appends the CRON schedule flag.Also applies to: 19-19
test/e2e/api_accounts_metadata_test.go (4)
7-10
: New imports for testing infrastructure.
These imports align with the deferred test server approach.
24-24
: Deferred mapping of NATS URL.
Consistent usage of “MapDeferred” for asynchronous test setup.
27-35
: DeferTestServer usage.
Adopting DeferTestServer simplifies the test configuration and ensures composable initialization.
38-38
: Captured only the events channel.
Discarding the subscription object is acceptable if not needed in the tests.test/e2e/api_transactions_create_test.go (7)
6-9
: New imports for test setup and instrumentation.
All additions follow the updated testing paradigm.
39-41
: Deferred db and NATS URL setup.
Good practice to keep database and message bus connections lazy and configurable.
43-46
: Instrumentation array creation.
Collecting instrumentation in a slice improves readability and flexibility.
48-49
: Conditionally appending numscript rewrite.
This is a clear and concise way to toggle experimental features.
51-54
: DeferTestServer for streamlined test environment.
Matches the refactoring to a more modular and composable testing approach.
78-78
: Subscribe call returns events channel.
Appropriate to ignore the subscription when the test only checks the channel events.
600-600
: Use of Client(testServer.GetValue()).Ledger.V1.
This updated pattern provides a cleaner way to interact with the ledger client.pkg/testserver/server.go (5)
5-5
: LGTM: Appropriate import for the testservice package.The switch to using the go-libs testing/testservice package aligns with the PR objective of using test server from go-libs.
9-13
: Well-structured instrumentation function for experimental features.This implementation provides a clean way to append the experimental features flag to the test service configuration.
15-19
: Well-structured instrumentation function for numscript rewrite feature.This implementation correctly enables the experimental numscript interpreter flag for testing.
21-25
: Well-structured implementation for max page size configuration.The function properly converts the provided size to a string and appends it to the command arguments.
27-31
: Well-structured implementation for default page size configuration.The function properly converts the provided size to a string and appends it to the command arguments.
pkg/testserver/utils.go (4)
10-16
: Well-organized test server options function.This function nicely encapsulates the common options needed for test server initialization, including HTTP server setup and PostgreSQL configuration.
18-25
: LGTM: Clean implementation of deferred test server creation.The function properly combines the provided PostgreSQL connection options with any additional options, facilitating easy test server setup.
27-34
: LGTM: Non-deferred test server creation implementation.This provides a synchronous alternative to DeferTestServer when immediate initialization is needed rather than deferred.
36-46
: LGTM: Well-structured worker initialization.The function correctly sets up a worker with appropriate instrumentation and PostgreSQL connection options.
pkg/testserver/helpers.go (3)
3-16
: Appropriate import updates for the refactored code.The imports have been properly updated to accommodate the new function signatures and dependencies.
64-75
: Well-refactored database connection function.The updated function signature with context and interface constraints provides better flexibility and error handling. The database cleanup is properly implemented to ensure resources are released.
77-88
: Improved subscription function with better return values.The refactored function now returns both the subscription object and the message channel, giving callers more control over the subscription lifecycle.
test/e2e/app_lifecycle_test.go (9)
41-56
: Clean implementation of the new test server initialization pattern.The code properly uses DeferMapDeferred to handle connection options and NATS URL, and creates the test server with appropriate instrumentation.
60-60
: Updated Subscribe call to match new function signature.The call correctly passes the required parameters to the refactored Subscribe function.
65-65
: Updated client access using the new Client function.This replaces direct client creation with the new modular approach from the testservice package.
91-91
: Updated database connection with context parameter.The code correctly passes the context to the refactored ConnectToDatabase function.
148-153
: Explicit server lifecycle management.The code now explicitly stops and starts the server instead of using Restart, which provides clearer control over the server lifecycle.
210-217
: Consistent use of the new test server initialization pattern.This follows the same pattern established earlier in the file, maintaining consistency in how test servers are created.
250-262
: Consistent test server initialization in another test context.The pattern is consistently applied throughout the file, which is good practice.
279-279
: Updated database connection call with context.The call correctly passes the context to the refactored ConnectToDatabase function.
297-297
: Updated URL retrieval for health check.The code now uses testservice.GetServerURL to get the server URL, which is more consistent with the new approach.
455c2b7
to
b072208
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (8)
pkg/generate/generator_test.go (1)
31-31
: Consider extracting debug flag to a constant or configuration.Direct access to environment variables in the code can make testing harder and reduce maintainability.
- testservice.DebugInstrumentation(os.Getenv("DEBUG") == "true"), + testservice.DebugInstrumentation(isDebugEnabled()),And add a helper function:
func isDebugEnabled() bool { return os.Getenv("DEBUG") == "true" }test/e2e/v1_api_balances_test.go (1)
9-11
: Avoid using dot imports in tests.
Usingimport . "github.com/formancehq/go-libs/v2/testing/utils"
can lead to namespace collisions. It’s generally clearer to import with a named or aliased import rather than a dot import.- . "github.com/formancehq/go-libs/v2/testing/utils" + utils "github.com/formancehq/go-libs/v2/testing/utils"test/e2e/api_accounts_metadata_test.go (2)
7-10
: Avoid dot imports and check for import clarity.
Usingimport . "github.com/formancehq/go-libs/v2/testing/utils"
can reduce clarity and hide which methods are being called. Prefer a named import to enhance readability and maintainability.- . "github.com/formancehq/go-libs/v2/testing/utils" + utils "github.com/formancehq/go-libs/v2/testing/utils"
38-38
: Consider unsubscribing from the subscription.
Currently, you discard the subscription object and only keepevents
. If unsubscribing is desired at test teardown, consider storing the subscription for a graceful cleanup.test/performance/pkg/write/local_env_test.go (1)
10-11
: Use named imports.
Avoid polluting the namespace with. "github.com/formancehq/go-libs/v2/testing/utils"
. Although this is test code, a named import clarifies usage.- . "github.com/formancehq/go-libs/v2/testing/utils" + utils "github.com/formancehq/go-libs/v2/testing/utils"pkg/testserver/utils.go (1)
36-46
: Consider consistency betweenDeferTestServer
andDeferTestWorker
The worker variant mostly duplicates the server code with a different command (“worker”). This is acceptable; just ensure that both are updated together to avoid drift. Otherwise, the approach is consistent and looks good.pkg/testserver/helpers.go (1)
77-88
: Potential resource cleanup forSubscribe
The subscription and NATS connection can remain open indefinitely. In ephemeral test scenarios, this might be fine, but consider adding a cleanup step if your tests are numerous or have a long lifetime.func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *utils.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) conn, err := nats.Connect(natsURL.GetValue()) require.NoError(t, err) subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, subscription.Unsubscribe()) + conn.Close() + }) return subscription, ret }test/e2e/app_lifecycle_test.go (1)
41-44
: Deferred approach to database connection
Mapping the templated database to abunconnect.ConnectionOptions
is a neat solution. You might also consider specifying connection pooling or timeouts if the concurrency is high.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
docker-compose.yml
is excluded by!**/*.yml
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (28)
pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(14 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(2 hunks)test/e2e/api_accounts_metadata_test.go
(2 hunks)test/e2e/api_balances_aggregated_test.go
(2 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(2 hunks)test/e2e/api_ledgers_import_test.go
(3 hunks)test/e2e/api_ledgers_list_test.go
(2 hunks)test/e2e/api_ledgers_metadata_test.go
(2 hunks)test/e2e/api_logs_list_test.go
(2 hunks)test/e2e/api_transactions_create_test.go
(4 hunks)test/e2e/api_transactions_list_test.go
(2 hunks)test/e2e/api_transactions_metadata_test.go
(2 hunks)test/e2e/api_transactions_revert_test.go
(3 hunks)test/e2e/api_volumes_test.go
(2 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(4 hunks)test/e2e/app_multiple_instance_test.go
(4 hunks)test/e2e/v1_api_balances_test.go
(3 hunks)test/performance/pkg/write/local_env_test.go
(3 hunks)test/stress/stress_test.go
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- pkg/testserver/client.go
- pkg/testserver/matchers.go
- test/e2e/api_transactions_create_test.go
- test/e2e/api_transactions_revert_test.go
- pkg/testserver/api.go
🧰 Additional context used
🧬 Code Definitions (20)
test/e2e/api_transactions_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_balances_aggregated_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_logs_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_import_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/e2e/api_transactions_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
test/e2e/api_ledgers_list_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (2)
MaxPageSizeInstrumentation
(21-25)DefaultPageSizeInstrumentation
(27-31)
test/e2e/api_volumes_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/generate/generator_test.go (3)
pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(17-20)
test/e2e/api_accounts_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/v1_api_balances_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/client.go (1)
Client
(8-12)
test/e2e/api_bulk_test.go (3)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/api.go (1)
CreateLedger
(17-20)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_accounts_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_create_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/performance/pkg/write/local_env_test.go (3)
pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
pkg/testserver/server.go (1)
cmd/serve.go (4)
ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/app_logs_blocks_async_test.go (4)
pkg/testserver/utils.go (2)
DeferTestServer
(18-25)DeferTestWorker
(36-46)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)pkg/testserver/worker.go (2)
LogsHashBlockCRONSpecInstrumentation
(15-19)LogsHashBlockMaxSizeInstrumentation
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/e2e/api_ledgers_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/app_lifecycle_test.go (5)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (2)
Subscribe
(77-88)ConnectToDatabase
(64-75)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(30-32)test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Tests
🔇 Additional comments (67)
test/e2e/api_transactions_list_test.go (2)
11-13
: Appropriate imports added for the new test server approach.The new imports correctly include the necessary packages to support the refactored test server initialization using the deferred pattern.
35-42
: Well-structured refactoring to use deferred test server initialization.The refactored code replaces the previous direct
NewTestServer
initialization with a more modularDeferTestServer
approach. This change:
- Separates PostgreSQL configuration using
DeferMapDeferred
- Properly configures instrumentation with debug and output settings
- Sets up logging through
testservice.WithLogger
This enhances maintainability and follows a consistent pattern across the codebase.
test/e2e/api_logs_list_test.go (2)
9-11
: Appropriate imports added for deferred test server implementation.The imports correctly include the necessary packages to support the new test server initialization pattern.
28-35
: Well-implemented refactoring to use deferred test server initialization.The code replaces the previous direct test server initialization with the deferred pattern, maintaining consistency with the broader refactoring effort across the codebase. The implementation:
- Correctly obtains database connection options using
DeferMapDeferred
- Properly configures instrumentation for debugging and output
- Sets up appropriate logging
This change improves modularity and separation of concerns in the test setup.
test/e2e/api_transactions_metadata_test.go (2)
8-10
: Appropriate imports added for the deferred test server approach.The imports correctly include the necessary packages for the refactored test server initialization.
27-34
: Clean implementation of the deferred test server pattern.The refactored code effectively implements the deferred test server initialization, consistent with the broader refactoring effort. The approach correctly:
- Retrieves connection options from the database
- Configures instrumentation for debugging and output
- Sets up logging
This maintains consistency across the test suite and improves modularity in the test setup.
test/e2e/api_balances_aggregated_test.go (2)
8-10
: Appropriate imports added for the deferred testing approach.The imports correctly include the necessary packages to support the refactored test server initialization.
27-34
: Consistent implementation of the deferred test server pattern.The code successfully implements the deferred test server initialization, maintaining consistency with the other refactored test files. The implementation:
- Correctly obtains database connection options
- Properly configures instrumentation with appropriate settings
- Sets up logging through the test service
This refactoring contributes to the overall improvement in modularity and maintainability across the test suite.
test/e2e/api_ledgers_list_test.go (3)
9-11
: Updated imports to use go-libs/v2 testing components.The code now uses the standardized testing components from go-libs/v2, which is consistent with the PR objective to use test server from go-libs.
25-34
: Improved test server initialization with DeferTestServer.The previous
NewTestServer
function has been replaced with a cleanerDeferTestServer
approach. This change:
- Makes the test configuration more modular with separate instrumentation options
- Uses deferred initialization for better resource management
- Explicitly configures both max and default page size (both set to 15)
These changes improve code maintainability and align with the broader refactoring effort.
36-36
: Increased test coverage with more ledgers.The test scenario now creates 20 ledgers instead of 10, providing more comprehensive test coverage.
test/stress/stress_test.go (2)
7-8
: Updated imports to use go-libs/v2 testing components.The code now uses the standardized testing components from go-libs/v2, which is consistent with the PR objective to use test server from go-libs.
32-37
: Simplified test server configuration using DeferTestServer.The server initialization has been refactored to use
DeferTestServer
with a more concise configuration. The new approach:
- Uses deferred database connection options
- Only includes the essential experimental features instrumentation
- Removes the previously nested configuration structure
These changes make the code more maintainable and streamlined.
test/e2e/api_ledgers_metadata_test.go (2)
7-9
: Updated imports to use go-libs/v2 testing components.The code now uses the standardized testing components from go-libs/v2, which is consistent with the PR objective to use test server from go-libs.
22-29
: Improved test server initialization with DeferTestServer.The server initialization has been refactored to use
DeferTestServer
with a more modular approach:
- Uses deferred database connection options
- Configures debug and output instrumentation separately
- Adds logger configuration
- Removes previously nested configuration structure
These changes improve code maintainability and align with the broader refactoring effort.
test/e2e/api_bulk_test.go (5)
9-12
: Updated imports to use go-libs/v2 testing components.The code now uses the standardized testing components from go-libs/v2, which is consistent with the PR objective to use test server from go-libs.
40-41
: Improved NATS URL handling with deferred mapping.The NATS URL configuration now uses
DeferMapDeferred
, which defers the mapping of the NATS server URL until it's needed. This is consistent with the new approach for resource management.
43-51
: Enhanced test server configuration with comprehensive instrumentation.The server initialization has been refactored to use
DeferTestServer
with a more complete configuration:
- Uses deferred database connection options
- Includes NATS instrumentation with the deferred URL
- Configures debug and output instrumentation
- Adds logger configuration
This approach is more modular and maintainable than the previous implementation.
58-58
: Updated event subscription to focus on the event channel.The updated code ignores the first return value (subscription object) from the
Subscribe
function and only captures the events channel, which is the primary focus of the test.
248-248
: Improved server URL retrieval with standardized utility function.The code now uses
testservice.GetServerURL(testServer.GetValue())
instead of directly callingtestServer.GetValue().URL()
to get the server URL. This centralizes the method of obtaining the server URL, enhancing consistency across tests.test/e2e/api_accounts_list_test.go (2)
9-12
: Updated imports to use the new testing framework.The changes replace direct imports with the new testing platform and service utilities from
go-libs/v2
. This enables the use of the deferred test initialization pattern used throughout the PR.
33-41
: Improved test server initialization with deferred approach.The server initialization has been completely refactored to use
DeferTestServer
instead of the previousNewTestServer
. This new approach:
- Simplifies configuration by using deferred operations
- Properly handles dependency injection for database connection options
- Adds explicit instrumentation for Nats, debugging, and output
- Sets up logging using Ginkgo's test context
This change improves maintainability and consistency across test files.
test/e2e/app_logs_blocks_async_test.go (4)
24-26
: Improved test variables organization.Variables are now better organized with explicit connection options derived from the database template. This makes the dependency flow clearer and more maintainable.
35-43
: Refactored server initialization with deferred pattern.Server initialization now uses the more modular
DeferTestServer
pattern with explicit instrumentation. This makes the test setup more consistent and maintainable.
45-48
: Added worker initialization with explicit configuration.The test now properly initializes a worker with specific CRON specification and block size limits. This addition ensures that asynchronous block hashing is properly configured for testing.
87-87
: Updated database connection approach.Instead of getting the database from the test server, the code now directly connects using the context and connection options. This provides more explicit control over the database connection lifecycle.
test/e2e/api_volumes_test.go (2)
8-10
: Updated imports for new testing framework.Added imports from the testing platform and service packages to support the deferred test initialization pattern.
37-44
: Improved test server initialization with deferred approach.The test server is now initialized using
DeferTestServer
with explicit database connection options and instrumentation. This follows the same pattern as other test files, improving consistency across the codebase.test/e2e/api_ledgers_import_test.go (3)
26-29
: Improved test setup variables organization.Test variables are now better organized with:
- A templated database
- A proper logging context
- Explicitly derived connection options
This makes the dependencies clearer and improves maintainability.
31-39
: Refactored server initialization with deferred pattern.Server initialization now uses
DeferTestServer
with explicit instrumentation including:
- Debug instrumentation
- Output instrumentation
- Experimental features instrumentation
- Ginkgo logger integration
This makes the test setup more consistent with other test files.
341-341
: Updated database connection handling.Database connection is now created directly using the context and connection options, rather than being retrieved from the test server. This provides better control over the database connection lifecycle and error handling.
pkg/testserver/worker.go (2)
9-13
: Clear and concise instrumentation function implementation.The function
LogsHashBlockMaxSizeInstrumentation
correctly implements the instrumentation pattern, taking a size parameter and returning a function that appends the appropriate command-line arguments to the run configuration.
15-19
: Consistent implementation of instrumentation function.The
LogsHashBlockCRONSpecInstrumentation
function follows the same pattern as the previous function, providing a clean interface for configuring the worker's block hasher schedule.pkg/generate/generator_test.go (3)
25-33
: Well-structured server initialization with improved modularity.The refactored server initialization uses
NewTestServer
with clear separation of concerns:
- Database connection configuration via
utils.NewDeferredWithValue
- Logger configuration with
testservice.WithLogger
- Instrumentation configuration with debug flags
This approach is more modular and easier to maintain than the previous implementation.
39-42
: Updated client access pattern consistent with the codebase refactoring.The client access has been correctly updated to use
Client(testServer)
instead of directly accessing it through the server, which aligns with the new abstraction approach.
55-56
: Consistent client access in multiple locations.The client access pattern has been consistently updated throughout the file, ensuring that all function calls use the new
Client(testServer)
approach.test/e2e/app_multiple_instance_test.go (3)
26-28
: Updated type declarations to match the new service abstraction.The variable types have been correctly updated from custom server implementations to use the more generic
*testservice.Service
type.
40-48
: Improved server initialization with clear instrumentation options.The refactored server initialization uses
testservice.New
with a more modular approach:
- Using the root command from the
cmd
package- Getting test server options from the database connection
- Adding instrumentation for debugging and output
This approach is more maintainable and follows a consistent pattern across the codebase.
65-65
: Updated client access pattern.The client access has been correctly updated to use
Client(server)
instead of directly accessing it through the server, consistent with the changes in other files.test/e2e/api_ledgers_create_test.go (4)
24-27
: Clean variable initialization with deferred values.The variables are now initialized using deferred values for database and NATS URL, which provides a cleaner and more maintainable approach to handling resources in tests.
29-38
: Significantly simplified test server initialization.The test server initialization has been refactored to use
DeferTestServer
with a more modular approach:
- Database connection configuration via
DeferMapDeferred
- Multiple instrumentation options (NATS, debug, output, experimental features)
- Logger configuration
This approach is more maintainable and follows a consistent pattern across the codebase.
52-53
: Consistent usage of the new server abstraction.The server is correctly accessed using
testServer.GetValue()
when creating a ledger, which aligns with the updated pattern for the deferred test server.
109-111
: Consistently updated throughout the codebase.All instances of server access have been updated to use
testServer.GetValue()
, ensuring consistent usage of the new abstraction across the file.test/e2e/v1_api_balances_test.go (2)
28-35
: Ensure proper error handling on server initialization.
The call toDeferTestServer
indirectly handles potential setup failures. Verify that any startup errors are surfaced, especially ifDeferMapDeferred
fails to create connection options.Would you like a script to check if any test initialization errors are being logged or swallowed silently?
80-81
: Client retrieval usage looks good.
Accessing the client viaClient(testServer.GetValue())
is consistent with the new approach across the codebase. No issues found.test/e2e/api_accounts_metadata_test.go (2)
24-24
: Deferred mapping approach is good.
DeferringnatsURL = MapDeferred(natsServer, ...)
is a good pattern for flexible test configuration. Confirm that any errors from NATS server initialization are adequately handled or logged.
27-35
: Refactor to useDeferTestServer
.
Switching from a direct server instantiation toDeferTestServer
fosters a consistent design for test setups and ensures deferred initialization. Make sure no references to the old pattern remain elsewhere.pkg/testserver/server.go (5)
5-5
: New import integration looks consistent.
The import fromtestservice
is aligned with the–rest refactor. No issues found.
9-11
: Properly enabling experimental features.
Enabling experimental features via an instrumentation function is a clean approach. Good job encapsulating it inExperimentalFeaturesInstrumentation
.
15-17
: Numscript rewrite instrumentation is well-defined.
Appending the experimental numscript flag within a test instrumentation function fosters easy toggling.
21-23
: Validate numeric values for max page size.
The code properly appends the max-page-size argument. Consider verifying that zero or invalid values aren’t passed unintentionally to avoid misconfiguration.
27-29
: Default page size instrumentation is coherent.
Appending the default-page-size flag similarly is consistent. No immediate issues.test/performance/pkg/write/local_env_test.go (3)
24-24
: Switched to atestservice.Service
pointer.
Replacing*testserver.Server
with*testservice.Service
aligns with the new service-based architecture. Confirm that external references to the old struct have been removed.
28-32
: Consistent client and URL usage.
Usingtestserver.Client(e.testServer)
andtestservice.GetServerURL(e.testServer)
is a neat improvement, centralizing creation and endpoint retrieval. No concerns here.
63-76
: Revised server creation with instrumentation.
Usingtestserver.NewTestServer
plus instrumentation is consistent with the broader refactor. Confirm that all necessary instrumentation flags (e.g.,ExperimentalFeaturesInstrumentation
or OTLP configs) are applied as intended.pkg/testserver/utils.go (3)
10-16
: Encapsulate server instrumentation inGetTestServerOptions
This function succinctly bundles common instrumentation settings (arguments, Postgres, HTTP). Looks good and helps keep downstream code clean.
18-25
: DeferTestServer usage
The approach of wrappingcmd.NewRootCommand
withDeferNew
and injecting the previously defined server options is neatly modular and consistently uses the deferred pattern for test setup.
27-34
: NewTestServer aligns well with deferred usage
Providing a synchronous (non-deferred) alternative for creating the test server is helpful. The function properly reuses theGetTestServerOptions
for instrumentation.pkg/testserver/helpers.go (1)
64-75
: Database connection lifecycle
The newConnectToDatabase
function cleanly opens the DB and defers closure viaTestingT.Cleanup
. Great approach that guarantees resource release.test/e2e/app_lifecycle_test.go (8)
12-12
: Imports for NATS testing, testservice, and HTTP
Bringing innatstesting
,testservice
,utils
, andnet/http
is aligned with the new refactoring for server & instrumentation usage plus the new health checks.Also applies to: 14-15, 31-31
48-56
: ReplacingNewTestServer
withDeferTestServer
Usingtestservice.WithInstruments
for NATS, debug, and output instrumentation in a single call is tidy. This is a clean approach consistent with the new deferred pattern.
60-60
: Subscribing and retrieving ledger info
Both calls,Subscribe
andClient(...).Ledger.GetInfo(...)
, are correct. The test usage is straightforward, no issues noted.Also applies to: 65-65
71-71
: Server restart
testServer.GetValue().Restart(ctx)
is used to gracefully recycle the application. Looks correct, with no concurrency pitfalls identified.
92-92
: Connecting to the database within test
ConnectToDatabase(ctx, GinkgoT(), connectionOptions)
usage is consistent with the revised helper, ensuring cleanup.
210-217
: DeferTestServer usage for ledger tests
Instantiating a new server with NATS instrumentation. Replaces the older approach and keeps things uniform.
250-262
: Consistency when setting up test server
These lines mirror patterns from earlier in the file for setting up a deferred server with connection options. Code is uniform and maintainable.
296-296
: Health check validation
Usinghttp.DefaultClient.Get(testservice.GetServerURL(testServer.GetValue()) + "/_healthcheck")
is correct. Good example of loosely coupling the server’s URL from the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/testserver/helpers.go (1)
77-87
: Subscribe function lacks subscription teardown
While the function works, consider unsubscribing from the subscription or closing the connection in a deferred cleanup to avoid resource leaks. For example:func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *utils.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) conn, err := nats.Connect(natsURL.GetValue()) require.NoError(t, err) subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, subscription.Drain()) + conn.Close() + }) return subscription, ret }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (28)
pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(14 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(2 hunks)test/e2e/api_accounts_metadata_test.go
(2 hunks)test/e2e/api_balances_aggregated_test.go
(2 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(2 hunks)test/e2e/api_ledgers_import_test.go
(3 hunks)test/e2e/api_ledgers_list_test.go
(2 hunks)test/e2e/api_ledgers_metadata_test.go
(2 hunks)test/e2e/api_logs_list_test.go
(2 hunks)test/e2e/api_transactions_create_test.go
(4 hunks)test/e2e/api_transactions_list_test.go
(2 hunks)test/e2e/api_transactions_metadata_test.go
(2 hunks)test/e2e/api_transactions_revert_test.go
(3 hunks)test/e2e/api_volumes_test.go
(2 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(4 hunks)test/e2e/app_multiple_instance_test.go
(4 hunks)test/e2e/v1_api_balances_test.go
(3 hunks)test/performance/pkg/write/local_env_test.go
(3 hunks)test/stress/stress_test.go
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- pkg/testserver/client.go
- pkg/testserver/matchers.go
- test/e2e/api_transactions_metadata_test.go
- test/e2e/v1_api_balances_test.go
- test/performance/pkg/write/local_env_test.go
- test/e2e/api_balances_aggregated_test.go
- test/e2e/api_transactions_create_test.go
- pkg/testserver/api.go
🧰 Additional context used
🧬 Code Definitions (17)
test/e2e/api_logs_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_transactions_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_bulk_test.go (3)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/api.go (1)
CreateLedger
(17-20)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_accounts_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_volumes_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_transactions_revert_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/app_logs_blocks_async_test.go (4)
pkg/testserver/utils.go (2)
DeferTestServer
(18-25)DeferTestWorker
(36-46)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)pkg/testserver/worker.go (2)
LogsHashBlockCRONSpecInstrumentation
(15-19)LogsHashBlockMaxSizeInstrumentation
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
pkg/generate/generator_test.go (3)
pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(17-20)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_accounts_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_list_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (2)
MaxPageSizeInstrumentation
(21-25)DefaultPageSizeInstrumentation
(27-31)
test/e2e/api_ledgers_create_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
pkg/testserver/server.go (1)
cmd/serve.go (4)
ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/api_ledgers_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
test/e2e/app_lifecycle_test.go (5)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (2)
Subscribe
(77-88)ConnectToDatabase
(64-75)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(30-32)test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)
test/e2e/api_ledgers_import_test.go (4)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Tests
🔇 Additional comments (66)
pkg/testserver/worker.go (3)
4-6
: Updated imports to support new instrumentation patterns.The import changes reflect the transition to using the
go-libs/v2
testing framework with itstestservice
package, which is a cleaner approach for managing test services.
9-13
: Well-structured instrumentation function for block hasher size configuration.This function creates a parameterized instrumentation closure that correctly configures the worker's async block hasher maximum size via command-line arguments. The pattern follows good practices by:
- Using a high-order function that returns an instrumentation function
- Properly converting the integer size to string using
strconv.Itoa
- Using the constant from
cmd
package for flag name consistency
15-19
: Well-structured instrumentation function for block hasher schedule configuration.This function creates a parameterized instrumentation closure that correctly configures the worker's async block hasher schedule via command-line arguments. It follows the same clean pattern as the previous function.
pkg/testserver/server.go (5)
4-7
: Updated imports to support new instrumentation patterns.The imports have been simplified to only include what's necessary for the new instrumentation functions, using the
go-libs/v2
testing framework.
9-13
: Well-structured instrumentation function for enabling experimental features.This function creates an instrumentation closure that properly enables experimental features via a command-line flag. It follows the established pattern of returning a function that modifies the run configuration.
15-19
: Well-structured instrumentation function for enabling experimental numscript rewrite.This function creates an instrumentation closure that properly enables the experimental numscript interpreter via a command-line flag, following the same clean pattern as other instrumentation functions.
21-25
: Well-structured instrumentation function for setting maximum page size.This function creates a parameterized instrumentation closure that correctly configures the maximum page size via command-line arguments. It properly uses
fmt.Sprint
to convert the uint64 value to a string.
27-31
: Well-structured instrumentation function for setting default page size.This function creates a parameterized instrumentation closure that correctly configures the default page size via command-line arguments. It properly uses
fmt.Sprint
to convert the uint64 value to a string.test/e2e/api_transactions_list_test.go (2)
9-14
: Updated imports to support the new test server initialization pattern.The imports have been updated to include the necessary packages for the new test server initialization pattern, including
pgtesting
for database handling andtestservice
for test service configuration.
35-42
: Improved test server initialization with deferred pattern.The test server initialization has been refactored to use a deferred pattern, which is more flexible and maintainable. The new approach:
- Uses
DeferTestServer
to create a deferred service- Leverages
DeferMapDeferred
to handle database connection options- Configures instrumentation for debugging and output
- Sets up proper logging through
testservice.WithLogger
This change is part of a broader refactoring effort to standardize server setup across the codebase, enhancing modularity and reducing boilerplate.
test/e2e/api_logs_list_test.go (2)
9-14
: Updated imports to support the new test server initialization pattern.The imports have been updated to include the necessary packages for the new test server initialization pattern, including
pgtesting
for database handling andtestservice
for test service configuration.
28-36
: Improved test server initialization with deferred pattern.The test server initialization has been refactored to use a deferred pattern, which is more flexible and maintainable. The new approach:
- Uses
DeferTestServer
to create a deferred service- Leverages
DeferMapDeferred
to handle database connection options- Configures instrumentation for debugging and output
- Sets up proper logging through
testservice.WithLogger
This change aligns with the standardization of server setup across the codebase, enhancing modularity and maintainability.
test/stress/stress_test.go (1)
32-37
: Clean refactoring of test server initialization.The refactoring to use
DeferTestServer
from go-libs improves code maintainability by standardizing how test servers are initialized across the codebase. The deferred initialization pattern allows for better resource management and cleaner test setup.test/e2e/api_ledgers_list_test.go (2)
25-34
: Improved test configuration with deferred test server.The change to
DeferTestServer
improves the test setup by:
- Using a more modular approach to configure the test server
- Explicitly setting page size limits through instrumentation
- Properly configuring logging output to GinkgoWriter
This aligns with the broader refactoring to use the test server from go-libs.
36-36
: Test data expanded for better pagination testing.Increasing the number of ledgers from 10 to 20 provides better test coverage for the pagination functionality, as the page size is configured to 15 (lines 30-31).
test/e2e/api_transactions_revert_test.go (2)
31-42
: Improved test server configuration with NATS integration.The refactoring properly integrates NATS into the test server configuration using the deferred initialization pattern:
- The NATS URL is initialized using
DeferMapDeferred
- NATS instrumentation is added to the test server
- Debug and output instrumentation are properly configured
This change provides a cleaner and more modular approach to test setup.
58-58
: Updated Subscribe function call to match new signature.The updated call to
Subscribe
correctly captures only the events channel while discarding the subscription return value, which isn't used in the test. This matches the function signature inpkg/testserver/helpers.go
.test/e2e/api_ledgers_metadata_test.go (1)
22-29
: Consistent implementation of deferred test server pattern.The refactoring to use
DeferTestServer
maintains consistency with the other test files:
- Database connection is handled through
DeferMapDeferred
- Debug and output configurations use standardized instrumentation
- Logging is properly configured through
WithLogger
This change improves maintainability by adopting a common pattern for test server initialization across the codebase.
test/e2e/api_bulk_test.go (5)
9-12
: Updated imports to support new testing infrastructureThe new imports provide standardized testing utilities for:
- NATS testing integration via
natstesting
- PostgreSQL integration via
pgtesting
- Test service orchestration via
testservice
- Testing utilities via
testing/utils
These changes align with the refactoring described in the PR to leverage the test server from go-libs.
40-41
: Improved NATS URL initialization with deferred mappingReplaced direct NATS URL initialization with a deferred approach using
DeferMapDeferred
. This pattern:
- Lazily extracts the client URL from the NATS server instance
- Ensures the URL is only resolved when needed
- Follows a consistent pattern with other deferred resources
43-51
: Refactored test server initialization to use modular approachReplaced
NewTestServer
withDeferTestServer
which provides:
- Clear separation of configuration concerns
- Explicit instrumentation setup (NATS, debug, output)
- Proper logger configuration
- Deferred initialization for better resource management
This approach makes test setup more readable and maintainable by using a composition-based pattern.
58-58
: Updated event subscription patternThe event subscription now uses the new
Subscribe
function that returns both a subscription object and an events channel. The subscription object is ignored (using_
), showing we're only interested in the events channel.
248-248
: Standardized server URL retrievalUpdated the URL construction to use
testservice.GetServerURL(testServer.GetValue())
instead of direct URL access. This centralizes the method of obtaining the server URL, improving consistency in test setup.test/e2e/api_accounts_list_test.go (2)
9-12
: Updated imports to support new testing infrastructureAdded standardized testing utilities for:
- NATS testing via
natstesting
- PostgreSQL testing via
pgtesting
- Test service orchestration via
testservice
- Testing utilities via
testing/utils
These imports support the transition to using the test server from go-libs.
33-41
: Refactored test server initialization to use modular approachReplaced nested configuration with a more modular
DeferTestServer
approach that:
- Obtains database connection options through
DeferMapDeferred
- Configures NATS instrumentation with a deferred URL
- Sets up debug and output instrumentation
- Configures logging with GinkgoT()
This improves readability and maintenance by separating concerns and providing a consistent initialization pattern across test files.
test/e2e/app_logs_blocks_async_test.go (5)
9-11
: Updated imports to support new testing infrastructureAdded standardized testing utilities for:
- PostgreSQL testing via
pgtesting
- Test service orchestration via
testservice
- Testing utilities via
testing/utils
These imports align with the refactoring to use the test server from go-libs.
24-26
: Improved database connection setup with deferred initializationUpdated database initialization to:
- Use templated database with
UseTemplatedDatabase()
- Extract connection options with
DeferMapDeferred
- Set up a testing context
This provides a cleaner separation between resource creation and connection option extraction.
35-43
: Refactored test server initialization to use modular approachReplaced the previous configuration with
DeferTestServer
that:
- Uses the extracted connection options
- Configures multiple instrumentation options through
WithInstruments
- Enables experimental features
- Sets up proper logging
This improves clarity and follows a consistent pattern across test files.
45-49
: Added dedicated test worker with specific configurationAdded a deferred test worker using:
- The same connection options as the test server
- Specialized instrumentation for logs hash block processing
- Custom CRON specification for scheduled execution
- Configured maximum block size
This separates worker configuration from server configuration, improving separation of concerns.
87-87
: Standardized database connection with utility functionReplaced direct database access with the
ConnectToDatabase
utility function, which:
- Manages database connection lifecycle
- Handles cleanup automatically
- Ensures consistent error handling
- Makes the code more readable
This change aligns with the refactoring approach of using standardized utilities.
test/e2e/api_volumes_test.go (2)
8-10
: Updated imports to support new testing infrastructureAdded standardized testing utilities for:
- PostgreSQL testing via
pgtesting
- Test service orchestration via
testservice
- Testing utilities via
testing/utils
These imports support the transition to using the test server from go-libs.
37-44
: Refactored test server initialization to use modular approachReplaced the previous configuration with
DeferTestServer
that:
- Uses database connection options via
DeferMapDeferred
- Configures debug and output instrumentation
- Sets up proper logging with GinkgoT()
This change follows the consistent pattern established across the test suite, improving readability and maintenance.
test/e2e/api_ledgers_import_test.go (4)
10-12
: Good addition of the go-libs testing packages.The imports now correctly reference the modular testing packages from go-libs which aligns with the PR's objective to use the shared test server infrastructure.
26-29
: Well-structured test setup using deferred patterns.The refactoring to use
UseTemplatedDatabase()
,logging.TestingContext()
, andDeferMapDeferred
improves the code by:
- Making dependencies explicit
- Following a consistent pattern for resource management
- Improving readability of the test setup
31-39
: Clean implementation of the new modular test server approach.The transition from the previous nested configuration to using
DeferTestServer
with explicit instrumentation options is a significant improvement. It separates concerns and makes the test setup more maintainable.The instrumentation functions provide better observability for debugging and logging during test execution.
341-341
: Improved database connection with proper context.Using
ctx
(initialized withlogging.TestingContext()
) rather thanGinkgoT()
directly is a better practice for context management in database operations. This change ensures proper logging and cancellation signal handling.pkg/generate/generator_test.go (2)
25-34
: Cleaner test server initialization with better structure.The refactored code now uses
NewTestServer
with a more modular approach:
- Using
utils.NewDeferredWithValue
for connection options- Adding explicit logger configuration with
testservice.WithLogger(t)
- Configuring debug instrumentation based on environment variables
This approach is more maintainable and provides better observability during tests.
39-39
: Improved client access pattern.The change from
testServer.Client().Ledger.V2
toClient(testServer).Ledger.V2
follows a more functional approach and improves the separation of concerns. This is consistent with the rest of the refactoring in this PR and makes the code more testable.Also applies to: 55-55
test/e2e/api_ledgers_create_test.go (3)
9-12
: Appropriate imports for the new testing approach.The addition of platform-specific testing packages (natstesting, pgtesting) and the testservice package aligns with the PR's goal of using the shared test server infrastructure from go-libs.
24-27
: Well-structured variable initialization with deferred patterns.The code now uses a consistent approach for managing database connections and NATS URLs through deferred patterns, which improves resource management and test setup clarity.
29-38
: Comprehensive test server setup with multiple instrumentation options.The refactored code properly configures the test server with:
- Database connection options from the templated database
- NATS instrumentation for event handling
- Debug and output instrumentation for better observability
- Experimental features configuration for testing
This makes tests more robust and easier to debug.
test/e2e/app_multiple_instance_test.go (3)
26-27
: Good standardization to use testservice.Service.Changing the server types from custom types to
*testservice.Service
improves consistency across the codebase and leverages the shared test infrastructure properly.Also applies to: 28-28
40-48
: Improved server creation with cleaner initialization.The code now uses
testservice.New
with the root command and proper options, which is a more maintainable approach than the previous custom initialization. The explicit instrumentation configuration enhances test observability.
65-65
: Consistent client access pattern.The change from
server.Client().Ledger
toClient(server).Ledger
follows the same functional approach used elsewhere in the PR, maintaining consistency throughout the codebase.test/e2e/api_accounts_metadata_test.go (4)
7-10
: New import references look appropriate
No issues found with these new imports. They align well with the underlying modules for testing NATS, PostgreSQL, and the testservice utilities.
24-24
: Deferred mapping for NATS URL
UsingMapDeferred
helps maintain a clean deferred-based approach for NATS resource management. No issues here.
27-35
: Switch to DeferTestServer
Instantiating the test server withDeferTestServer
and feeding in instrumentation options is consistent with the new deferred setup. This approach improves modularity and configuration clarity.
38-38
: Subscribe call discards subscription ID
The updatedSubscribe
function definition returns both a subscription and a message channel. Capturing only the channel is presumably intentional. Looks good if the subscription ID is not needed.pkg/testserver/utils.go (5)
1-8
: New package and imports
The package naming and import references appear correct for the new test server utilities.
10-16
: GetTestServerOptions
This function assembles the server options neatly, including instrumentation for arguments, PostgreSQL, and HTTP. No issues found.
18-25
: DeferTestServer
This deferred approach for test server creation ensures a flexible and composable setup. Good addition.
27-34
: NewTestServer
Providing a non-deferred version complementsDeferTestServer
for scenarios where immediate instantiation is preferred. Implementation looks sound.
36-46
: DeferTestWorker
Similar pattern toDeferTestServer
, but for worker initialization. Implementation remains consistent with the existing approach.pkg/testserver/helpers.go (2)
4-5
: Added imports
Imports forcontext
,bunconnect
,testservice
, andutils
align with the new utility-based design.Also applies to: 8-9
64-75
: ConnectToDatabase function
Accepting an inline interface for testing and cleanup is a neat pattern for ensuring database closure. Implementation is straightforward and correct.test/e2e/app_lifecycle_test.go (11)
12-15
: Updated imports to use go-libs testing utilities.The import changes are part of the broader refactoring to utilize the test server capabilities from go-libs library. The new imports include testing utilities for NATS, PostgreSQL, and testservice, which aligns with the PR objective of transitioning to use the test server from go-libs.
41-47
: Improved database configuration with deferred evaluation pattern.The code has been refactored to use the
DeferMapDeferred
pattern, which provides a cleaner way to derive connection options from the database. This approach allows for lazy evaluation of connection parameters, making the test setup more flexible and maintainable.
48-56
: Enhanced test server initialization with modular instrumentation.The refactoring replaces direct initialization with
DeferTestServer
, which provides a more structured approach to configuring the test server. The use of individual instrumentation options (NATS, debug, output) improves modularity and makes the configuration more explicit and maintainable.
60-60
: Updated NATS subscription to use the new API.The
Subscribe
call has been updated to work with the new deferred test server and NATS URL approach, ensuring consistent use of the new patterns throughout the test suite.
65-65
: Simplified client access using the new Client utility.The change from direct API access to using the
Client
utility function helps encapsulate the details of client creation and configuration, making the test code more concise and maintainable.
91-91
: Updated database connection to use the new API.The database connection now uses the new
ConnectToDatabase
function with the context and connection options, which provides a more consistent approach to database access across the test suite.
148-152
: Improved server lifecycle management with explicit Stop and Start.The server restart process has been refactored to use explicit
Stop
andStart
methods with appropriate contexts, rather than a singleRestart
call. This provides clearer control over the server's lifecycle and allows for timeout configuration specifically for the stopping phase.
210-217
: Consistent test server configuration for ledger schema version tests.The test server configuration follows the same pattern as in the earlier test context, ensuring consistency throughout the test suite. The use of
DeferTestServer
with appropriate instrumentations shows a consistent application of the new pattern.
250-262
: Standardized test server setup for downgrade tests.The downgrade tests now use the same standardized approach to test server configuration, with appropriate instrumentations. This ensures consistency across different test contexts and aligns with the PR's goal of using the test server from go-libs.
279-279
: Updated database access for migration tests.The migration test now uses the consistent
ConnectToDatabase
function, aligning with the pattern used elsewhere in the file and ensuring proper resource management and cleanup.
297-297
: Updated HTTP client call for healthcheck.The health check endpoint access has been updated to use
http.DefaultClient.Get
with a URL derived fromtestservice.GetServerURL(testServer.GetValue())
, which is a more standard approach and better utilizes the test service API.
f85af4f
to
5f26404
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (8)
pkg/testserver/server.go (4)
9-13
: Consider adding doc comments.The function is clear and well-structured. For maintainability, a brief doc explaining what “experimental features” are and how this instrumentation affects the run configuration would be helpful.
15-19
: Remain consistent with naming or add documentation.This function name references a “rewrite,” while the command flag references an “interpreter.” Adding a short doc comment or consistently naming them would reduce confusion for future maintainers.
21-25
: Validate the provided page size.While
uint64
prevents negative values, a zero (or extremely large) value might cause unexpected behavior. Consider validating the size upstream or logging a warning for zero.
27-31
: Same page-size validation considerations as above.As with
MaxPageSizeInstrumentation
, ensuresize
aligns with acceptable defaults and does not inadvertently disable pagination if zero or excessively high.pkg/testserver/utils.go (3)
18-25
: DeferTestServer improves test flexibility.Nice use of
testservice.DeferNew
for on-demand server creation. Documenting typical usage or constraints would help future contributors.
27-34
: NewTestServer complements DeferTestServer.Having both immediate and deferred server creation is valuable. Adding clarifications (in doc comments) on when each factory method is recommended can help maintain consistency in tests.
36-46
: DeferTestWorker parallel to DeferTestServer.Implementation mirrors the server approach for worker processes. Similar doc or usage notes can reinforce clarity, especially for new users reading the test code.
pkg/testserver/helpers.go (1)
77-88
: Add a cleanup step for NATS resources.Publishing messages to a channel in the subscription is well done, but consider adding
t.Cleanup
to close the subscription and NATS connection, preventing resource leaks in long test runs.func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *utils.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) conn, err := nats.Connect(natsURL.GetValue()) require.NoError(t, err) + t.Cleanup(func() { + conn.Drain() // or conn.Close() + }) subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) return subscription, ret }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (30)
pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(14 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(2 hunks)test/e2e/api_accounts_metadata_test.go
(2 hunks)test/e2e/api_balances_aggregated_test.go
(2 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(2 hunks)test/e2e/api_ledgers_import_test.go
(3 hunks)test/e2e/api_ledgers_list_test.go
(2 hunks)test/e2e/api_ledgers_metadata_test.go
(2 hunks)test/e2e/api_logs_list_test.go
(2 hunks)test/e2e/api_transactions_create_test.go
(4 hunks)test/e2e/api_transactions_list_test.go
(2 hunks)test/e2e/api_transactions_metadata_test.go
(2 hunks)test/e2e/api_transactions_revert_test.go
(3 hunks)test/e2e/api_volumes_test.go
(2 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(4 hunks)test/e2e/app_multiple_instance_test.go
(4 hunks)test/e2e/v1_api_balances_test.go
(3 hunks)test/performance/pkg/env/env.go
(0 hunks)test/performance/pkg/env/env_remote_ledger.go
(2 hunks)test/performance/pkg/write/local_env_test.go
(3 hunks)test/stress/stress_test.go
(2 hunks)
💤 Files with no reviewable changes (1)
- test/performance/pkg/env/env.go
🚧 Files skipped from review as they are similar to previous changes (8)
- pkg/testserver/client.go
- pkg/testserver/matchers.go
- test/e2e/api_ledgers_list_test.go
- test/e2e/api_transactions_create_test.go
- test/e2e/app_logs_blocks_async_test.go
- test/e2e/v1_api_balances_test.go
- test/performance/pkg/write/local_env_test.go
- pkg/testserver/api.go
🧰 Additional context used
🧬 Code Definitions (18)
test/e2e/api_transactions_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_transactions_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_balances_aggregated_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/generate/generator_test.go (3)
pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(17-20)
test/e2e/app_multiple_instance_test.go (3)
pkg/testserver/utils.go (1)
GetTestServerOptions
(10-16)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(30-32)
test/e2e/api_ledgers_import_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_ledgers_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_create_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(9-13)
test/e2e/api_volumes_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
test/e2e/api_accounts_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_accounts_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_logs_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/performance/pkg/env/env_remote_ledger.go (1)
test/performance/pkg/env/env.go (1)
Env
(11-14)
pkg/testserver/server.go (1)
cmd/serve.go (4)
ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/app_lifecycle_test.go (5)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (2)
Subscribe
(77-88)ConnectToDatabase
(64-75)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
GetInfo
(30-32)test/e2e/suite_test.go (1)
UseTemplatedDatabase
(108-110)
test/e2e/api_transactions_revert_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Tests
🔇 Additional comments (68)
test/performance/pkg/env/env_remote_ledger.go (3)
18-23
: Good use of underscore parameters for unused ctx and b argumentsNice improvement in the Create method by using underscores for unused parameters (ctx, b), which follows Go's best practice for indicating unused parameters. The method is also simplified by directly returning the result of NewRemoteLedgerEnv with an inline client creation.
34-36
: Clean implementation with removal of unnecessary ledgerURL fieldThe removal of the ledgerURL field from the RemoteLedgerEnv struct aligns with the interface changes from the broader refactoring effort. This change correctly simplifies the struct by eliminating redundant state that's already maintained within the client.
46-49
: Appropriate simplification of the constructor functionThe NewRemoteLedgerEnv function signature has been appropriately simplified to only require the client parameter, removing the redundant ledgerURL parameter. This is consistent with the changes to the RemoteLedgerEnv struct and improves the API by focusing on essential parameters.
test/e2e/api_transactions_list_test.go (2)
10-13
: Import statements updated to accommodate new testserver approach.The imports now include platform-specific testing packages and utility functions that support the deferred test server pattern.
35-42
: Improved test server initialization with deferred approach.The refactoring replaces the previous direct configuration approach with a more modular pattern using deferred initialization. This change:
- Separates database connection configuration using
DeferMapDeferred
- Explicitly configures instrumentation with debug and output options
- Adds proper logging configuration
This approach improves maintainability by clearly separating configuration concerns.
test/e2e/api_logs_list_test.go (2)
9-11
: Updated imports to support new testserver pattern.The new imports properly include the required packages for the deferred test server approach.
28-35
: Refactored test server initialization with deferred pattern.The test server initialization now uses the more modular
DeferTestServer
approach, consistent with the pattern applied across the codebase. This improves configurability by:
- Clearly separating database connection configuration
- Explicitly setting up instrumentation for debugging and output
- Configuring proper test logging
This approach is more maintainable and aligns with the PR's objective of using the test server from go-libs.
test/stress/stress_test.go (2)
7-8
: Updated imports for testservice patterns.The imports now include the necessary packages to support the deferred test server approach.
32-37
: Simplified test server initialization for stress tests.The stress test configuration appropriately uses a more streamlined setup:
- Maintains the same deferred initialization pattern as other files
- Only includes the experimental features instrumentation, which is appropriate for stress testing
- Omits unnecessary debug/logging configuration
This tailored approach is well-suited for stress tests where minimal configuration is preferred.
test/e2e/api_transactions_metadata_test.go (2)
8-10
: Updated imports to support deferred testserver pattern.The new imports correctly include the required packages for using the refactored test server approach.
27-34
: Refactored test server initialization with consistent deferred pattern.The test server initialization has been updated to match the pattern used throughout the codebase:
- Uses
DeferTestServer
for modular configuration- Properly configures database connection options
- Sets up appropriate instrumentation and logging
This approach aligns with the PR's goal of leveraging the test server from go-libs and improves code maintainability.
test/e2e/api_balances_aggregated_test.go (2)
8-10
: Appropriate import updates for test library migration.The imports have been updated to include the necessary packages from go-libs for the new test server approach.
27-34
: Well-structured server initialization with deferred approach.The refactoring from
NewTestServer
toDeferTestServer
improves modularity by:
- Using deferred mapping for database connection options
- Separating instrumentation and logging concerns
- Following a consistent pattern used across test files
This approach aligns with the PR objective of using the test server from go-libs.
test/e2e/api_ledgers_metadata_test.go (2)
7-9
: Appropriate import updates for test library migration.The imports have been correctly updated to include the necessary packages from go-libs.
22-29
: Well-structured server initialization with deferred approach.The refactoring from
NewTestServer
toDeferTestServer
follows the same pattern as other test files, improving modularity and consistency across the test suite.test/e2e/api_transactions_revert_test.go (4)
6-9
: Appropriate import updates including NATS testing.The imports have been correctly updated to include packages for both PostgreSQL and NATS testing components.
31-32
: Well-structured NATS URL initialization.The addition of
natsURL
usingDeferMapDeferred
properly extracts the client URL from the NATS server.
34-42
: Comprehensive server initialization with NATS support.The refactoring to
DeferTestServer
includes:
- Database connection options via deferred mapping
- NATS instrumentation with the deferred URL
- Debug and output instrumentation
- Logger configuration
This provides a more modular and maintainable approach to test server setup.
58-58
: Updated Subscribe function call to match new signature.The Subscribe function now receives the NATS URL and properly ignores the first return value (subscription) while capturing the events channel.
test/e2e/api_bulk_test.go (5)
9-12
: Appropriate import updates for test infrastructure.The imports have been correctly updated to include all necessary testing infrastructure packages.
40-41
: Well-structured NATS URL initialization.The addition of
natsURL
usingDeferMapDeferred
properly extracts the client URL from the NATS server.
43-51
: Comprehensive server initialization with NATS support.The server initialization follows the same pattern as other test files, providing consistent configuration across the test suite.
58-58
: Updated Subscribe function call to match new signature.The Subscribe function now correctly receives the NATS URL and captures only the events channel.
248-248
: Improved server URL retrieval for HTTP requests.The change to use
testservice.GetServerURL(testServer.GetValue())
instead of directly accessing the URL provides a more consistent approach to URL retrieval across the test suite.test/e2e/api_accounts_list_test.go (2)
9-12
: Good update to imports reflecting the new dependency structure.The imports are now correctly structured to use the more modular
testservice
package and related platform testing utilities. This aligns with the shift to a more flexible testing approach.
33-41
: Well-structured test server initialization with improved modularity.The new implementation using
DeferTestServer
with separate instrumentation options is a significant improvement over the previous approach. It provides:
- Clear separation of concerns between database configuration, instrumentation, and logging
- More explicit dependency management through deferred mappings
- Better composability through the use of testservice options
pkg/testserver/worker.go (3)
3-7
: Good simplification of imports.The imports have been reduced to only what's necessary for the new instrumentation functions, removing unused dependencies.
9-13
: Well-designed instrumentation function for logs hash block size.This function follows the functional design pattern nicely, creating a closure that configures the run configuration when needed. The strconv usage for type conversion is appropriate.
15-19
: Good implementation of CRON spec instrumentation.Similar to the block size function, this cleanly encapsulates the configuration logic for the worker's CRON schedule into a reusable function.
test/e2e/api_volumes_test.go (2)
8-10
: Appropriate import changes for the new testing approach.The updated imports correctly reflect the shift to using the platform testing utilities and testservice package.
37-44
: Clean implementation of the test server with targeted instrumentation.This implementation properly configures the test server with only the instrumentation needed for this particular test (debug and output, without NATS), demonstrating the flexibility of the new approach.
test/e2e/api_ledgers_import_test.go (4)
10-12
: Good import structure for the testing utilities.The imports correctly include the necessary testing platform and utility packages needed for the revised testing approach.
26-29
: Clear separation of database and connection configuration.Extracting the connection options from the database into a separate variable improves readability and follows the pattern of separating concerns in the test setup.
31-39
: Well-structured test server with additional instrumentation.This implementation includes the experimental features instrumentation in addition to the standard debug and output instrumentation, showing how the new approach allows for customized server configurations.
341-341
: Improved database connection with explicit context.The updated
ConnectToDatabase
call now properly passes the context and connection options separately, which follows the new pattern and improves clarity around how the database connection is established.pkg/generate/generator_test.go (4)
10-11
: Updated imports to support new testing approach.The new imports from
testing/testservice
andtesting/utils
are added to support the refactored test server and utility functionality from go-libs.
25-33
: Improved server initialization with modern test framework.The test server initialization has been refactored to use
NewTestServer
with a cleaner, more modular approach. This implementation:
- Uses
utils.NewDeferredWithValue
to encapsulate database connection options- Adds structured logging via
testservice.WithLogger
- Incorporates instrumentation options through
testservice.WithInstruments
This approach is more maintainable and aligns with the standard pattern from go-libs.
39-39
: Updated client access pattern.Changed from directly accessing the client through
testServer.Client().Ledger.V2
to using the standaloneClient(testServer)
function, making the client access consistent with the new abstraction pattern.
55-55
: Updated action application method.Changed to use the new client access pattern for applying actions, maintaining consistency with the updated framework.
test/e2e/api_ledgers_create_test.go (3)
9-12
: Updated imports to support modern test framework.Imports now use the platform-specific testing packages from go-libs, including
pgtesting
,natstesting
, andtestservice
, which provide more structured testing capabilities.
24-27
: Simplified test setup with deferred values.The test setup now uses:
UseTemplatedDatabase()
for database initializationlogging.TestingContext()
for context creationDeferMapDeferred
to transform the NATS server into its client URLThis approach improves readability and reduces boilerplate code.
29-38
: Modernized test server initialization.The server setup now uses
DeferTestServer
with a clean, modular approach:
- Database connection options are mapped from the database instance
- Multiple instrumentation options are composed together
- Logger configuration is provided through
testservice.WithLogger
This pattern enhances maintainability by separating concerns and making the configuration more explicit.
test/e2e/app_multiple_instance_test.go (4)
8-10
: Updated imports to support modern test framework.The imports now include the testservice package and utilities from go-libs, enabling the refactored test patterns.
26-29
: Updated server types to use testservice abstraction.Changed the server collection type from
[]*Server
to[]*testservice.Service
and updated the channel type accordingly. This aligns with the new testing framework's service abstraction.
40-49
: Modernized server initialization.Server creation now uses
testservice.New
with a more modular approach:
- Root command is directly provided
- Test server options are generated with database connection mapping
- Instrumentation options are explicitly provided for debugging and output
This pattern improves clarity and maintainability of the test server setup.
65-65
: Updated client access pattern.Changed from directly accessing the client to using the standalone
Client(server)
function, maintaining consistency with the new abstraction pattern.test/e2e/api_accounts_metadata_test.go (4)
7-10
: Updated imports to support modern test framework.The imports now use platform-specific testing packages from go-libs, providing more structured testing capabilities for PostgreSQL, NATS, and general test services.
24-24
: Simplified NATS URL handling with MapDeferred.NATS URL is now obtained using
MapDeferred
, which maps the NATS server to its client URL in a clean and declarative way.
27-35
: Modernized test server initialization.The server setup now uses
DeferTestServer
with a clean, modular approach:
- Database connection options are mapped from the database instance
- NATS instrumentation is configured with the deferred URL
- Debug and output instrumentation are explicitly configured
- Logger is provided through
testservice.WithLogger
This pattern enhances maintainability by making the configuration more explicit and modular.
38-38
: Updated subscription pattern.Changed to discard the first return value from
Subscribe
(likely a subscription object) and only keep the events channel. This suggests an API change in the Subscribe function that now returns both a subscription object and the events channel.pkg/testserver/server.go (1)
5-5
: Import looks good.No cyclical dependencies or naming conflicts detected with the addition of
testservice
.pkg/testserver/utils.go (2)
1-8
: New file creation and imports.No issues detected with these imports. They provide a clear baseline for server and instrumentation utilities.
10-16
: Clean modular approach for server options.This method neatly centralizes the default instrumentation, yielding a more maintainable setup. If code style conventions require doc strings, consider adding a brief explanation.
pkg/testserver/helpers.go (3)
4-5
: Additional imports are appropriate.Bringing in
context
andbunconnect
is consistent with the new pattern of database connections in test code.
8-9
: Imports for testservice and utils.These are necessary for the new modular and deferred approach.
64-75
: Robust test DB setup.Ensuring the DB is closed via
t.Cleanup
is good practice. This function cleanly handles database lifecycle in tests.test/e2e/app_lifecycle_test.go (12)
12-15
: Updated imports to support new test server abstractionThe imports have been updated to use the new test service infrastructure from go-libs, including NATS testing support and utility functions. This aligns with the PR objective of migrating to the test server from go-libs.
41-47
: Improved connection setup with deferred evaluation patternThe new approach uses
DeferMapDeferred
to create connection options that are lazily evaluated. This is more flexible than the previous method as it allows for dynamic configuration resolution at runtime rather than at initialization time.
48-56
: Replaced NewTestServer with DeferTestServer for better modularityThe test server setup has been refactored to use the new
DeferTestServer
function with a more modular configuration approach using explicit instrumentation options. This improves maintenance and flexibility compared to the previous nested configuration method.
60-60
: Updated Subscribe function usage to work with new test service abstractionThe
Subscribe
function call has been updated to work with the new test service API, properly passing the testing context, service instance, and NATS URL.
65-65
: Refactored client usage to use new Client helper functionThe code now uses the
Client
function to create a client for the test service instead of directly accessing the test server. This is more maintainable and consistent with the modular approach in the PR.
91-91
: Updated database connection to use context-aware patternThe database connection now correctly passes the context to
ConnectToDatabase
, which aligns with the context-aware patterns used throughout the codebase and improves resource management.
148-152
: Improved server lifecycle management with explicit Stop and StartThe code now explicitly manages the server lifecycle with separate
Stop
andStart
calls instead of usingRestart
. This provides clearer control and better supports the timeout handling through the dedicated stop context.
210-217
: Consistent application of DeferTestServer patternThis test server setup follows the same pattern as earlier in the file, demonstrating consistent refactoring throughout the test suite. The use of method references with
DeferMapDeferred
is a clean approach.
250-252
: Simplified variable declarations with consistent namingThe variable declarations have been updated to use the deferred evaluation pattern consistently, with clear naming that reflects their purpose.
255-262
: Consistent test server configurationThis test server configuration follows the same pattern used elsewhere in the file, showing consistent application of the new approach throughout the test suite.
279-279
: Updated database connection with context-aware approachSimilar to the earlier change, this database connection now correctly uses the context-aware pattern for
ConnectToDatabase
.
297-297
: Improved health check endpoint accessThe health check endpoint is now accessed using
http.DefaultClient.Get
with the URL derived fromtestservice.GetServerURL
, which is more maintainable than directly constructing the URL from the server.
5f26404
to
a8720d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/testserver/helpers.go (1)
77-79
: Consider unsubscribing from the subscription in cleanupReturning both a
*nats.Subscription
and a channel for messages works, but for test stability, ensure a proper unsubscribe or drain process for the subscription/connection after tests if you need to avoid resource leaks or data races.func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *deferred.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) conn, err := nats.Connect(natsURL.GetValue()) require.NoError(t, err) subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) + t.Cleanup(func() { + _ = subscription.Drain() + conn.Close() + }) return subscription, ret }Also applies to: 82-83, 85-85, 87-87
test/e2e/app_lifecycle_test.go (1)
60-60
: Subscribing to NATS for ledger eventsCapturing the returned messages is helpful for verifying ledger operations. Consider ensuring the subscription is cleaned up once tests complete.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (33)
internal/storage/ledger/main_test.go
(3 hunks)pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(14 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/helpers.go
(2 hunks)pkg/testserver/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(2 hunks)test/e2e/api_accounts_metadata_test.go
(2 hunks)test/e2e/api_balances_aggregated_test.go
(2 hunks)test/e2e/api_bulk_test.go
(3 hunks)test/e2e/api_ledgers_create_test.go
(2 hunks)test/e2e/api_ledgers_import_test.go
(3 hunks)test/e2e/api_ledgers_list_test.go
(2 hunks)test/e2e/api_ledgers_metadata_test.go
(2 hunks)test/e2e/api_logs_list_test.go
(2 hunks)test/e2e/api_transactions_create_test.go
(4 hunks)test/e2e/api_transactions_list_test.go
(2 hunks)test/e2e/api_transactions_metadata_test.go
(2 hunks)test/e2e/api_transactions_revert_test.go
(3 hunks)test/e2e/api_volumes_test.go
(2 hunks)test/e2e/app_lifecycle_test.go
(9 hunks)test/e2e/app_logs_blocks_async_test.go
(4 hunks)test/e2e/app_multiple_instance_test.go
(4 hunks)test/e2e/suite_test.go
(5 hunks)test/e2e/v1_api_balances_test.go
(3 hunks)test/performance/pkg/env/env.go
(0 hunks)test/performance/pkg/env/env_remote_ledger.go
(2 hunks)test/performance/pkg/write/local_env_test.go
(3 hunks)test/stress/stress_test.go
(2 hunks)test/stress/suite_test.go
(4 hunks)
💤 Files with no reviewable changes (1)
- test/performance/pkg/env/env.go
🚧 Files skipped from review as they are similar to previous changes (8)
- pkg/testserver/client.go
- test/e2e/api_ledgers_list_test.go
- test/e2e/app_logs_blocks_async_test.go
- test/performance/pkg/env/env_remote_ledger.go
- test/performance/pkg/write/local_env_test.go
- pkg/testserver/matchers.go
- test/e2e/api_transactions_create_test.go
- pkg/testserver/api.go
🧰 Additional context used
🧬 Code Definitions (19)
test/e2e/api_transactions_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_transactions_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_bulk_test.go (3)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/api.go (1)
CreateLedger
(17-20)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_volumes_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
test/e2e/api_accounts_metadata_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/e2e/api_balances_aggregated_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_accounts_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_ledgers_metadata_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/api_transactions_revert_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
Subscribe
(77-88)
test/stress/stress_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(10-15)
test/e2e/api_ledgers_create_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(111-113)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(10-15)
pkg/testserver/server.go (1)
cmd/serve.go (4)
ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/api_logs_list_test.go (1)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)
test/e2e/v1_api_balances_test.go (2)
pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/client.go (1)
Client
(8-12)
test/e2e/api_ledgers_import_test.go (3)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(111-113)pkg/testserver/utils.go (1)
DeferTestServer
(18-25)pkg/testserver/helpers.go (1)
ConnectToDatabase
(64-75)
test/stress/suite_test.go (2)
internal/storage/driver/driver.go (1)
New
(285-302)pkg/client/formance.go (1)
New
(144-181)
pkg/generate/generator_test.go (3)
pkg/testserver/utils.go (1)
NewTestServer
(27-34)pkg/testserver/client.go (1)
Client
(8-12)pkg/testserver/api.go (1)
CreateLedger
(17-20)
internal/storage/ledger/main_test.go (2)
internal/storage/system/store.go (1)
New
(133-143)internal/storage/driver/main_test.go (1)
TestMain
(28-44)
🪛 GitHub Actions: Default
pkg/testserver/helpers.go
[error] 8-8: missing go.sum entry for module providing package github.com/formancehq/go-libs/v2/testing/deferred (imported by github.com/formancehq/ledger/pkg/testserver); to add: go get github.com/formancehq/ledger/pkg/testserver
🔇 Additional comments (78)
test/e2e/api_transactions_list_test.go (2)
35-42
: Improved test server configuration with deferred initializationThe refactoring from direct instantiation to using
DeferTestServer
with deferred database connection options and modular instrumentation is a good improvement. This approach provides better separation of concerns and more flexibility in test configuration.
10-13
: Appropriate import updates to support the new test infrastructureThe added imports for
deferred
,pgtesting
, andtestservice
packages properly support the updated test server initialization pattern.test/e2e/api_logs_list_test.go (2)
9-11
: Appropriate import updates to support the new test infrastructureThe added imports for the
deferred
,pgtesting
, andtestservice
packages correctly support the updated test server initialization.
28-35
: Improved test server configuration with deferred initializationThe refactoring from direct instantiation to using
DeferTestServer
with deferred database connection options and modular instrumentation is a good improvement. This approach follows the same consistent pattern applied in other test files.test/stress/stress_test.go (2)
7-8
: Appropriate import updates for the stress testsThe added imports for
deferred
andtestservice
packages properly support the new test server initialization pattern.
32-37
: Streamlined stress test configuration with experimental featuresGood refactoring to use the deferred test server approach with specialized experimental features instrumentation. This simplifies the configuration while maintaining the necessary experimental features for stress testing.
test/e2e/api_transactions_metadata_test.go (2)
8-10
: Appropriate import updates to support the new test infrastructureThe added imports for
deferred
,pgtesting
, andtestservice
packages correctly support the new test server initialization approach.
27-34
: Improved test server configuration with deferred initializationThe refactoring to use
DeferTestServer
with deferred database connection options and modular instrumentation follows the consistent pattern applied across the test suite. This change enhances the configurability and maintainability of the tests.test/e2e/api_balances_aggregated_test.go (2)
7-10
: New imports for deferred testing infrastructure.These imports from go-libs/v2 bring in the deferred testing functionality which allows for lazy initialization of test components.
27-34
: Improved test server initialization with deferred approach.The test server initialization has been refactored to use the
DeferTestServer
function which provides a cleaner separation of concerns:
- Database connection is handled via a deferred mapping
- Instrumentation is configured with dedicated functions
- Logger is set up in a standardized way
This refactoring reduces boilerplate and improves maintainability compared to the previous approach.
test/e2e/api_ledgers_metadata_test.go (2)
6-9
: Added imports for standardized testing infrastructure.The new imports bring in the deferred testing patterns from go-libs/v2, aligning this test file with the standardized approach.
22-29
: Refactored server initialization with standardized pattern.The test server initialization now uses the
DeferTestServer
function with structured configurations for:
- Database connection options through deferred mapping
- Debugging and output instrumentation
- Standardized logger setup
This change improves maintainability by following a consistent pattern across test files.
test/e2e/api_transactions_revert_test.go (4)
6-9
: Imported standardized testing infrastructure.These imports bring in the deferred testing patterns from go-libs/v2, specifically including support for NATS testing.
31-32
: Added deferred NATS URL mapping.The NATS URL is now properly obtained using a deferred mapping, which allows for lazy evaluation and better encapsulation of the NATS server details.
34-42
: Comprehensive test server setup with instrumentation.The test server initialization has been updated to:
- Use deferred database connection options
- Configure multiple instrumentation options including NATS
- Set up standardized logging
This approach provides better separation of concerns and consistent test setup across the codebase.
58-58
: Updated NATS subscription to use standardized pattern.The subscription now discards the first return value (subscription object) and directly captures the events channel, using the deferred NATS URL consistently with the server setup.
test/e2e/api_bulk_test.go (5)
9-12
: Added imports for comprehensive testing infrastructure.These imports bring in the deferred testing infrastructure from go-libs/v2, including support for PostgreSQL and NATS testing.
40-41
: Configured deferred NATS URL mapping.The NATS URL is now obtained using a deferred mapping, which allows for lazy evaluation and better encapsulation of the NATS server configuration.
43-51
: Comprehensive test server initialization with all required instrumentation.The test server setup now uses a standardized pattern with:
- Deferred database connection options
- NATS instrumentation for event publishing/subscription
- Debug and output instrumentation
- Standard logger configuration
This approach provides better modularity and consistency across tests.
58-58
: Updated event subscription to use standardized pattern.The subscription now discards the first return value (subscription object) and directly captures the events channel, using the same deferred NATS URL that was configured with the server.
248-248
: Updated HTTP request URL construction.Now using
testservice.GetServerURL(testServer.GetValue())
to obtain the server URL for creating HTTP requests, which provides a more consistent approach across the codebase.test/e2e/api_accounts_list_test.go (1)
9-12
: Improved test server initialization with deferred pattern.The refactoring moves from a monolithic test server configuration to a more modular approach using deferred values. This change leverages the go-libs testing utilities to provide better separation of concerns between database connectivity, instrumentation, and logging.
The new approach:
- Uses
DeferMap
to handle database connection options- Configures multiple instrumentation components (Nats, Debug, Output)
- Sets up proper logging with GinkgoT()
This makes the test setup more maintainable and composable.
Also applies to: 33-41
pkg/testserver/worker.go (3)
4-7
: Simplified imports align with the reduced scope of the file.The imports have been significantly reduced to match the new, more focused functionality of this file after removing the Worker struct implementation.
10-15
: Added well-structured instrumentation function for logs hash block max size.This new function follows the instrumentation pattern used throughout the codebase, providing a clean way to configure the worker's block hasher size through command-line arguments.
The implementation correctly:
- Creates a closure that accepts context and run configuration
- Appends the appropriate command-line arguments
- Returns nil to satisfy the function signature
17-22
: Added well-structured instrumentation function for logs hash block CRON spec.This function mirrors the pattern of the previous function, maintaining consistency in how instrumentation is configured throughout the application.
The implementation correctly configures the CRON schedule for the asynchronous block hasher through command-line arguments.
test/e2e/api_volumes_test.go (1)
8-10
: Consistent application of the deferred test server pattern.This change aligns with the application-wide refactoring to use the go-libs test server. The implementation follows the same pattern seen in other test files, providing consistency across the test suite.
The refactoring:
- Adds the necessary imports for deferred values and test services
- Configures the test server with appropriate instrumentation options
- Maintains the same test behavior while improving the underlying implementation
Also applies to: 37-44
test/e2e/api_ledgers_import_test.go (2)
10-12
: Improved test setup with explicit context and connection management.The refactoring enhances the test setup by clearly separating database connection, context creation, and test server configuration, making the test more maintainable and the resource management more explicit.
The new implementation:
- Creates a dedicated testing context using
logging.TestingContext()
- Uses deferred mapping for database connection options
- Configures the test server with appropriate instrumentation, including experimental features
Also applies to: 26-39
341-341
: Updated database connection to use the new connection options.This change correctly adapts the database connection to use the context and connection options defined earlier in the test, ensuring proper resource management and cleanup.
The updated
ConnectToDatabase
call aligns with the broader refactoring approach by using the context and connection options rather than extracting these from the test server.pkg/generate/generator_test.go (3)
25-33
: Server initialization is now more modular and explicitThe refactored server initialization improves modularity by using
deferred.FromValue
for database connection options and explicitly configuring instrumentation. This approach aligns with the broader refactoring to use test servers from go-libs.
39-40
: Client retrieval is now decoupled from the serverChanged from direct access via
testServer.Client()
to a standaloneClient(testServer)
function. This separation of concerns allows for more flexibility and better testability.
55-56
: Client access consistent with the new patternThe client access pattern is consistently applied here, matching the change in line 39, which maintains code consistency.
test/e2e/api_ledgers_create_test.go (2)
29-38
: Cleaner test server initialization with explicit instrumentationThe refactored code uses
DeferTestServer
with explicit instrumentation options, providing a more modular approach to server configuration. This is more maintainable than the previous nested configuration structure.
24-27
: Clean variable declarations with proper context handlingThe test setup variables are now cleanly defined, with database access via
UseTemplatedDatabase()
and a properly established testing context.test/e2e/v1_api_balances_test.go (2)
28-35
: Server configuration follows the new pattern consistentlyThe test server initialization is consistent with the approach used in other test files, with proper deferred mapping of database connection options and explicit instrumentation setup.
80-81
: Client access follows new pattern for consistencyChanged from using
testServer.GetValue().Client()
toClient(testServer.GetValue())
for accessing the Ledger API, maintaining consistency with the new pattern used throughout the codebase.test/e2e/app_multiple_instance_test.go (4)
26-27
: Updated type for better compatibility with test service frameworkThe type of
allServers
has been updated from a slice of*Server
to a slice of*testservice.Service
, reflecting the transition to the new service abstraction.
28-29
: Channel type updated for consistencyThe
servers
channel now correctly uses*testservice.Service
to match the updated server type.
40-48
: Modernized server creation with explicit optionsThe server instantiation has been updated to use
testservice.New
with the command and options pattern, which is more modular and configurable than the previous approach.
65-66
: Client access updated for consistency with new patternUpdated from
server.Client()
toClient(server)
to maintain consistency with the new client access pattern used throughout the codebase.test/e2e/api_accounts_metadata_test.go (4)
7-10
: New imports support deferred execution and platform testing.The added imports from go-libs/v2 introduce support for deferred execution patterns and platform-specific testing utilities, which aligns with the updated testing approach used throughout the codebase.
24-24
: Good use of deferred mapping for NATS URL.Using
deferred.DeferMap
to extract the client URL from the NATS server creates a clean dependency chain and properly handles the asynchronous nature of service initialization.
27-35
: Server initialization refactored to use deferred pattern.The server initialization has been elegantly refactored to use the
DeferTestServer
function with appropriate instrumentation options. This approach provides better separation of concerns and makes testing more modular.
38-38
: Updated Subscribe usage properly handles subscription.The Subscribe function now correctly discards the subscription object and only keeps the message channel, which matches the updated signature from the referenced helper. This ensures proper resource management.
pkg/testserver/server.go (4)
10-15
: Well-structured instrumentation for experimental features.This function cleanly encapsulates the instrumentation for enabling experimental features. The closure pattern allows for clean command-line argument construction when needed.
17-22
: Consistent pattern for numscript rewrite instrumentation.Following the same pattern as other instrumentation functions creates a consistent API for feature flagging. This approach makes it easy to add or modify experimental features in the future.
24-29
: Parameterized instrumentation for max page size.This implementation allows for flexible configuration of the max page size parameter during testing. The use of a closure with a parameter creates a clean, reusable API.
31-36
: Parameterized instrumentation for default page size.Similar to the max page size instrumentation, this function provides a clean way to configure the default page size for testing. The consistent pattern across all instrumentation functions makes the API intuitive.
pkg/testserver/utils.go (4)
10-16
: Well-structured test server options factory.This function encapsulates the common configuration needed for test servers, including HTTP server setup and database connection options, making the server creation process more maintainable.
18-25
: Clean implementation of deferred test server creation.The
DeferTestServer
function properly utilizes the deferred pattern to allow for lazy initialization of server resources. The function composes well with the options pattern, allowing for flexible configuration.
27-34
: Direct test server creation complements deferred approach.Providing both deferred and direct initialization methods (
NewTestServer
alongsideDeferTestServer
) gives test authors flexibility in how they manage server lifecycles based on their specific test needs.
36-46
: Worker-specific deferred initialization.The
DeferTestWorker
function follows the same pattern asDeferTestServer
but with worker-specific configuration. This consistency makes the API predictable while still allowing for specialized behavior.test/stress/suite_test.go (4)
24-25
: Updated deferred variable initialization.The variables now use the more modern
deferred.New
approach instead ofNewDeferred
, which aligns with the broader refactoring to use the updated deferred library.
34-34
: Enhanced test suite setup with context support.The
SynchronizedBeforeSuite
function now accepts aSpecContext
parameter, which enables better context handling and timeout management during test suite initialization.
38-48
: Improved error handling in async PostgreSQL server initialization.The
LoadAsync
callback now properly returns both the PostgreSQL server and an error value, allowing for better error handling during the asynchronous loading process. This is a significant improvement over the previous implementation.
51-51
: Context-aware waiting for service readiness.Using
deferred.WaitContext
with the spec context ensures proper timeout handling and cancellation support when waiting for the PostgreSQL server to be ready. This is more robust than the previous approach.pkg/testserver/helpers.go (3)
4-5
: New imports introduced for context and bunconnectThese import statements facilitate the integration of context-driven database connection handling. No immediate concerns.
64-68
: Test-only database connection functionThe new
ConnectToDatabase
function correctly uses thedbOptions
from deferred, ensures the DB is closed on test cleanup, and fails fast if an error occurs. This pattern is clean and straightforward for test environments.Also applies to: 72-72, 74-74
8-9
:❓ Verification inconclusive
Missing go.sum entry for deferred package
The pipeline indicates a missing
go.sum
entry forgithub.com/formancehq/go-libs/v2/testing/deferred
. Please run the necessary commands (e.g.,go mod tidy
) to ensure proper dependency resolution.Below is a script you can use to verify the references and fix the missing module entry:
🏁 Script executed:
#!/bin/bash # Description: Attempt to fix and verify the missing go.sum entry for deferred package. go get github.com/formancehq/go-libs/v2/testing/deferred@latest go mod tidy # Verify that the go.sum file now contains the required module. grep "github.com/formancehq/go-libs/v2/testing/deferred" go.sumLength of output: 730
Dependency Resolution Issue: Verify Module Initialization
The error messages indicate that the commands were executed outside a valid Go module context (i.e., nogo.mod
file was found). Please ensure that you run the dependency update commands from the root of a Go module. If necessary, initialize the module withgo mod init <module>
before executing:
go get github.com/formancehq/go-libs/v2/testing/deferred@latest
go mod tidy
Once in the correct directory, re-run these commands and verify that
go.sum
contains the required entry for the deferred package.🧰 Tools
🪛 GitHub Actions: Default
[error] 8-8: missing go.sum entry for module providing package github.com/formancehq/go-libs/v2/testing/deferred (imported by github.com/formancehq/ledger/pkg/testserver); to add: go get github.com/formancehq/ledger/pkg/testserver
internal/storage/ledger/main_test.go (3)
8-8
: Deferred package import for async loadingThis import provides the asynchronous loading of resources. Address the missing
go.sum
entry if not already resolved.
33-35
: Deferred initialization for Postgres server, bun.DB, and driverUsing
deferred.New[...]()
clarifies resource creation order. Looks consistent with the broader refactoring.
40-40
: LoadAsync usage for server and DBThese changes properly handle deferred loading with optional error returns. Great for improving error handling in test setup.
Also applies to: 45-45, 67-67, 69-69
test/e2e/app_lifecycle_test.go (10)
12-13
: New imports for deferred, NATS testing, and net/httpThese imports support the new test architecture and HTTP checks for health endpoints. No issues noted.
Also applies to: 15-15, 31-31
41-44
: DeferMap usage for connection optionsMapping the
pgtesting.Database
tobunconnect.ConnectionOptions
is a clean approach to customizing DB parameters for tests.
48-55
: DeferTestServer for dynamic server setupSwitching to the new deferred approach centralizes and defers test server creation with instrumentation. This improves modularity.
65-65
: Client operations and server restartsThe updated calls (
Client(...)
,Restart(ctx)
, explicit DB connection) demonstrate a clearer test lifecycle. No immediate issues.Also applies to: 71-71, 91-91
149-152
: Stop and Start with custom context timeoutExplicitly setting a
stopContext
for shutdown is a best practice for graceful stops. This logic is well-structured for e2e tests.
210-217
: Second DeferTestServer usageThis mirrors the earlier approach, reinforcing the internal standard for test server creation. Clean and consistent.
250-251
: Templated database usage for second contextReusing
UseTemplatedDatabase
ensures consistent database states across tests. No issues noted.
255-261
: Second testServer with individual instrumentation configurationSimilar to the earlier
DeferTestServer
usage. Maintaining uniform patterns here helps with code readability.
279-279
: ConnectToDatabase call for migration insertion testsDirectly establishing a DB connection to manipulate migrations is consistent with the rest of the testing strategy.
297-297
: Health check endpoint verificationCalling
/_healthcheck
is straightforward to confirm app health. Good practice for e2e coverage.test/e2e/suite_test.go (7)
9-9
: Import addition aligns with refactoring strategy.The addition of the
deferred
package import is consistent with the PR objectives of refactoring test server implementation with resources from go-libs.
30-32
: Good refactoring to use standardized deferred pattern.The change from custom deferred implementations to using the standardized
deferred.New[T]()
function improves consistency and maintainability. This aligns with the PR's objective to leverage the go-libs test server infrastructure.
44-46
: Improved error handling with Ginkgo integration.The addition of
deferred.RegisterRecoverHandler(GinkgoRecover)
enhances error handling by properly integrating with Ginkgo's recovery mechanism. ThespecContext
parameter also enables context-aware operations which is a good practice.
50-50
: Better error handling in asynchronous loading.The modified signature to return an error alongside the server instance improves error handling. This change follows Go's idiomatic approach of explicitly returning errors rather than panicking or handling errors internally.
Also applies to: 75-75
78-78
: Consistent error handling pattern for natsServer.Similar to the pgServer changes, this modification ensures a consistent error handling pattern is applied across all service initializations.
Also applies to: 82-82
86-86
: Context-aware waiting mechanism.The updated waiting mechanism using
deferred.WaitContext
properly passes the context to the waiting process, which is important for cancellation and timeout handling. This is an improvement over the previous implementation.
111-111
: Updated return type for consistency.The return type change to
*deferred.Deferred[*Database]
correctly aligns with the new deferred package structure, maintaining type safety and enabling proper use of the deferred pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
test/e2e/api_ledgers_list_test.go (1)
59-69
:⚠️ Potential issueMismatch in test name versus expected count.
The
It
block states "should return 5 ledgers" but the assertion expectsHaveLen(10)
. This discrepancy may confuse maintainers and can cause future misunderstandings.Below is a suggested fix to align the title with the code:
- It("filtering on bucket should return 5 ledgers", func() { + It("filtering on bucket should return 10 ledgers", func() {
🧹 Nitpick comments (4)
pkg/testserver/server.go (1)
20-27
: Check for potential initialization errors.
NewTestServer()
gracefully aggregates default and user-provided options, but it doesn’t appear to handle errors iftestservice.New
fails. Consider returning or logging possible errors for better observability.pkg/testserver/client.go (1)
9-13
: Client creation without explicit error handling.
TheClient
function directly returns a newledgerclient.Formance
. Consider logging or handling potential edge cases (e.g., invalid server URL).test/e2e/api_ledgers_import_test.go (1)
264-273
: Consider standardizing error handling in helper functionsWhile the error is properly checked in the calling function, consider standardizing the error handling approach in the importLogs helper function to match the pattern used throughout the rest of the file.
- return err + Expect(err).To(Succeed()) + return niltest/e2e/api_transactions_create_test.go (1)
599-604
: Different access pattern for V1 APIThis section uses a different pattern (
testServer.Wait(specContext)
followed byClient(testServer)
) compared to theWait(specContext, DeferClient(testServer))
pattern used elsewhere. While this works correctly for the V1 API, consider standardizing the approach for consistency.Consider updating to use the consistent pattern:
- testServer, err := testServer.Wait(specContext) - Expect(err).To(BeNil()) - - response, err = Client(testServer).Ledger.V1.CreateTransaction( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V1.CreateTransaction(
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (26)
pkg/generate/generator_test.go
(3 hunks)pkg/testserver/api.go
(0 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/ginkgo/helpers.go
(1 hunks)pkg/testserver/ginkgo/matchers.go
(3 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)test/e2e/api_accounts_list_test.go
(18 hunks)test/e2e/api_accounts_metadata_test.go
(7 hunks)test/e2e/api_balances_aggregated_test.go
(7 hunks)test/e2e/api_bulk_test.go
(9 hunks)test/e2e/api_ledgers_create_test.go
(4 hunks)test/e2e/api_ledgers_import_test.go
(11 hunks)test/e2e/api_ledgers_list_test.go
(7 hunks)test/e2e/api_ledgers_metadata_test.go
(3 hunks)test/e2e/api_logs_list_test.go
(10 hunks)test/e2e/api_transactions_create_test.go
(13 hunks)test/e2e/api_transactions_list_test.go
(48 hunks)test/e2e/api_transactions_metadata_test.go
(4 hunks)test/e2e/api_transactions_revert_test.go
(8 hunks)test/e2e/api_volumes_test.go
(13 hunks)test/e2e/app_lifecycle_test.go
(11 hunks)test/e2e/app_logs_blocks_async_test.go
(5 hunks)test/e2e/suite_test.go
(5 hunks)test/e2e/v1_api_balances_test.go
(4 hunks)test/stress/stress_test.go
(8 hunks)
💤 Files with no reviewable changes (1)
- pkg/testserver/api.go
🚧 Files skipped from review as they are similar to previous changes (3)
- test/e2e/app_logs_blocks_async_test.go
- test/e2e/v1_api_balances_test.go
- test/e2e/suite_test.go
🧰 Additional context used
🧬 Code Definitions (19)
test/e2e/api_transactions_list_test.go (4)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)internal/controller/ledger/controller.go (1)
CreateTransaction
(84-87)internal/storage/common/resource.go (1)
ColumnPaginatedQuery
(405-414)
test/e2e/api_ledgers_list_test.go (4)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/server.go (2)
MaxPageSizeInstrumentation
(43-48)DefaultPageSizeInstrumentation
(50-55)pkg/testserver/client.go (1)
DeferClient
(15-17)pkg/client/models/operations/v2listledgers.go (1)
V2ListLedgersRequest
(9-20)
pkg/testserver/ginkgo/matchers.go (1)
pkg/testserver/client.go (1)
Client
(9-13)
test/e2e/api_volumes_test.go (2)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/e2e/api_balances_aggregated_test.go (2)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/e2e/api_logs_list_test.go (2)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/stress/stress_test.go (6)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)pkg/client/ledger.go (1)
Ledger
(19-24)pkg/client/v2.go (1)
V2
(19-21)pkg/client/models/operations/v2createledger.go (1)
V2CreateLedgerRequest
(9-13)pkg/testserver/ginkgo/matchers.go (1)
HaveCoherentState
(78-80)
test/e2e/api_ledgers_metadata_test.go (2)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/e2e/api_transactions_metadata_test.go (2)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/e2e/api_ledgers_import_test.go (8)
test/e2e/suite_test.go (2)
UseTemplatedDatabase
(114-116)ConnectToDatabase
(118-125)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)pkg/client/models/operations/v2importlogs.go (1)
V2ImportLogsRequest
(9-14)pkg/client/models/operations/v2listlogs.go (1)
V2ListLogsRequest
(11-25)pkg/client/models/operations/v2listtransactions.go (1)
V2ListTransactionsRequest
(36-53)pkg/client/models/operations/v2listaccounts.go (1)
V2ListAccountsRequest
(11-26)pkg/client/models/operations/v2addmetadataontransaction.go (1)
V2AddMetadataOnTransactionRequest
(11-22)
pkg/generate/generator_test.go (2)
pkg/testserver/server.go (1)
NewTestServer
(20-27)pkg/testserver/client.go (1)
Client
(9-13)
test/e2e/api_bulk_test.go (5)
pkg/client/models/operations/v2createbulk.go (2)
V2CreateBulkResponse
(56-60)V2CreateBulkRequest
(9-19)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)test/e2e/suite_test.go (1)
Subscribe
(127-142)pkg/testserver/utils.go (1)
ConvertSDKTxToCoreTX
(11-29)
pkg/testserver/ginkgo/helpers.go (1)
pkg/testserver/server.go (1)
GetTestServerOptions
(12-18)
test/e2e/api_transactions_create_test.go (8)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(114-116)pkg/testserver/server.go (1)
ExperimentalNumscriptRewriteInstrumentation
(36-41)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (2)
DeferClient
(15-17)Client
(9-13)pkg/client/models/components/v2posttransaction.go (1)
V2PostTransaction
(29-36)internal/controller/ledger/controller.go (1)
CreateTransaction
(84-87)test/e2e/api_volumes_test.go (1)
Transaction
(22-28)pkg/testserver/utils.go (1)
ConvertSDKTxToCoreTX
(11-29)
pkg/testserver/server.go (1)
cmd/serve.go (5)
BindFlag
(58-58)ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
test/e2e/api_ledgers_create_test.go (5)
test/e2e/suite_test.go (1)
UseTemplatedDatabase
(114-116)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/server.go (1)
ExperimentalFeaturesInstrumentation
(29-34)pkg/testserver/client.go (1)
DeferClient
(15-17)pkg/client/models/operations/v2createledger.go (1)
V2CreateLedgerRequest
(9-13)
test/e2e/api_accounts_metadata_test.go (3)
test/e2e/suite_test.go (2)
UseTemplatedDatabase
(114-116)Subscribe
(127-142)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
test/e2e/app_lifecycle_test.go (3)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)test/e2e/suite_test.go (3)
Subscribe
(127-142)ConnectToDatabase
(118-125)UseTemplatedDatabase
(114-116)pkg/testserver/client.go (1)
Client
(9-13)
test/e2e/api_transactions_revert_test.go (3)
test/e2e/suite_test.go (2)
UseTemplatedDatabase
(114-116)Subscribe
(127-142)pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)
🔇 Additional comments (136)
pkg/testserver/utils.go (1)
7-7
: Confirm the renamed ledger import.
This updated import path forledger
appears consistent with the usage below. Ensure that all references elsewhere in the codebase correctly targetgithub.com/formancehq/ledger/internal
.pkg/testserver/server.go (6)
7-8
: New imports for deferred and testservice.
These imports facilitate the deferred testing and service instrumentation model. Looks good.
12-17
: Streamlined test server options.
Usingtestservice.WithInstruments
centralizes the instrumentation logic, improving maintainability.
29-34
: Experimental features flag.
Appending the--experimental-features
flag is well-organized and in line with the new instrumentation model.
36-41
: Numscript rewrite instrumentation.
Clean addition of the--experimental-numscript-interpreter
flag for toggling the new interpreter.
43-48
: Configure maximum page size.
Straightforward approach to passing--max-page-size
. Implementation appears correct.
50-55
: Configure default page size.
Similarly, this instrumentation logic for setting--default-page-size
is concise and consistent.pkg/testserver/client.go (2)
1-8
: New file for client utilities.
Defining a dedicated file for the client-related logic keeps the test server responsibilities cohesive and maintainable.
15-17
: Deferred client.
Mapping the deferred test server to a deferred client is a neat pattern to ensure correct initialization order.test/e2e/api_ledgers_list_test.go (7)
9-15
: Imports look consistent with the new deferred test approach.All newly introduced imports for
ginkgo.DeferTestServer
,pgtesting
, andtestservice
are fitting well into the codebase. This change aligns with the PR objective to replace direct server instantiation with deferred patterns.
26-35
: Deferred server initialization is clear and well-structured.Using
ginkgo.DeferTestServer
withDeferMap(db, (*pgtesting.Database).ConnectionOptions)
plus relevant instrumentation simplifies test setup and is consistent with the updated architecture.
37-40
: Check for potential syntax error in Go loop.Line 39 (unmodified) shows
for i := range 20 { ... }
, which is not valid Go syntax. The typical approach isfor i := 0; i < 20; i++ { ... }
. If the code truly compiles as written, please confirm it is correct and not an accidental leftover from pseudocode.Would you like me to open an issue or generate a fix to standardize this loop?
53-57
: Test coverage for unfiltered listing is correct.This block checks pagination limiting returned ledgers to 15 out of 20 total. The approach is valid; no issues found.
71-81
: Filtering on metadata yields correct test logic."Should return 7 ledgers" matches the
HaveLen(7)
assertion. Looks good.
83-93
: Single-ledger filter is accurate.The test name "should return 1 ledger" aligns correctly with the check
HaveLen(1)
. Implementation is consistent.
95-105
: String prefix filtering works fine."Should return 11 ledger" aligns with
HaveLen(11)
after verifying naming logic. Code is correct.test/e2e/api_balances_aggregated_test.go (4)
8-10
: Refactored imports and usage of ginkgo DeferTestServer.These import changes and references to
DeferTestServer
remain consistent with the new test approach.Also applies to: 14-14
28-35
: Deferred server setup is clean and maintainable.This block demonstrates a proper usage of
ginkgo.DeferTestServer
with instrumentation.
39-46
: Transaction creation logic and result checks appear solid.Initialization of ledger "default" and capturing returned data in
ret
is straightforward. TrackingfirstTransactionsInsertedAt
ensures correct point-in-time references later.Also applies to: 106-108
127-128
: Aggregation tests are consistent and correct.Pit-based, metadata-based, and insertion-time tests produce the expected ledger balance states. All assertions match the described scenarios.
Also applies to: 141-142, 144-145, 159-160, 162-163, 178-179
test/e2e/api_transactions_list_test.go (5)
11-13
: New imports align with deferred client patterns.The updated test framework imports and references to
DeferTestServer
andDeferClient
are consistent with the PR’s deferred architecture.Also applies to: 19-19
36-43
: Deferred test server initialization is appropriately parameterized.Mapping PostgreSQL connection options, applying instrumentation, and deferring the server is a solid approach.
45-46
: Creation and listing of transactions integrate well with the new model.Using
Wait(specContext, DeferClient(testServer))
for ledger operations effectively decouples test steps from immediate server instantiation while supporting asynchronous test flows.Also applies to: 61-72, 99-99, 108-108, 137-137
149-150
: Pagination and cursor logic validation is thorough.Filtering on references, verifying next/previous cursors, and stable pagination checks are well-executed. Code coverage looks robust.
Also applies to: 158-158, 163-164, 167-168, 171-175, 177-178, 200-200, 209-210, 212-212, 214-215, 217-217, 224-226, 234-239
272-273
: Transaction count and list tests demonstrate robust coverage.All added lines confirm metadata filters, range queries,
$gt
/$lt
checks, and ensure correct responses for edge cases (e.g., empty sets). The code is logically consistent.Also applies to: 345-347, 351-352, 372-373, 392-393, 412-413, 414-414, 420-420, 422-423, 424-424, 430-430, 434-434, 436-438, 444-444, 448-448, 450-452, 462-462, 464-466, 476-476, 478-480, 490-490, 492-494, 504-504, 506-508, 518-518, 520-522, 532-532, 534-536, 546-546, 560-560, 562-564, 574-574, 576-578, 588-588, 590-592, 602-602, 604-606, 616-616, 618-619, 627-631, 632-634, 645-649, 650-652, 663-664, 665-667, 678-682, 683-685, 696-697, 698-700, 711-712, 713-715, 726-730, 731-733, 744-747, 748-750, 761-762, 763-765, 776-779, 780-782, 793-795, 796-798, 809-810, 811-813, 824-827, 828-830, 841-843, 844-846, 857-858, 860-861, 888-898, 909-910, 913-913, 916-917, 918-918, 920-920, 922-924, 930-930, 932-934, 940-941
pkg/generate/generator_test.go (4)
25-33
: Well-structured test server initializationThe refactor to use
NewTestServer
with deferred connection options provides a cleaner, more modular approach to test setup. The explicit instrumentation configuration improves test maintainability.
39-42
: Updated client access patternThe change from
testServer.Client().Ledger.V2
toClient(testServer).Ledger.V2
aligns with the new pattern of accessing the client through a standalone function rather than a method, which is more consistent with the rest of the codebase.
55-56
: Consistent client access patternThis change maintains the same client access pattern throughout the file, improving consistency and readability.
59-65
: Updated response accessThe change in accessing cursor data fields matches the updated client API structure. This ensures proper access to transaction data in the response.
pkg/testserver/ginkgo/helpers.go (2)
12-19
: Well-designed server initialization helperThe
DeferTestServer
function effectively encapsulates the common pattern of creating a test server with PostgreSQL connection options. This simplifies test setup across the codebase and promotes consistency.
21-31
: Good abstraction for worker initializationThe
DeferTestWorker
function provides a clean abstraction for initializing test workers with the appropriate configuration. The consistent pattern withDeferTestServer
makes the API intuitive and easy to use.test/e2e/api_bulk_test.go (8)
9-17
: Well-structured import changesThe updated imports properly reflect the shift to using the deferred testing patterns and centralizing test server management.
40-43
: Improved variable declaration for natsURLUsing
ginkgo.DeferMap
for the NATS URL provides a clean way to transform the server into just its client URL, maintaining consistency with the deferred pattern used elsewhere.
45-53
: Enhanced test server configurationThe updated server initialization with
DeferTestServer
provides a more modular approach with explicit configuration for NATS, debugging, output, and logging. This improves maintainability and readability.
55-61
: Context-aware BeforeEachAdding
specContext
parameter toBeforeEach
and usingWait
withDeferClient
ensures proper context management and consistent client access patterns.
109-116
: Consistent client access in JustBeforeEachThe update to use
Wait(specContext, DeferClient(testServer))
ensures consistent client access patterns throughout the file and proper handling of the deferred service.
250-254
: Improved server URL accessUsing
testservice.GetServerURL(testServer)
centralizes the method of obtaining the server URL, enhancing consistency in the test setup.
264-268
: Consistent client access in assertionsThe change to use
Wait(specContext, DeferClient(testServer))
in the assertions ensures the same client access pattern is used throughout the file.
330-330
: Updated transaction conversionThe access to the transaction data via
bulkResponse.V2BulkResponse.Data[0].V2BulkElementResultCreateTransaction.Data
reflects the updated structure of the bulk response, ensuring proper data access.test/stress/stress_test.go (7)
7-10
: Updated imports for deferred testingThe imports have been updated to use the deferred testing patterns from go-libs and the new ginkgo helpers.
33-38
: Simplified test server configurationThe refactored server initialization with
DeferTestServer
andDeferMap
provides a cleaner, more maintainable approach to setting up the test environment.
48-61
: Context-aware BeforeEach with consistent client accessThe updated
BeforeEach
function withSpecContext
parameter and the use ofWait(ctx, DeferClient(testServer))
ensures proper context management and consistent client access.
75-101
: Updated transaction ID accessThe access to the transaction ID via
createdTx.V2CreateTransactionResponse.Data.ID
reflects the updated structure of the transaction response, ensuring proper data access.
111-112
: Cleaner state verificationUsing
Expect(testServer).To(HaveCoherentState())
directly is more readable and concise than callingGetValue()
first.
133-143
: Consistent client access in revert operationThe use of
Wait(ctx, DeferClient(testServer))
for the revert operation ensures the same client access pattern is used throughout the file.
153-154
: Consistent state verificationThe second use of
Expect(testServer).To(HaveCoherentState())
maintains the consistent pattern established earlier in the file.test/e2e/api_ledgers_metadata_test.go (14)
7-9
: Import reorganization looks good
Using thedeferred/ginkgo
package ensures a more modern approach for managing test servers. No issues found.
12-12
: Alignment with new testserver ginkgo module
Importing the ginkgo sub-package of testserver is consistent with the new deferred testing strategy, aiding uniform test configuration.
23-30
: Adoption of ginkgo.DeferTestServer
Migrating toginkgo.DeferTestServer
promotes more streamlined server setup and test instrumentation. This approach is consistent and recommended.
33-34
: SpecContext usage recognized
IntroducingspecContext
inBeforeEach
aligns with Ginkgo v2 best practices, improving test scoping and concurrency management.
43-43
: Error checking
Expect(err).To(BeNil())
is a valid pattern for confirming ledger creation success.
46-46
: Metadata request
RequestBody: m
properly supplies metadata for the ledger. Implementation seems correct.
49-49
: Confirmation of error
Expect(err).To(BeNil())
usage is appropriate here.
50-51
: Transitional test step
Ensuring that the updated ledger metadata is fetched withIt("should be ok", ...)
. This integrates well with the deferred test server usage.
55-55
: Validating ledger metadata
Expect(ledger.V2GetLedgerResponse.Data.Metadata).To(Equal(m))
correctly verifies the updated metadata.
58-58
: Setting up deletion
AnotherBeforeEach
for wiping metadata confirms thorough coverage of ledger states.
59-59
: Deferred deletion
Wait(specContext, DeferClient(testServer)).Ledger.V2.DeleteLedgerMetadata(...)
is consistent with the new asynchronous test approach.
63-63
: Error check
Expect(err).To(BeNil())
is straightforward and clear for confirming no failures occurred.
65-66
: Validation of deletion
ThisIt
block verifies that the ledger's metadata is empty post-deletion, ensuring correctness.
70-70
: Final check
Expect(ledger.V2GetLedgerResponse.Data.Metadata).To(BeEmpty())
solidly confirms metadata removal.pkg/testserver/ginkgo/matchers.go (4)
1-1
: Package reorganization
Definingpackage ginkgo
clarifies the specialized matchers and ensures they’re clearly tied to Ginkgo-based testing.
10-11
: Deferred and testservice imports
Including these packages aligns with the shift to the new deferred test server strategy, enhancing modular test code.
13-13
: Importing testserver
Access totestserver.Client()
within the matcher simplifies obtaining the ledger client, removing manual server references.
26-67
: Refactored HaveCoherentStateMatcher
TheWait
call on the deferred server ensures readiness before performing validation. Checking ledgers and aggregated balances or fallback transactions is a robust test flow. This refactor is well-structured and aligns with the deferred approach.test/e2e/api_logs_list_test.go (32)
9-11
: Updated imports
The new imports fordeferred/ginkgo
andtestservice
integrate neatly with the deferred server approach.
15-15
: Import testserver/ginkgo
Aligns logs listing tests with the new testserver approach, clarifying the usage of deferred test utilities.
29-36
: DeferTestServer usage
InitializingtestServer
with multiple instrumentation options lowers setup complexity and enhances test thoroughness.
38-38
: BeforeEach block
UsingSpecContext
fosters concurrency-friendly test setup right before each scenario.
39-39
: Creating ledger
Wait(specContext, DeferClient(testServer))
ensures the ledger service is fully initialized before usage.
44-44
: Error assertion
Expect(err).To(BeNil())
provides a clear check that the ledger was created successfully.
46-48
: Another ledger creation
Spawning a separate ledger broadens test scenarios, verifying logs can handle multiple ledgers.
61-61
: BeforeEach for transaction
A separateBeforeEach
ensures transactions exist for logs retrieval, isolating test concerns.
62-62
: Transaction creation
Deferring the client call is consistent with the new test design and ensures correct ordering.
80-80
: Additional transaction
Creating a transaction in another ledger tests cross-ledger logging behavior.
98-98
: Yet another transaction
Expanded coverage for logs with different metadata scenarios. This is beneficial for thorough testing.
116-116
: Adding metadata
Ensuring logs reflect metadata additions helps validate that relevant events are consistently emitted and captured.
126-126
: Test case for logs
Naming the test effectively communicates the core focus: verifying logs enumeration viaListLogs
.
127-127
: Retrieving logs
Ensuring the logs are properly fetched from the deferred server. Straightforward approach.
135-135
: Asserting logs count
Checking for exactly three logs confirms the expected number of events.
137-137
: Iterating log data
Looping through each log item is a robust way to verify correctness individually.
143-145
: Checking first log's ID, Type, and Data
Ensuring log #1's type isSetMetadata
with the correct data reflects the correct event order.
153-154
: Second log validations
ConfirmedType
isNewTransaction
; this matches the expected event type for transaction creation.
157-159
: Transaction data checks
Verifying the contents ofaccountMetadata
andtransaction
fields ensures completeness of log details.
264-264
: Response pointer
rsp *operations.V2ListLogsResponse
is a concise way to capture paginated logs for further checks.
266-266
: Listing logs again
ReusingWait(specContext, DeferClient(testServer))
to confirm correct log retrieval. No issues noted.
275-277
: Cursor checks
AssertingHasMore
,Previous
, andNext
fosters confidence in paginated results.
280-283
: Page size and data count validations
Verifying the returned count matchespageSize
ensures correct pagination logic.
287-288
: Following next cursor
Another test scenario verifying theNext
cursor's correctness. Good approach.
291-291
: Using next cursor
Cursor: rsp.V2LogsCursorResponse.Cursor.Next
properly references the subsequent page token.
298-301
: Second page checks
Re-confirmingPageSize
and verifyingcompareLogs
ensures consistent page-to-page correctness.
303-303
: Cursor termination
Expect(rsp.V2LogsCursorResponse.Cursor.Next).To(BeNil())
properly verifies the absence of additional pages.
306-306
: New scenario
"When following previous cursor" extends pagination checks for backward navigation. Comprehensive coverage.
307-308
: Fetching previous page
Ensuring theCursor: rsp.V2LogsCursorResponse.Cursor.Previous
is used well covers reverse paging features.
310-310
: Reusing ledger name
ReiteratingLedger: "default"
. Implementation is consistent.
317-320
: Verifying first page
Checking the initial page’s size and content again to ensure the previous cursor logic is correct.
322-322
: No previous page
Expect(rsp.V2LogsCursorResponse.Cursor.Previous).To(BeNil())
correctly concludes the pagination cycle.test/e2e/api_volumes_test.go (4)
8-14
: Clean import refactoring for the new testing approachThe imports have been properly updated to include the necessary deferred testing packages, platform testing, and testservice.
38-45
: Well-structured test server initialization using the deferred approachThe initialization has been updated to use DeferTestServer with appropriate instrumentation, replacing the previous nested Configuration approach. This simplifies configuration and improves modularity.
57-84
: Improved context handling for test executionBeforeEach has been updated to accept specContext parameter and use Wait with DeferClient for asynchronous operations, enhancing robustness and better aligning with modern testing practices.
97-98
: Updated response structure handlingThe code has been properly updated to access data using the new cursor-based pagination structure (V2VolumesWithBalanceCursorResponse.Cursor.Data), maintaining correctness across all test cases.
Also applies to: 128-129, 158-159, 185-186, 212-213, 247-248
test/e2e/api_transactions_metadata_test.go (4)
8-14
: Clean import refactoring for the new testing approachThe imports have been properly updated to include the necessary deferred testing packages, platform testing, and testservice.
28-35
: Well-structured test server initializationThe initialization has been updated to use ginkgo.DeferTestServer with appropriate instrumentation, following the project-wide pattern. The explicit package qualification makes the code more readable.
37-42
: Improved context handling in test setupThe BeforeEach function has been updated to accept specContext parameter and use Wait with DeferClient, providing better handling for asynchronous operations.
Also applies to: 49-80
46-47
: Correct response structure updatesThe response variable types and transaction ID access have been properly updated to work with the new response structure, ensuring all tests continue to function correctly.
Also applies to: 76-77, 107-108, 117-121
test/e2e/api_accounts_list_test.go (4)
9-16
: Clean import refactoring for the new testing approachThe imports have been properly updated to include the necessary deferred testing packages, platform testing, testservice, and nats testing.
34-42
: Comprehensive test server initialization with NATS instrumentationThe initialization has been updated to use ginkgo.DeferTestServer with DeferMap for database connection options and added NATS instrumentation, enhancing the test environment setup.
44-49
: Improved context handling across test casesThe BeforeEach and test functions have been updated to accept specContext parameter and use Wait with DeferClient, providing consistent handling for asynchronous operations throughout the test suite.
Also applies to: 63-101
125-126
: Properly updated response handlingResponse handling has been updated to work with the new cursor-based pagination structure, ensuring all test assertions remain valid.
Also applies to: 137-139, 180-189, 204-209, 225-230, 248-249
test/e2e/api_ledgers_import_test.go (5)
10-17
: Clean import refactoring for the new testing approachThe imports have been properly updated to include the necessary deferred testing packages, platform testing, and testservice.
26-29
: Well-structured database connection configurationThe variable declarations have been updated to use the deferred approach for database connection options, improving modularity and reusability.
31-39
: Comprehensive test server initializationThe test server setup has been updated to use DeferTestServer with appropriate instrumentation options, including experimental features, which simplifies configuration.
54-56
: Consistent approach to function updatesAll functions have been updated to use Wait with DeferClient and properly handle specContext, maintaining a consistent approach across the entire test suite.
Also applies to: 95-100
350-351
: Updated database connection handlingThe database connection now uses connectionOptions from the deferred context, providing better integration with the rest of the test framework.
test/e2e/api_accounts_metadata_test.go (4)
7-11
: Updated import structure for deferred testingThe import changes appropriately introduce the necessary packages for the deferred testing pattern, including the go-libs testing packages for Ginkgo integration, NATS testing, PostgreSQL testing, and test service functionality.
24-37
: Improved test server initialization with deferred patternThe server initialization has been refactored from direct instantiation to a deferred pattern using
DeferTestServer
. This change offers better modularity and clearer instrumentation configuration through explicit instrumentation options.
39-41
: Enhanced context handling in BeforeEachGood update to use
specContext
for managing the NATS subscription, improving context awareness in test setup.
55-64
: Updated API calls with Wait and DeferClient patternThe test now properly uses the
Wait
function withDeferClient(testServer)
for API calls, which improves handling of asynchronous operations with proper context management.test/e2e/api_ledgers_create_test.go (4)
9-13
: Updated import structure for deferred testingThe imports have been correctly updated to include the necessary packages for the deferred testing pattern, replacing the older direct test server initialization approach.
25-39
: Refactored test server initialization with better instrumentationThe server initialization has been improved by using
DeferTestServer
with properly mapped database connection options and explicit instrumentation. The addition of the experimental features instrumentation is particularly notable as it maintains the same test behavior with a more modular approach.
52-54
: Enhanced context handling in JustBeforeEachThe
JustBeforeEach
function now correctly accepts aSpecContext
parameter and uses theWait
function withDeferClient
for ledger operations, improving context management.
109-114
: Updated assertion with modified response structureThe test has been updated to properly access the ledger metadata through the new response structure (
ledger.V2GetLedgerResponse.Data.Metadata
), maintaining the same testing logic while adapting to the updated API structure.test/e2e/api_transactions_create_test.go (4)
6-11
: Updated import structure for deferred testingThe imports have been correctly updated to include the necessary packages for the deferred testing pattern, ensuring proper access to the testing utilities.
41-57
: Improved test server initialization with conditional instrumentationThe server initialization has been improved significantly with:
- Clear database and context setup
- Conditional instrumentation based on the numscript rewrite flag
- Proper use of
DeferTestServer
with mapped connection optionsThis change enhances both readability and modularity of the test setup.
79-90
: Updated BeforeEach with context-aware subscriptionThe
BeforeEach
function now correctly uses thespecContext
for NATS subscription and properly initializes the test request.
208-226
: Updated assertions with modified response structureThe test assertions have been properly updated to use the transaction data from the new response structure (
rsp.V2CreateTransactionResponse.Data
), maintaining the same verification while adapting to the API changes.test/e2e/app_lifecycle_test.go (3)
42-57
: Improved test server initialization with explicit connection optionsThe server initialization has been refactored to use:
- Explicit connection options mapping with
DeferMap
DeferTestServer
with proper instrumentation- Better logger configuration
This approach improves clarity and maintainability of the test setup.
158-162
: Enhanced server lifecycle managementThe server restart logic has been changed from using a single
Restart
call to separateStop
andStart
calls with appropriate context handling. This provides more explicit control over the server lifecycle, which is valuable for testing shutdown behavior.
309-313
: Updated HTTP client accessThe HTTP client access has been properly updated to use
http.DefaultClient.Get
with the URL obtained fromtestservice.GetServerURL(testServer)
, adapting to the new API for server URL access.test/e2e/api_transactions_revert_test.go (8)
6-11
: Imports updated to use go-libs testing packages.The imports have been updated to leverage the testing utilities from the go-libs library, which provides improved deferred patterns and testing helpers.
31-34
: Variable declarations refactored to use deferred patterns.The test setup now uses deferred initialization patterns with
UseTemplatedDatabase()
andDeferMap
, which improves resource management and test reliability.
36-44
: Test server initialization refactored to use DeferTestServer.The server initialization has been improved by using
DeferTestServer
with proper instrumentation options. This approach provides better modularity and resource management compared to direct instantiation.
46-51
: BeforeEach updated to accept SpecContext for async operations.The
BeforeEach
function now accepts aSpecContext
parameter, enabling the use ofWait
andDeferClient
methods for better handling of asynchronous operations.
55-55
: Transaction variable type updated to match new response structure.The
tx
variable type has been changed from*components.V2Transaction
to*operations.V2CreateTransactionResponse
to align with the updated API response format.
59-80
: Transaction creation BeforeEach updated to use context-aware operations.The transaction creation setup now leverages
SpecContext
withSubscribe
,Wait
, andDeferClient
methods, providing improved error handling and resource management.
113-113
: Transaction ID references updated to match new response structure.All transaction ID references have been consistently updated from
tx.ID
totx.V2CreateTransactionResponse.Data.ID
to align with the new API response format.Also applies to: 139-139, 152-152, 165-165, 179-179, 190-190, 214-214, 282-282, 293-293
157-157
: Response expectations updated to match new structure.Test assertions have been updated to work with the new response structure, correctly accessing fields like
V2GetTransactionResponse.Data.Reverted
andV2GetTransactionResponse.Data.Timestamp
.Also applies to: 195-196, 217-217, 297-298
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
🔭 Outside diff range comments (4)
internal/api/v1/mocks_ledger_controller_test.go (1)
1-388
:⚠️ Potential issueRegenerate the mock files.
The pipeline is showing a warning about modified generated code. Since this is auto-generated mock code that has been manually modified to update imports, you should regenerate it using the mockgen tool to ensure consistency.
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v1 --mock_names Controller=LedgerController . Controller
🧰 Tools
🪛 GitHub Actions: Default
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/bulking/mocks_ledger_controller_test.go (1)
1-388
:⚠️ Potential issueRegenerate the mock files.
The pipeline is showing a warning about modified generated code. Since this is auto-generated mock code that has been manually modified to update imports, you should regenerate it using the mockgen tool to ensure consistency.
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package bulking --mock_names Controller=LedgerController . Controller
🧰 Tools
🪛 GitHub Actions: Default
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/common/mocks_ledger_controller_test.go (1)
1-388
:⚠️ Potential issueRegenerate the mock files.
The pipeline is showing a warning about modified generated code. Since this is auto-generated mock code that has been manually modified to update imports, you should regenerate it using the mockgen tool to ensure consistency.
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package common --mock_names Controller=LedgerController . Controller
🧰 Tools
🪛 GitHub Actions: Default
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/storage/driver/buckets_generated_test.go (1)
1-185
:⚠️ Potential issueRegenerate the mock files.
The pipeline is showing a warning about modified generated code. Since this is auto-generated mock code that has been manually modified to update imports, you should regenerate it using the mockgen tool to ensure consistency.
mockgen -write_source_comment=false -write_package_comment=false -source ../bucket/bucket.go -destination buckets_generated_test.go -package driver --mock_names Factory=BucketFactory . Factory
🧰 Tools
🪛 GitHub Actions: Default
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
🧹 Nitpick comments (2)
pkg/testserver/ginkgo/helpers.go (2)
12-19
: Good implementation of deferred test server initialization.This function provides a clean API for creating deferred test servers with PostgreSQL connection options. It effectively wraps the more generic
DeferNew
function with specific options for a test server configuration.Consider adding a brief comment documenting the function's purpose and when it should be used over
DeferTestWorker
.
21-31
: Clean implementation of worker service initialization.The function follows the same pattern as
DeferTestServer
but with worker-specific instrumentation. It handles both command argument instrumentation and PostgreSQL instrumentation in a clear and consistent way.Consider adding documentation that explains what a "worker" does in this context, which would help new contributors understand when to use this function.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
deployments/pulumi/go.mod
is excluded by!**/*.mod
deployments/pulumi/go.sum
is excluded by!**/*.sum
,!**/*.sum
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/provisioner/go.mod
is excluded by!**/*.mod
tools/provisioner/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (207)
cmd/buckets_upgrade.go
(1 hunks)cmd/buckets_upgrade_test.go
(1 hunks)cmd/root.go
(1 hunks)cmd/serve.go
(2 hunks)cmd/worker.go
(1 hunks)deployments/pulumi/pkg/config/config.go
(6 hunks)deployments/pulumi/pkg/monitoring/monitoring.go
(1 hunks)internal/account.go
(1 hunks)internal/api/bulking/bulker.go
(1 hunks)internal/api/bulking/bulker_test.go
(1 hunks)internal/api/bulking/elements.go
(3 hunks)internal/api/bulking/handler_json.go
(1 hunks)internal/api/bulking/handler_json_test.go
(1 hunks)internal/api/bulking/handler_stream_json_test.go
(1 hunks)internal/api/bulking/handler_stream_text_test.go
(1 hunks)internal/api/bulking/mocks_ledger_controller_test.go
(1 hunks)internal/api/common/errors.go
(1 hunks)internal/api/common/middleware_logid.go
(1 hunks)internal/api/common/middleware_resolver.go
(1 hunks)internal/api/common/middleware_resolver_test.go
(1 hunks)internal/api/common/mocks_ledger_controller_test.go
(1 hunks)internal/api/common/mocks_system_controller_test.go
(1 hunks)internal/api/module.go
(1 hunks)internal/api/router.go
(2 hunks)internal/api/v1/controllers_accounts.go
(1 hunks)internal/api/v1/controllers_accounts_add_metadata.go
(1 hunks)internal/api/v1/controllers_accounts_add_metadata_test.go
(1 hunks)internal/api/v1/controllers_accounts_count.go
(1 hunks)internal/api/v1/controllers_accounts_count_test.go
(1 hunks)internal/api/v1/controllers_accounts_delete_metadata.go
(1 hunks)internal/api/v1/controllers_accounts_delete_metadata_test.go
(1 hunks)internal/api/v1/controllers_accounts_list.go
(1 hunks)internal/api/v1/controllers_accounts_list_test.go
(1 hunks)internal/api/v1/controllers_accounts_read.go
(1 hunks)internal/api/v1/controllers_accounts_read_test.go
(2 hunks)internal/api/v1/controllers_balances_aggregates.go
(1 hunks)internal/api/v1/controllers_balances_aggregates_test.go
(1 hunks)internal/api/v1/controllers_balances_list.go
(1 hunks)internal/api/v1/controllers_config.go
(1 hunks)internal/api/v1/controllers_config_test.go
(1 hunks)internal/api/v1/controllers_info.go
(1 hunks)internal/api/v1/controllers_info_test.go
(1 hunks)internal/api/v1/controllers_logs_list.go
(1 hunks)internal/api/v1/controllers_logs_list_test.go
(2 hunks)internal/api/v1/controllers_stats.go
(1 hunks)internal/api/v1/controllers_stats_test.go
(1 hunks)internal/api/v1/controllers_transactions.go
(1 hunks)internal/api/v1/controllers_transactions_add_metadata.go
(1 hunks)internal/api/v1/controllers_transactions_add_metadata_test.go
(1 hunks)internal/api/v1/controllers_transactions_count.go
(1 hunks)internal/api/v1/controllers_transactions_count_test.go
(1 hunks)internal/api/v1/controllers_transactions_create.go
(1 hunks)internal/api/v1/controllers_transactions_create_test.go
(2 hunks)internal/api/v1/controllers_transactions_delete_metadata.go
(1 hunks)internal/api/v1/controllers_transactions_delete_metadata_test.go
(1 hunks)internal/api/v1/controllers_transactions_list.go
(1 hunks)internal/api/v1/controllers_transactions_list_test.go
(2 hunks)internal/api/v1/controllers_transactions_read.go
(1 hunks)internal/api/v1/controllers_transactions_read_test.go
(1 hunks)internal/api/v1/controllers_transactions_revert.go
(1 hunks)internal/api/v1/controllers_transactions_revert_test.go
(1 hunks)internal/api/v1/middleware_auto_create_ledger.go
(1 hunks)internal/api/v1/mocks_ledger_controller_test.go
(1 hunks)internal/api/v1/mocks_system_controller_test.go
(1 hunks)internal/api/v1/routes.go
(1 hunks)internal/api/v1/utils.go
(1 hunks)internal/api/v2/common.go
(1 hunks)internal/api/v2/controllers_accounts_add_metadata.go
(1 hunks)internal/api/v2/controllers_accounts_add_metadata_test.go
(1 hunks)internal/api/v2/controllers_accounts_count.go
(1 hunks)internal/api/v2/controllers_accounts_count_test.go
(1 hunks)internal/api/v2/controllers_accounts_delete_metadata.go
(1 hunks)internal/api/v2/controllers_accounts_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_accounts_list.go
(1 hunks)internal/api/v2/controllers_accounts_list_test.go
(1 hunks)internal/api/v2/controllers_accounts_read.go
(1 hunks)internal/api/v2/controllers_accounts_read_test.go
(1 hunks)internal/api/v2/controllers_balances.go
(1 hunks)internal/api/v2/controllers_balances_test.go
(1 hunks)internal/api/v2/controllers_bulk.go
(1 hunks)internal/api/v2/controllers_bulk_test.go
(2 hunks)internal/api/v2/controllers_ledgers_create.go
(1 hunks)internal/api/v2/controllers_ledgers_create_test.go
(1 hunks)internal/api/v2/controllers_ledgers_delete_metadata.go
(1 hunks)internal/api/v2/controllers_ledgers_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_ledgers_info.go
(1 hunks)internal/api/v2/controllers_ledgers_info_test.go
(1 hunks)internal/api/v2/controllers_ledgers_list.go
(1 hunks)internal/api/v2/controllers_ledgers_list_test.go
(1 hunks)internal/api/v2/controllers_ledgers_read.go
(1 hunks)internal/api/v2/controllers_ledgers_read_test.go
(1 hunks)internal/api/v2/controllers_ledgers_update_metadata.go
(1 hunks)internal/api/v2/controllers_ledgers_update_metadata_test.go
(1 hunks)internal/api/v2/controllers_logs_export_test.go
(1 hunks)internal/api/v2/controllers_logs_import.go
(1 hunks)internal/api/v2/controllers_logs_import_test.go
(1 hunks)internal/api/v2/controllers_logs_list.go
(1 hunks)internal/api/v2/controllers_logs_list_test.go
(2 hunks)internal/api/v2/controllers_stats.go
(1 hunks)internal/api/v2/controllers_stats_test.go
(1 hunks)internal/api/v2/controllers_transactions_add_metadata.go
(1 hunks)internal/api/v2/controllers_transactions_add_metadata_test.go
(1 hunks)internal/api/v2/controllers_transactions_count.go
(1 hunks)internal/api/v2/controllers_transactions_count_test.go
(1 hunks)internal/api/v2/controllers_transactions_create.go
(1 hunks)internal/api/v2/controllers_transactions_create_test.go
(1 hunks)internal/api/v2/controllers_transactions_delete_metadata.go
(1 hunks)internal/api/v2/controllers_transactions_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_transactions_list.go
(1 hunks)internal/api/v2/controllers_transactions_list_test.go
(2 hunks)internal/api/v2/controllers_transactions_read.go
(1 hunks)internal/api/v2/controllers_transactions_read_test.go
(1 hunks)internal/api/v2/controllers_transactions_revert.go
(1 hunks)internal/api/v2/controllers_transactions_revert_test.go
(1 hunks)internal/api/v2/controllers_volumes.go
(1 hunks)internal/api/v2/controllers_volumes_test.go
(1 hunks)internal/api/v2/mocks_ledger_controller_test.go
(1 hunks)internal/api/v2/mocks_system_controller_test.go
(1 hunks)internal/api/v2/query.go
(1 hunks)internal/api/v2/routes.go
(4 hunks)internal/bus/listener.go
(1 hunks)internal/bus/listener_test.go
(1 hunks)internal/bus/message.go
(1 hunks)internal/controller/ledger/controller.go
(1 hunks)internal/controller/ledger/controller_default.go
(1 hunks)internal/controller/ledger/controller_default_test.go
(1 hunks)internal/controller/ledger/controller_generated_test.go
(1 hunks)internal/controller/ledger/controller_with_too_many_client_handling.go
(1 hunks)internal/controller/ledger/controller_with_too_many_client_handling_generated_test.go
(0 hunks)internal/controller/ledger/controller_with_too_many_client_handling_test.go
(1 hunks)internal/controller/ledger/controller_with_traces.go
(1 hunks)internal/controller/ledger/errors.go
(1 hunks)internal/controller/ledger/listener.go
(1 hunks)internal/controller/ledger/listener_generated_test.go
(1 hunks)internal/controller/ledger/log_process.go
(1 hunks)internal/controller/ledger/log_process_test.go
(1 hunks)internal/controller/ledger/mocks_test.go
(1 hunks)internal/controller/ledger/numscript.go
(1 hunks)internal/controller/ledger/numscript_parser_generated_test.go
(0 hunks)internal/controller/ledger/numscript_runtime.go
(1 hunks)internal/controller/ledger/numscript_runtime_generated_test.go
(0 hunks)internal/controller/ledger/stats_test.go
(1 hunks)internal/controller/ledger/store.go
(1 hunks)internal/controller/ledger/store_generated_test.go
(1 hunks)internal/controller/system/controller.go
(1 hunks)internal/controller/system/state_tracker.go
(1 hunks)internal/controller/system/store.go
(1 hunks)internal/ledger.go
(1 hunks)internal/log.go
(1 hunks)internal/machine/examples/basic.go
(1 hunks)internal/machine/funding.go
(1 hunks)internal/machine/vm/machine.go
(1 hunks)internal/machine/vm/machine_test.go
(1 hunks)internal/machine/vm/run.go
(1 hunks)internal/machine/vm/run_test.go
(1 hunks)internal/machine/vm/store.go
(1 hunks)internal/moves.go
(1 hunks)internal/storage/bucket/bucket.go
(1 hunks)internal/storage/bucket/default_bucket.go
(1 hunks)internal/storage/bucket/default_bucket_test.go
(1 hunks)internal/storage/bucket/main_test.go
(1 hunks)internal/storage/bucket/migrations.go
(1 hunks)internal/storage/bucket/migrations_test.go
(1 hunks)internal/storage/common/paginator.go
(1 hunks)internal/storage/common/paginator_column.go
(1 hunks)internal/storage/common/paginator_offset.go
(1 hunks)internal/storage/common/resource.go
(2 hunks)internal/storage/driver/buckets_generated_test.go
(1 hunks)internal/storage/driver/driver.go
(1 hunks)internal/storage/driver/driver_test.go
(1 hunks)internal/storage/driver/ledger_generated_test.go
(0 hunks)internal/storage/driver/main_test.go
(1 hunks)internal/storage/driver/module.go
(1 hunks)internal/storage/driver/rollbacks.go
(1 hunks)internal/storage/driver/system_generated_test.go
(1 hunks)internal/storage/ledger/accounts.go
(1 hunks)internal/storage/ledger/accounts_test.go
(1 hunks)internal/storage/ledger/balances.go
(1 hunks)internal/storage/ledger/balances_test.go
(1 hunks)internal/storage/ledger/logs.go
(1 hunks)internal/storage/ledger/logs_test.go
(2 hunks)internal/storage/ledger/main_test.go
(3 hunks)internal/storage/ledger/moves.go
(1 hunks)internal/storage/ledger/moves_test.go
(1 hunks)internal/storage/ledger/store.go
(1 hunks)internal/storage/ledger/transactions.go
(2 hunks)internal/storage/ledger/transactions_test.go
(1 hunks)internal/storage/ledger/volumes.go
(1 hunks)internal/storage/ledger/volumes_test.go
(1 hunks)internal/storage/module.go
(1 hunks)internal/storage/system/main_test.go
(1 hunks)internal/storage/system/migrations.go
(1 hunks)internal/storage/system/migrations_test.go
(1 hunks)internal/storage/system/store.go
(1 hunks)internal/storage/system/store_test.go
(2 hunks)internal/tracing/tracing.go
(1 hunks)internal/transaction.go
(2 hunks)internal/transaction_test.go
(1 hunks)internal/worker/async_block.go
(2 hunks)internal/worker/fx.go
(1 hunks)pkg/features/features.go
(1 hunks)pkg/generate/generator.go
(1 hunks)pkg/generate/generator_test.go
(3 hunks)pkg/generate/set.go
(1 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/ginkgo/helpers.go
(1 hunks)pkg/testserver/ginkgo/matchers.go
(2 hunks)
⛔ Files not processed due to max files limit (34)
- pkg/testserver/server.go
- pkg/testserver/utils.go
- pkg/testserver/worker.go
- test/e2e/api_accounts_list_test.go
- test/e2e/api_accounts_metadata_test.go
- test/e2e/api_balances_aggregated_test.go
- test/e2e/api_bulk_test.go
- test/e2e/api_ledgers_create_test.go
- test/e2e/api_ledgers_import_test.go
- test/e2e/api_ledgers_list_test.go
- test/e2e/api_ledgers_metadata_test.go
- test/e2e/api_logs_list_test.go
- test/e2e/api_transactions_create_test.go
- test/e2e/api_transactions_list_test.go
- test/e2e/api_transactions_metadata_test.go
- test/e2e/api_transactions_revert_test.go
- test/e2e/api_volumes_test.go
- test/e2e/app_lifecycle_test.go
- test/e2e/app_logs_blocks_async_test.go
- test/e2e/app_multiple_instance_test.go
- test/e2e/suite_test.go
- test/e2e/v1_api_balances_test.go
- test/migrations/upgrade_test.go
- test/performance/pkg/env/configure.go
- test/performance/pkg/env/features.go
- test/performance/pkg/read/read_test.go
- test/performance/pkg/write/local_env_test.go
- test/performance/pkg/write/report_test.go
- test/performance/pkg/write/write_test.go
- test/stress/stress_test.go
- test/stress/suite_test.go
- tools/generator/cmd/root.go
- tools/provisioner/pkg/reconciler.go
- tools/provisioner/pkg/store.go
💤 Files with no reviewable changes (4)
- internal/controller/ledger/controller_with_too_many_client_handling_generated_test.go
- internal/controller/ledger/numscript_runtime_generated_test.go
- internal/controller/ledger/numscript_parser_generated_test.go
- internal/storage/driver/ledger_generated_test.go
✅ Files skipped from review due to trivial changes (183)
- internal/api/v2/controllers_accounts_delete_metadata.go
- internal/api/v1/controllers_stats.go
- internal/bus/listener_test.go
- internal/controller/system/controller.go
- internal/storage/bucket/bucket.go
- internal/api/v2/controllers_accounts_count.go
- internal/controller/ledger/listener.go
- internal/api/v1/controllers_accounts.go
- internal/storage/driver/rollbacks.go
- internal/controller/ledger/numscript.go
- internal/api/v1/controllers_transactions_delete_metadata.go
- internal/api/v1/controllers_accounts_list.go
- internal/controller/ledger/errors.go
- internal/api/v1/controllers_balances_aggregates.go
- internal/api/v2/query.go
- internal/api/v2/controllers_transactions_delete_metadata.go
- internal/storage/bucket/default_bucket.go
- internal/api/v2/controllers_ledgers_list.go
- internal/api/v2/controllers_volumes.go
- internal/machine/vm/run.go
- internal/api/v2/controllers_balances.go
- internal/worker/fx.go
- internal/storage/common/paginator_offset.go
- internal/ledger.go
- internal/api/v1/controllers_transactions_count.go
- internal/api/v1/controllers_accounts_count.go
- internal/worker/async_block.go
- internal/api/v1/controllers_transactions_add_metadata.go
- internal/storage/driver/driver.go
- internal/api/common/middleware_logid.go
- internal/api/v2/controllers_logs_export_test.go
- internal/api/v2/controllers_bulk.go
- internal/api/v1/routes.go
- internal/api/bulking/handler_stream_text_test.go
- internal/controller/ledger/log_process.go
- internal/controller/ledger/stats_test.go
- internal/machine/vm/store.go
- internal/api/v2/controllers_transactions_count.go
- internal/api/v1/controllers_accounts_delete_metadata.go
- internal/storage/driver/driver_test.go
- internal/storage/driver/module.go
- internal/tracing/tracing.go
- internal/controller/system/state_tracker.go
- internal/api/v2/controllers_accounts_list.go
- internal/api/bulking/handler_json.go
- internal/machine/funding.go
- internal/api/v1/controllers_transactions_create_test.go
- internal/api/v2/controllers_stats_test.go
- internal/api/common/errors.go
- internal/controller/ledger/controller_with_too_many_client_handling.go
- internal/bus/message.go
- internal/api/v2/controllers_transactions_revert_test.go
- internal/storage/ledger/logs.go
- internal/api/v1/controllers_accounts_read.go
- internal/api/v2/controllers_ledgers_info.go
- internal/controller/ledger/controller_with_too_many_client_handling_test.go
- internal/api/v1/controllers_balances_list.go
- internal/storage/ledger/moves.go
- internal/controller/system/store.go
- internal/api/v2/controllers_transactions_create.go
- internal/storage/ledger/accounts.go
- internal/api/v2/controllers_logs_import.go
- internal/controller/ledger/controller_with_traces.go
- internal/account.go
- internal/api/v2/controllers_ledgers_create.go
- internal/machine/examples/basic.go
- internal/storage/ledger/volumes.go
- internal/storage/module.go
- internal/api/v2/controllers_ledgers_update_metadata_test.go
- internal/api/v1/controllers_accounts_count_test.go
- internal/storage/ledger/balances.go
- internal/api/v1/controllers_accounts_delete_metadata_test.go
- cmd/root.go
- internal/bus/listener.go
- internal/api/v2/controllers_accounts_count_test.go
- internal/api/v2/controllers_transactions_list_test.go
- cmd/buckets_upgrade.go
- internal/api/v1/controllers_info.go
- internal/controller/ledger/numscript_runtime.go
- internal/api/v2/controllers_stats.go
- internal/api/v2/controllers_transactions_delete_metadata_test.go
- internal/machine/vm/machine_test.go
- internal/api/v1/controllers_transactions_count_test.go
- internal/api/v2/controllers_accounts_delete_metadata_test.go
- internal/api/v1/controllers_accounts_add_metadata.go
- internal/transaction_test.go
- internal/api/module.go
- internal/api/v2/controllers_transactions_add_metadata.go
- internal/api/v2/controllers_ledgers_create_test.go
- internal/api/bulking/handler_stream_json_test.go
- internal/machine/vm/machine.go
- internal/api/v1/middleware_auto_create_ledger.go
- internal/transaction.go
- internal/api/v2/controllers_ledgers_read.go
- internal/controller/ledger/log_process_test.go
- internal/api/v2/controllers_logs_list.go
- internal/api/v1/controllers_transactions_delete_metadata_test.go
- internal/storage/bucket/migrations_test.go
- internal/storage/ledger/moves_test.go
- internal/api/v1/controllers_transactions_revert_test.go
- pkg/generate/generator.go
- internal/api/v1/controllers_accounts_read_test.go
- pkg/features/features.go
- internal/api/v2/controllers_logs_import_test.go
- deployments/pulumi/pkg/monitoring/monitoring.go
- internal/storage/system/main_test.go
- internal/storage/system/store.go
- internal/api/v1/controllers_transactions_create.go
- internal/controller/ledger/controller.go
- internal/api/v1/controllers_logs_list.go
- internal/api/v1/controllers_config_test.go
- internal/api/v2/controllers_accounts_read.go
- internal/api/v2/controllers_ledgers_read_test.go
- internal/api/v1/controllers_balances_aggregates_test.go
- internal/api/v1/controllers_accounts_add_metadata_test.go
- internal/api/v2/controllers_logs_list_test.go
- internal/api/v2/controllers_ledgers_update_metadata.go
- internal/storage/system/migrations.go
- internal/storage/bucket/migrations.go
- internal/api/v2/controllers_ledgers_delete_metadata_test.go
- pkg/generate/set.go
- deployments/pulumi/pkg/config/config.go
- internal/api/bulking/handler_json_test.go
- internal/api/bulking/bulker_test.go
- internal/api/v2/controllers_transactions_read_test.go
- internal/api/v2/controllers_ledgers_delete_metadata.go
- internal/storage/common/paginator_column.go
- internal/api/v1/controllers_accounts_list_test.go
- internal/api/v2/controllers_transactions_add_metadata_test.go
- internal/storage/ledger/transactions.go
- internal/api/v2/controllers_accounts_read_test.go
- internal/api/v2/controllers_accounts_add_metadata.go
- internal/api/v2/controllers_transactions_revert.go
- internal/moves.go
- internal/api/v1/controllers_transactions_read.go
- internal/api/v2/controllers_transactions_list.go
- internal/storage/ledger/balances_test.go
- internal/api/bulking/bulker.go
- internal/controller/ledger/controller_default.go
- internal/storage/bucket/main_test.go
- internal/api/v1/controllers_transactions_list.go
- internal/api/v1/controllers_logs_list_test.go
- internal/api/v2/common.go
- internal/storage/bucket/default_bucket_test.go
- internal/machine/vm/run_test.go
- internal/api/v1/controllers_transactions.go
- internal/api/common/middleware_resolver.go
- cmd/worker.go
- internal/api/v2/controllers_accounts_list_test.go
- internal/api/v2/controllers_bulk_test.go
- internal/api/v1/controllers_transactions_revert.go
- internal/api/v2/controllers_balances_test.go
- internal/api/v1/controllers_transactions_read_test.go
- internal/api/v1/utils.go
- internal/api/v1/controllers_transactions_add_metadata_test.go
- internal/api/v1/controllers_transactions_list_test.go
- internal/storage/driver/main_test.go
- internal/api/v2/controllers_volumes_test.go
- internal/storage/ledger/transactions_test.go
- internal/api/bulking/elements.go
- internal/api/router.go
- internal/storage/ledger/accounts_test.go
- internal/api/v2/controllers_accounts_add_metadata_test.go
- cmd/buckets_upgrade_test.go
- internal/api/v2/controllers_ledgers_info_test.go
- internal/controller/ledger/store.go
- internal/api/v2/controllers_transactions_create_test.go
- internal/controller/ledger/controller_default_test.go
- internal/api/v2/controllers_ledgers_list_test.go
- internal/storage/ledger/logs_test.go
- internal/api/v1/controllers_info_test.go
- internal/api/common/middleware_resolver_test.go
- internal/log.go
- internal/storage/system/store_test.go
- cmd/serve.go
- internal/storage/ledger/store.go
- internal/storage/common/paginator.go
- internal/storage/system/migrations_test.go
- internal/api/v1/controllers_config.go
- internal/api/v2/controllers_transactions_count_test.go
- internal/api/v1/controllers_stats_test.go
- internal/api/v2/controllers_transactions_read.go
- internal/storage/ledger/volumes_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/testserver/client.go
- internal/storage/ledger/main_test.go
🧰 Additional context used
🧬 Code Definitions (1)
pkg/testserver/ginkgo/matchers.go (5)
pkg/client/models/operations/v2listledgers.go (1)
V2ListLedgersRequest
(9-20)pkg/client/models/operations/v2getbalancesaggregated.go (1)
V2GetBalancesAggregatedRequest
(11-18)pkg/client/models/components/v2aggregatebalancesresponse.go (1)
V2AggregateBalancesResponse
(10-12)pkg/client/models/operations/v2listtransactions.go (1)
V2ListTransactionsRequest
(36-53)pkg/client/models/components/v2transactionscursorresponse.go (1)
V2TransactionsCursorResponse
(48-50)
🪛 GitHub Actions: Default
internal/api/common/mocks_system_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/controller/ledger/listener_generated_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/v2/mocks_ledger_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/controller/ledger/store_generated_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/storage/driver/buckets_generated_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/v1/mocks_ledger_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/storage/driver/system_generated_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/v1/mocks_system_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/common/mocks_ledger_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/v2/mocks_system_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/bulking/mocks_ledger_controller_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/controller/ledger/controller_generated_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/controller/ledger/mocks_test.go
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
🔇 Additional comments (22)
pkg/testserver/ginkgo/helpers.go (2)
1-10
: Well-structured imports and package organization.The imports are organized logically, pulling in the necessary dependencies from both the go-libs package and the local ledger packages. Using the dot import for
testservice/ginkgo
makes sense here as it provides theDeferNew
function used throughout.
1-31
: The deferred pattern is well implemented throughout.The refactoring to use the deferred pattern from go-libs is a good architectural choice. It should improve test initialization efficiency and potentially enable more parallel testing. The code is concise and follows a consistent pattern.
internal/storage/driver/system_generated_test.go (1)
12-13
:❓ Verification inconclusive
Do not manually modify generated code - regenerate with mockgen instead
While updating the import paths from
go-libs/v2
togo-libs/v3
is correct for your dependency upgrade, directly modifying generated code is not the appropriate approach. This is confirmed by the pipeline warning.Instead of manually modifying this file, please regenerate the mock using the mockgen command that's specified in the file header (line 5):
🏁 Script executed:
#!/bin/bash # Check if the mockgen command works as expected mockgen -write_source_comment=false -write_package_comment=false -source ../system/store.go -destination system_generated_test.go -package driver --mock_names Store=SystemStore . Store # Show the result to verify the regeneration head -20 system_generated_test.goLength of output: 404
Action Required: Resolve
mockgen
dependency issue and verify regeneration processIt appears that running the mockgen command failed because the utility is not installed (evidenced by the "mockgen: command not found" error), and as a result, the generated file wasn’t created.
- Ensure
mockgen
is installed and available in your PATH (or update the environment settings accordingly).- Manually verify that after installing
mockgen
, the regeneration command produces the expected output ininternal/storage/driver/system_generated_test.go
.- Refrain from manually modifying auto-generated code – the file should always be updated via the regeneration process.
Please address the missing dependency and verify the regeneration manually.
internal/controller/ledger/listener_generated_test.go (1)
1-6
:❓ Verification inconclusive
Follow the "DO NOT EDIT" directive for generated files.
The first comment in this file clearly states "Code generated by MockGen. DO NOT EDIT." Generated files should not be manually modified, as any changes will be lost when the file is regenerated.
🏁 Script executed:
#!/bin/bash # Check if the mockgen command is available if ! command -v mockgen &> /dev/null; then echo "mockgen command not found. It may need to be installed." exit 1 fi # Extract the mockgen command from the file mockgen_cmd=$(grep -o "mockgen.*Listener" internal/controller/ledger/listener_generated_test.go) echo "Extracted mockgen command: $mockgen_cmd" # Check if the listener.go source file exists if [ ! -f "internal/controller/ledger/listener.go" ]; then echo "Source file listener.go not found in the expected location." exit 1 fi echo "The proper way to update this file is to run the mockgen command shown above."Length of output: 150
Action Required: Ensure auto-generated file remains unedited and install
mockgen
if regeneration is needed.The file
internal/controller/ledger/listener_generated_test.go
is automatically generated by mockgen (as indicated by the header comment) and must not be manually modified.Points to note:
- Do not edit: The header comment in the file clearly states “Code generated by MockGen. DO NOT EDIT.” Any manual changes will be overwritten when the file is regenerated.
- Regeneration process: To update the generated file, you must rerun the mockgen command specified in the file. However, our verification indicates that the
mockgen
command is not available in the current environment. Please ensure thatmockgen
is installed so that you can properly regenerate mocks as needed.- Source integrity: The file is generated based on
internal/controller/ledger/listener.go
. Any changes to the Listener interface should be made in the source file, then propagated via mockgen.🧰 Tools
🪛 GitHub Actions: Default
[warning] 3-3: Generated code has been modified. Please regenerate mocks using mockgen.
internal/api/v1/mocks_ledger_controller_test.go (1)
13-14
: Library version update looks good.The import paths have been updated from v2 to v3 for the go-libs packages, which aligns with the PR objective of using test server from go-libs.
internal/api/bulking/mocks_ledger_controller_test.go (1)
13-14
: Library version update looks good.The import paths have been updated from v2 to v3 for the go-libs packages, which aligns with the PR objective of using test server from go-libs.
internal/api/common/mocks_ledger_controller_test.go (1)
13-14
: Library version update looks good.The import paths have been updated from v2 to v3 for the go-libs packages, which aligns with the PR objective of using test server from go-libs.
internal/storage/driver/buckets_generated_test.go (1)
12-12
: Library version update looks good.The import path has been updated from v2 to v3 for the migrations package, which aligns with the PR objective of using test server from go-libs.
internal/storage/common/resource.go (2)
7-11
: Import paths updated to v3The import paths have been updated from
go-libs/v2
togo-libs/v3
for all packages. This change is consistent with the PR objective of using the latest version of go-libs.
30-31
: Minor formatting improvementThe case for
$like
operator has been reformatted from a single line to multiple lines for better readability, with no functional changes.pkg/testserver/ginkgo/matchers.go (5)
1-1
: Package name changed from testserver to ginkgoThe package name has been updated to reflect its actual location in the directory structure, improving code organization.
8-13
: Import paths updated to v3The import paths have been updated from
go-libs/v2
togo-libs/v3
and new imports for deferred pattern support have been added.
27-30
: Updated parameter type for the matcherThe
Match
method now accepts a deferred service pointer instead of a direct server reference, aligning with the new deferred pattern from go-libs v3.
33-38
: Updated server access using deferred patternThe code now properly waits for the deferred service to resolve with error handling, then gets the client using the new
testserver.Client()
function instead of direct server access.
39-62
: Updated client API calls and response structure handlingThe code has been updated to work with the new API structure:
- Ledger listing now accesses data through
ledgers.V2LedgerListResponse.Cursor.Data
- Balance aggregation now accesses
aggregatedBalances.V2AggregateBalancesResponse.Data
- Transaction listing now checks
txs.V2TransactionsCursorResponse.Cursor.Data
These changes align with the updated response structures from the go-libs v3 library.
pkg/generate/generator_test.go (5)
6-12
: Import paths updated to v3The import paths have been updated from
go-libs/v2
togo-libs/v3
for all packages, including new imports for the deferred pattern and testing utilities.
25-35
: Refactored server initialization with improved modularityThe server initialization has been completely refactored:
- Now uses
NewTestServer
with a deferred database connection- Adds explicit logger configuration
- Configures instrumentation with debug mode option
This approach is more modular and follows better separation of concerns.
39-42
: Updated client access patternClient access now uses the standalone
Client(testServer)
function instead of the previoustestServer.Client()
method, consistent with the new API design in go-libs v3.
55-57
: Updated action application with new client accessThe
action.Apply()
call now uses the updated client access pattern for consistency.
59-70
: Updated transaction response accessThe code has been updated to access transaction data through the new response structure:
- Now uses
txs.V2TransactionsCursorResponse.Cursor.Data
instead oftxs.Data
- Updates checks for transaction properties and metadata through the new structure
These changes align with the modified API response formats in go-libs v3.
internal/api/v2/routes.go (2)
133-133
: Minor formatting improvements.The spacing adjustments improve code alignment and readability without changing functionality.
Also applies to: 143-143
4-4
:✅ Verification successful
Appropriate version upgrade in imports.
The import paths have been updated from v2 to v3 of go-libs packages. This is consistent with the PR objective to use components from go-libs.
To ensure all imports have been consistently updated across the codebase:
Also applies to: 15-15
🏁 Script executed:
#!/bin/bash # Check for any remaining v2 imports of go-libs that might need updating echo "Checking for any remaining v2 imports of go-libs:" rg -l "github.com/formancehq/go-libs/v2" --type go # Check that v3 imports are properly used echo "Confirming v3 imports are properly used:" rg -l "github.com/formancehq/go-libs/v3" --type goLength of output: 10060
Verified: All imports are correctly updated to go-libs v3
The import change in
internal/api/v2/routes.go
(line 4) has been confirmed, and our search shows no remaining references to go-libs v2 across the repository. The consistent usage of go-libs v3 in multiple files (as seen in the verification output) aligns with the PR's objective.
- File Update:
internal/api/v2/routes.go
(line 4 & line 15)- Verification Results:
- No v2 imports found
- Extensive usage of v3 imports confirmed
metadata "github.com/formancehq/go-libs/v3/metadata" | ||
migrations "github.com/formancehq/go-libs/v3/migrations" | ||
time "github.com/formancehq/go-libs/v3/time" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update import paths using mockgen instead of manual edits
You've updated the import paths from go-libs/v2
to go-libs/v3
in this generated file. While the changes themselves are correct and align with the PR objective of using test server from go-libs, manually editing generated files is not recommended.
The pipeline failure indicates this issue: "Generated code has been modified. Please regenerate mocks using mockgen."
Instead of manually editing this file, please:
- Update the imports in the source file (
store.go
) - Regenerate the mock using the same command shown in the file header (line 5):
mockgen -write_source_comment=false -write_package_comment=false -source store.go -destination store_generated_test.go -package ledger . Store
This ensures the generated code remains consistent with its source.
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" | ||
migrations "github.com/formancehq/go-libs/v3/migrations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate mock code instead of manual modification
The import paths have been manually updated from go-libs/v2
to go-libs/v3
, but this file is generated code as indicated by the header comments. The pipeline is also warning about this with: "Generated code has been modified. Please regenerate mocks using mockgen."
Instead of manually editing the imports, please regenerate the mock using the mockgen command specified in the file header:
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v2 --mock_names Controller=LedgerController . Controller
This will ensure the mock is properly updated with the correct imports and any other necessary changes from the source.
package ledger | ||
|
||
import ( | ||
context "context" | ||
reflect "reflect" | ||
|
||
metadata "github.com/formancehq/go-libs/v2/metadata" | ||
metadata "github.com/formancehq/go-libs/v3/metadata" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version update needs proper regeneration of mocks.
The import path has been updated from v2 to v3 for the metadata package, but this file is auto-generated by mockgen. According to the pipeline warning, manually editing generated code is not recommended.
Instead of manually modifying this file, please regenerate it using the mockgen command that's already specified in the file header (line 5):
mockgen -write_source_comment=false -write_package_comment=false -source listener.go -destination listener_generated_test.go -package ledger . Listener
This will ensure all dependencies are properly updated and the generated code remains consistent.
package v1 | ||
|
||
import ( | ||
context "context" | ||
reflect "reflect" | ||
|
||
bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" | ||
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate mocks instead of manually modifying generated code.
The import path has been updated from v2 to v3, but this is a generated file as indicated by the file header. Manual modifications to generated files can lead to inconsistencies.
Instead of directly modifying this file, update the import in the source file (../../controller/system/controller.go
) and then regenerate the mock using the mockgen command specified in the file header:
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v1 --mock_names Controller=SystemController . Controller
package common | ||
|
||
import ( | ||
context "context" | ||
reflect "reflect" | ||
|
||
bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" | ||
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate mocks instead of manually modifying generated code.
The import path has been updated from v2 to v3, but this is a generated file as indicated by the file header. Manual modifications to generated files can lead to inconsistencies.
Instead of directly modifying this file, update the import in the source file (../../controller/system/controller.go
) and then regenerate the mock using the mockgen command specified in the file header:
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package common --mock_names Controller=SystemController . Controller
package v2 | ||
|
||
import ( | ||
context "context" | ||
reflect "reflect" | ||
|
||
bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" | ||
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate mocks instead of manually modifying generated code.
The import path has been updated from v2 to v3, but this is a generated file as indicated by the file header. Manual modifications to generated files can lead to inconsistencies.
Instead of directly modifying this file, update the import in the source file (../../controller/system/controller.go
) and then regenerate the mock using the mockgen command specified in the file header:
mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v2 --mock_names Controller=SystemController . Controller
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" | ||
migrations "github.com/formancehq/go-libs/v3/migrations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate mocks instead of manually modifying generated code.
The import paths have been updated from v2 to v3, but this is a generated file as indicated by the file header. Manual modifications to generated files can lead to inconsistencies.
Instead of directly modifying this file, update the imports in the source file (controller.go
) and then regenerate the mock using the mockgen command specified in the file header:
mockgen -write_source_comment=false -write_package_comment=false -source controller.go -destination controller_generated_test.go -package ledger . Controller
package ledger | ||
|
||
import ( | ||
context "context" | ||
reflect "reflect" | ||
|
||
bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" | ||
bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generated code should not be modified manually.
The import path update from v2 to v3 for the bunpaginate package aligns with the PR objective of using the test server from go-libs. However, this is auto-generated code as indicated by the comment at the top of the file.
The pipeline is correctly warning that generated code has been modified. Instead of manually editing this file, you should:
- Update the imports/dependencies in the source file (../../storage/common/resource.go)
- Regenerate the mocks by running the mockgen command shown in line 5:
mockgen -write_source_comment=false -write_package_comment=false -source ../../storage/common/resource.go -destination mocks_test.go -package ledger . PaginatedResource
This will ensure that all the generated code is properly updated and consistent with the underlying source.
1b16c90
to
2948850
Compare
2948850
to
ca2917e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/e2e/api_accounts_list_test.go (1)
102-116
: String concatenation for error label
Usingstring(components.V2ErrorsEnumValidation)
directly is fine, but considerfmt.Sprintf("should return a %s on invalid filter", components.V2ErrorsEnumValidation)
for readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
deployments/pulumi/go.mod
is excluded by!**/*.mod
deployments/pulumi/go.sum
is excluded by!**/*.sum
,!**/*.sum
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/generator/go.mod
is excluded by!**/*.mod
tools/generator/go.sum
is excluded by!**/*.sum
,!**/*.sum
tools/provisioner/go.mod
is excluded by!**/*.mod
tools/provisioner/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (207)
cmd/buckets_upgrade.go
(1 hunks)cmd/buckets_upgrade_test.go
(1 hunks)cmd/root.go
(1 hunks)cmd/serve.go
(2 hunks)cmd/worker.go
(1 hunks)deployments/pulumi/pkg/config/config.go
(6 hunks)deployments/pulumi/pkg/monitoring/monitoring.go
(1 hunks)internal/account.go
(1 hunks)internal/api/bulking/bulker.go
(1 hunks)internal/api/bulking/bulker_test.go
(1 hunks)internal/api/bulking/elements.go
(3 hunks)internal/api/bulking/handler_json.go
(1 hunks)internal/api/bulking/handler_json_test.go
(1 hunks)internal/api/bulking/handler_stream_json_test.go
(1 hunks)internal/api/bulking/handler_stream_text_test.go
(1 hunks)internal/api/bulking/mocks_ledger_controller_test.go
(1 hunks)internal/api/common/errors.go
(1 hunks)internal/api/common/middleware_logid.go
(1 hunks)internal/api/common/middleware_resolver.go
(1 hunks)internal/api/common/middleware_resolver_test.go
(1 hunks)internal/api/common/mocks_ledger_controller_test.go
(1 hunks)internal/api/common/mocks_system_controller_test.go
(1 hunks)internal/api/module.go
(1 hunks)internal/api/router.go
(2 hunks)internal/api/v1/controllers_accounts.go
(1 hunks)internal/api/v1/controllers_accounts_add_metadata.go
(1 hunks)internal/api/v1/controllers_accounts_add_metadata_test.go
(1 hunks)internal/api/v1/controllers_accounts_count.go
(1 hunks)internal/api/v1/controllers_accounts_count_test.go
(1 hunks)internal/api/v1/controllers_accounts_delete_metadata.go
(1 hunks)internal/api/v1/controllers_accounts_delete_metadata_test.go
(1 hunks)internal/api/v1/controllers_accounts_list.go
(1 hunks)internal/api/v1/controllers_accounts_list_test.go
(1 hunks)internal/api/v1/controllers_accounts_read.go
(1 hunks)internal/api/v1/controllers_accounts_read_test.go
(2 hunks)internal/api/v1/controllers_balances_aggregates.go
(1 hunks)internal/api/v1/controllers_balances_aggregates_test.go
(1 hunks)internal/api/v1/controllers_balances_list.go
(1 hunks)internal/api/v1/controllers_config.go
(1 hunks)internal/api/v1/controllers_config_test.go
(1 hunks)internal/api/v1/controllers_info.go
(1 hunks)internal/api/v1/controllers_info_test.go
(1 hunks)internal/api/v1/controllers_logs_list.go
(1 hunks)internal/api/v1/controllers_logs_list_test.go
(2 hunks)internal/api/v1/controllers_stats.go
(1 hunks)internal/api/v1/controllers_stats_test.go
(1 hunks)internal/api/v1/controllers_transactions.go
(1 hunks)internal/api/v1/controllers_transactions_add_metadata.go
(1 hunks)internal/api/v1/controllers_transactions_add_metadata_test.go
(1 hunks)internal/api/v1/controllers_transactions_count.go
(1 hunks)internal/api/v1/controllers_transactions_count_test.go
(1 hunks)internal/api/v1/controllers_transactions_create.go
(1 hunks)internal/api/v1/controllers_transactions_create_test.go
(2 hunks)internal/api/v1/controllers_transactions_delete_metadata.go
(1 hunks)internal/api/v1/controllers_transactions_delete_metadata_test.go
(1 hunks)internal/api/v1/controllers_transactions_list.go
(1 hunks)internal/api/v1/controllers_transactions_list_test.go
(2 hunks)internal/api/v1/controllers_transactions_read.go
(1 hunks)internal/api/v1/controllers_transactions_read_test.go
(1 hunks)internal/api/v1/controllers_transactions_revert.go
(1 hunks)internal/api/v1/controllers_transactions_revert_test.go
(1 hunks)internal/api/v1/middleware_auto_create_ledger.go
(1 hunks)internal/api/v1/mocks_ledger_controller_test.go
(1 hunks)internal/api/v1/mocks_system_controller_test.go
(1 hunks)internal/api/v1/routes.go
(1 hunks)internal/api/v1/utils.go
(1 hunks)internal/api/v2/common.go
(1 hunks)internal/api/v2/controllers_accounts_add_metadata.go
(1 hunks)internal/api/v2/controllers_accounts_add_metadata_test.go
(1 hunks)internal/api/v2/controllers_accounts_count.go
(1 hunks)internal/api/v2/controllers_accounts_count_test.go
(1 hunks)internal/api/v2/controllers_accounts_delete_metadata.go
(1 hunks)internal/api/v2/controllers_accounts_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_accounts_list.go
(1 hunks)internal/api/v2/controllers_accounts_list_test.go
(1 hunks)internal/api/v2/controllers_accounts_read.go
(1 hunks)internal/api/v2/controllers_accounts_read_test.go
(1 hunks)internal/api/v2/controllers_balances.go
(1 hunks)internal/api/v2/controllers_balances_test.go
(1 hunks)internal/api/v2/controllers_bulk.go
(1 hunks)internal/api/v2/controllers_bulk_test.go
(2 hunks)internal/api/v2/controllers_ledgers_create.go
(1 hunks)internal/api/v2/controllers_ledgers_create_test.go
(1 hunks)internal/api/v2/controllers_ledgers_delete_metadata.go
(1 hunks)internal/api/v2/controllers_ledgers_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_ledgers_info.go
(1 hunks)internal/api/v2/controllers_ledgers_info_test.go
(1 hunks)internal/api/v2/controllers_ledgers_list.go
(1 hunks)internal/api/v2/controllers_ledgers_list_test.go
(1 hunks)internal/api/v2/controllers_ledgers_read.go
(1 hunks)internal/api/v2/controllers_ledgers_read_test.go
(1 hunks)internal/api/v2/controllers_ledgers_update_metadata.go
(1 hunks)internal/api/v2/controllers_ledgers_update_metadata_test.go
(1 hunks)internal/api/v2/controllers_logs_export_test.go
(1 hunks)internal/api/v2/controllers_logs_import.go
(1 hunks)internal/api/v2/controllers_logs_import_test.go
(1 hunks)internal/api/v2/controllers_logs_list.go
(1 hunks)internal/api/v2/controllers_logs_list_test.go
(2 hunks)internal/api/v2/controllers_stats.go
(1 hunks)internal/api/v2/controllers_stats_test.go
(1 hunks)internal/api/v2/controllers_transactions_add_metadata.go
(1 hunks)internal/api/v2/controllers_transactions_add_metadata_test.go
(1 hunks)internal/api/v2/controllers_transactions_count.go
(1 hunks)internal/api/v2/controllers_transactions_count_test.go
(1 hunks)internal/api/v2/controllers_transactions_create.go
(1 hunks)internal/api/v2/controllers_transactions_create_test.go
(1 hunks)internal/api/v2/controllers_transactions_delete_metadata.go
(1 hunks)internal/api/v2/controllers_transactions_delete_metadata_test.go
(1 hunks)internal/api/v2/controllers_transactions_list.go
(1 hunks)internal/api/v2/controllers_transactions_list_test.go
(2 hunks)internal/api/v2/controllers_transactions_read.go
(1 hunks)internal/api/v2/controllers_transactions_read_test.go
(1 hunks)internal/api/v2/controllers_transactions_revert.go
(1 hunks)internal/api/v2/controllers_transactions_revert_test.go
(1 hunks)internal/api/v2/controllers_volumes.go
(1 hunks)internal/api/v2/controllers_volumes_test.go
(1 hunks)internal/api/v2/mocks_ledger_controller_test.go
(1 hunks)internal/api/v2/mocks_system_controller_test.go
(1 hunks)internal/api/v2/query.go
(1 hunks)internal/api/v2/routes.go
(4 hunks)internal/bus/listener.go
(1 hunks)internal/bus/listener_test.go
(1 hunks)internal/bus/message.go
(1 hunks)internal/controller/ledger/controller.go
(1 hunks)internal/controller/ledger/controller_default.go
(1 hunks)internal/controller/ledger/controller_default_test.go
(1 hunks)internal/controller/ledger/controller_generated_test.go
(1 hunks)internal/controller/ledger/controller_with_too_many_client_handling.go
(1 hunks)internal/controller/ledger/controller_with_too_many_client_handling_test.go
(1 hunks)internal/controller/ledger/controller_with_traces.go
(1 hunks)internal/controller/ledger/errors.go
(1 hunks)internal/controller/ledger/listener.go
(1 hunks)internal/controller/ledger/listener_generated_test.go
(1 hunks)internal/controller/ledger/log_process.go
(1 hunks)internal/controller/ledger/log_process_test.go
(1 hunks)internal/controller/ledger/mocks_test.go
(1 hunks)internal/controller/ledger/numscript.go
(1 hunks)internal/controller/ledger/numscript_runtime.go
(1 hunks)internal/controller/ledger/stats_test.go
(1 hunks)internal/controller/ledger/store.go
(1 hunks)internal/controller/ledger/store_generated_test.go
(1 hunks)internal/controller/system/controller.go
(1 hunks)internal/controller/system/state_tracker.go
(1 hunks)internal/controller/system/store.go
(1 hunks)internal/ledger.go
(1 hunks)internal/log.go
(1 hunks)internal/machine/examples/basic.go
(1 hunks)internal/machine/funding.go
(1 hunks)internal/machine/vm/machine.go
(1 hunks)internal/machine/vm/machine_test.go
(1 hunks)internal/machine/vm/run.go
(1 hunks)internal/machine/vm/run_test.go
(1 hunks)internal/machine/vm/store.go
(1 hunks)internal/moves.go
(1 hunks)internal/storage/bucket/bucket.go
(1 hunks)internal/storage/bucket/default_bucket.go
(1 hunks)internal/storage/bucket/default_bucket_test.go
(1 hunks)internal/storage/bucket/main_test.go
(1 hunks)internal/storage/bucket/migrations.go
(1 hunks)internal/storage/bucket/migrations_test.go
(1 hunks)internal/storage/common/paginator.go
(1 hunks)internal/storage/common/paginator_column.go
(1 hunks)internal/storage/common/paginator_offset.go
(1 hunks)internal/storage/common/resource.go
(2 hunks)internal/storage/driver/buckets_generated_test.go
(1 hunks)internal/storage/driver/driver.go
(1 hunks)internal/storage/driver/driver_test.go
(1 hunks)internal/storage/driver/main_test.go
(1 hunks)internal/storage/driver/module.go
(1 hunks)internal/storage/driver/rollbacks.go
(1 hunks)internal/storage/driver/system_generated_test.go
(1 hunks)internal/storage/ledger/accounts.go
(1 hunks)internal/storage/ledger/accounts_test.go
(1 hunks)internal/storage/ledger/balances.go
(1 hunks)internal/storage/ledger/balances_test.go
(1 hunks)internal/storage/ledger/logs.go
(1 hunks)internal/storage/ledger/logs_test.go
(2 hunks)internal/storage/ledger/main_test.go
(3 hunks)internal/storage/ledger/moves.go
(1 hunks)internal/storage/ledger/moves_test.go
(1 hunks)internal/storage/ledger/store.go
(1 hunks)internal/storage/ledger/transactions.go
(2 hunks)internal/storage/ledger/transactions_test.go
(1 hunks)internal/storage/ledger/volumes.go
(1 hunks)internal/storage/ledger/volumes_test.go
(1 hunks)internal/storage/module.go
(1 hunks)internal/storage/system/main_test.go
(1 hunks)internal/storage/system/migrations.go
(1 hunks)internal/storage/system/migrations_test.go
(1 hunks)internal/storage/system/store.go
(1 hunks)internal/storage/system/store_test.go
(2 hunks)internal/tracing/tracing.go
(1 hunks)internal/transaction.go
(2 hunks)internal/transaction_test.go
(1 hunks)internal/worker/async_block.go
(2 hunks)internal/worker/fx.go
(1 hunks)pkg/features/features.go
(1 hunks)pkg/generate/generator.go
(1 hunks)pkg/generate/generator_test.go
(3 hunks)pkg/generate/set.go
(1 hunks)pkg/testserver/client.go
(1 hunks)pkg/testserver/ginkgo/helpers.go
(1 hunks)pkg/testserver/ginkgo/matchers.go
(2 hunks)pkg/testserver/server.go
(1 hunks)pkg/testserver/utils.go
(1 hunks)pkg/testserver/worker.go
(1 hunks)test/e2e/api_accounts_list_test.go
(18 hunks)
⛔ Files not processed due to max files limit (30)
- test/e2e/api_accounts_metadata_test.go
- test/e2e/api_balances_aggregated_test.go
- test/e2e/api_bulk_test.go
- test/e2e/api_ledgers_create_test.go
- test/e2e/api_ledgers_import_test.go
- test/e2e/api_ledgers_list_test.go
- test/e2e/api_ledgers_metadata_test.go
- test/e2e/api_logs_list_test.go
- test/e2e/api_transactions_create_test.go
- test/e2e/api_transactions_list_test.go
- test/e2e/api_transactions_metadata_test.go
- test/e2e/api_transactions_revert_test.go
- test/e2e/api_volumes_test.go
- test/e2e/app_lifecycle_test.go
- test/e2e/app_logs_blocks_async_test.go
- test/e2e/app_multiple_instance_test.go
- test/e2e/suite_test.go
- test/e2e/v1_api_balances_test.go
- test/migrations/upgrade_test.go
- test/performance/pkg/env/configure.go
- test/performance/pkg/env/features.go
- test/performance/pkg/read/read_test.go
- test/performance/pkg/write/local_env_test.go
- test/performance/pkg/write/report_test.go
- test/performance/pkg/write/write_test.go
- test/stress/stress_test.go
- test/stress/suite_test.go
- tools/generator/cmd/root.go
- tools/provisioner/pkg/reconciler.go
- tools/provisioner/pkg/store.go
✅ Files skipped from review due to trivial changes (5)
- internal/controller/ledger/controller_generated_test.go
- internal/api/v1/mocks_ledger_controller_test.go
- internal/api/bulking/mocks_ledger_controller_test.go
- internal/controller/ledger/store_generated_test.go
- internal/storage/driver/system_generated_test.go
🚧 Files skipped from review as they are similar to previous changes (195)
- internal/controller/ledger/listener.go
- internal/api/v2/controllers_ledgers_info.go
- internal/api/v1/controllers_accounts_delete_metadata.go
- internal/storage/ledger/moves.go
- internal/api/v1/mocks_system_controller_test.go
- internal/api/v2/controllers_ledgers_delete_metadata.go
- deployments/pulumi/pkg/monitoring/monitoring.go
- internal/api/v1/controllers_stats.go
- internal/api/v2/controllers_transactions_count.go
- internal/api/v1/controllers_transactions_count.go
- internal/api/v2/query.go
- internal/api/v1/controllers_accounts.go
- internal/api/v2/controllers_transactions_delete_metadata.go
- internal/bus/listener_test.go
- internal/api/v2/controllers_accounts_delete_metadata.go
- internal/storage/driver/module.go
- pkg/features/features.go
- internal/api/v2/controllers_accounts_list.go
- internal/controller/ledger/numscript.go
- internal/api/v2/controllers_bulk.go
- internal/api/bulking/handler_stream_json_test.go
- internal/api/v1/controllers_logs_list.go
- internal/machine/vm/run_test.go
- internal/storage/common/paginator_column.go
- internal/controller/ledger/errors.go
- internal/api/bulking/bulker.go
- internal/api/v1/controllers_transactions.go
- internal/api/v2/controllers_volumes.go
- internal/controller/system/controller.go
- internal/api/v2/controllers_logs_export_test.go
- internal/api/v1/controllers_info.go
- internal/storage/common/paginator_offset.go
- internal/api/v1/controllers_balances_aggregates.go
- internal/storage/driver/rollbacks.go
- internal/api/v2/controllers_accounts_count.go
- internal/controller/ledger/listener_generated_test.go
- internal/api/common/middleware_logid.go
- internal/api/v2/controllers_transactions_revert_test.go
- internal/storage/system/store.go
- internal/api/v2/controllers_transactions_revert.go
- internal/controller/ledger/numscript_runtime.go
- internal/storage/bucket/bucket.go
- internal/storage/ledger/logs.go
- internal/api/v2/controllers_logs_import.go
- internal/api/v1/routes.go
- deployments/pulumi/pkg/config/config.go
- internal/api/v2/controllers_stats.go
- internal/api/bulking/handler_json.go
- internal/api/bulking/handler_stream_text_test.go
- internal/machine/vm/store.go
- internal/api/v2/controllers_accounts_delete_metadata_test.go
- internal/machine/vm/machine_test.go
- internal/api/v1/controllers_accounts_read_test.go
- internal/storage/driver/buckets_generated_test.go
- internal/storage/ledger/balances.go
- internal/controller/ledger/stats_test.go
- internal/controller/ledger/log_process.go
- internal/api/v2/controllers_transactions_create.go
- internal/storage/ledger/volumes.go
- internal/storage/bucket/migrations.go
- internal/bus/listener.go
- internal/controller/ledger/controller_with_too_many_client_handling.go
- pkg/testserver/client.go
- internal/api/v1/controllers_transactions_count_test.go
- internal/tracing/tracing.go
- internal/machine/funding.go
- internal/api/v1/middleware_auto_create_ledger.go
- cmd/buckets_upgrade.go
- internal/worker/fx.go
- internal/worker/async_block.go
- internal/controller/system/state_tracker.go
- internal/api/v2/controllers_ledgers_read.go
- internal/api/v2/controllers_stats_test.go
- internal/api/v1/controllers_transactions_delete_metadata.go
- internal/storage/bucket/default_bucket.go
- internal/api/v2/controllers_ledgers_update_metadata.go
- internal/controller/ledger/log_process_test.go
- internal/bus/message.go
- internal/api/v1/controllers_accounts_count_test.go
- internal/api/v2/controllers_logs_import_test.go
- pkg/generate/set.go
- internal/machine/vm/run.go
- internal/storage/driver/driver.go
- internal/api/v1/controllers_balances_list.go
- internal/api/v1/controllers_transactions_read.go
- internal/controller/ledger/controller_with_traces.go
- internal/api/v2/controllers_ledgers_create.go
- internal/api/v2/controllers_transactions_add_metadata.go
- internal/storage/common/paginator.go
- internal/api/v2/controllers_ledgers_list.go
- internal/api/common/errors.go
- internal/api/v2/controllers_ledgers_read_test.go
- internal/api/bulking/handler_json_test.go
- internal/storage/system/main_test.go
- internal/api/v1/utils.go
- internal/machine/vm/machine.go
- internal/api/v2/controllers_accounts_read.go
- internal/api/v1/controllers_transactions_list.go
- internal/storage/ledger/accounts.go
- internal/api/v2/controllers_accounts_add_metadata.go
- internal/moves.go
- internal/account.go
- cmd/buckets_upgrade_test.go
- pkg/generate/generator.go
- internal/api/v2/controllers_transactions_list.go
- internal/api/v1/controllers_accounts_count.go
- internal/api/v2/controllers_transactions_delete_metadata_test.go
- internal/api/v2/mocks_system_controller_test.go
- internal/api/v2/controllers_accounts_read_test.go
- internal/api/v1/controllers_config_test.go
- internal/api/v1/controllers_accounts_add_metadata.go
- internal/storage/system/migrations.go
- internal/api/v1/controllers_transactions_revert.go
- internal/api/common/middleware_resolver_test.go
- internal/api/module.go
- internal/api/v2/controllers_transactions_add_metadata_test.go
- internal/log.go
- internal/api/v2/controllers_logs_list_test.go
- internal/api/v1/controllers_logs_list_test.go
- internal/api/v2/controllers_ledgers_list_test.go
- internal/controller/ledger/controller.go
- internal/storage/module.go
- internal/api/bulking/bulker_test.go
- internal/storage/bucket/migrations_test.go
- internal/api/v1/controllers_accounts_read.go
- internal/api/v1/controllers_transactions_delete_metadata_test.go
- internal/storage/ledger/logs_test.go
- internal/controller/system/store.go
- cmd/root.go
- internal/api/v2/controllers_accounts_count_test.go
- internal/api/v2/common.go
- internal/api/v2/controllers_accounts_add_metadata_test.go
- internal/storage/bucket/main_test.go
- internal/transaction_test.go
- internal/api/v1/controllers_transactions_add_metadata_test.go
- internal/controller/ledger/controller_with_too_many_client_handling_test.go
- internal/api/v1/controllers_transactions_list_test.go
- internal/api/v1/controllers_balances_aggregates_test.go
- internal/storage/common/resource.go
- pkg/testserver/utils.go
- internal/api/v2/controllers_ledgers_info_test.go
- internal/api/v1/controllers_accounts_delete_metadata_test.go
- internal/api/v2/controllers_transactions_list_test.go
- internal/storage/ledger/transactions_test.go
- internal/storage/driver/driver_test.go
- internal/api/v2/controllers_balances.go
- internal/api/v1/controllers_transactions_revert_test.go
- internal/storage/system/migrations_test.go
- internal/api/v1/controllers_transactions_add_metadata.go
- internal/controller/ledger/mocks_test.go
- internal/api/v2/controllers_transactions_read.go
- internal/api/v1/controllers_accounts_list.go
- internal/api/v1/controllers_transactions_create.go
- internal/api/v1/controllers_accounts_list_test.go
- internal/api/common/mocks_system_controller_test.go
- internal/api/v1/controllers_transactions_read_test.go
- internal/storage/ledger/transactions.go
- internal/api/v2/mocks_ledger_controller_test.go
- internal/api/bulking/elements.go
- internal/machine/examples/basic.go
- internal/api/v2/controllers_transactions_count_test.go
- internal/api/v2/controllers_logs_list.go
- internal/api/v1/controllers_accounts_add_metadata_test.go
- internal/storage/driver/main_test.go
- internal/api/v2/controllers_ledgers_update_metadata_test.go
- internal/api/common/mocks_ledger_controller_test.go
- internal/ledger.go
- internal/storage/ledger/store.go
- internal/storage/ledger/moves_test.go
- internal/api/v2/controllers_accounts_list_test.go
- internal/api/v1/controllers_config.go
- internal/api/v2/controllers_ledgers_delete_metadata_test.go
- internal/api/router.go
- internal/api/v2/controllers_ledgers_create_test.go
- internal/storage/bucket/default_bucket_test.go
- internal/api/v1/controllers_info_test.go
- internal/api/v1/controllers_transactions_create_test.go
- internal/api/v2/controllers_bulk_test.go
- internal/api/common/middleware_resolver.go
- internal/controller/ledger/controller_default_test.go
- cmd/worker.go
- internal/api/v2/controllers_balances_test.go
- internal/storage/system/store_test.go
- internal/api/v2/controllers_volumes_test.go
- internal/api/v1/controllers_stats_test.go
- internal/storage/ledger/balances_test.go
- internal/api/v2/routes.go
- internal/controller/ledger/store.go
- internal/controller/ledger/controller_default.go
- internal/transaction.go
- internal/api/v2/controllers_transactions_create_test.go
- cmd/serve.go
- internal/api/v2/controllers_transactions_read_test.go
- internal/storage/ledger/volumes_test.go
- internal/storage/ledger/accounts_test.go
🧰 Additional context used
🧬 Code Definitions (6)
pkg/testserver/worker.go (1)
cmd/worker.go (2)
WorkerAsyncBlockHasherMaxBlockSizeFlag
(17-17)WorkerAsyncBlockHasherScheduleFlag
(18-18)
pkg/testserver/ginkgo/matchers.go (5)
pkg/client/models/operations/v2listledgers.go (1)
V2ListLedgersRequest
(9-20)pkg/client/models/operations/v2getbalancesaggregated.go (1)
V2GetBalancesAggregatedRequest
(11-18)pkg/client/models/components/v2aggregatebalancesresponse.go (1)
V2AggregateBalancesResponse
(10-12)pkg/client/models/operations/v2listtransactions.go (1)
V2ListTransactionsRequest
(36-53)pkg/client/models/components/v2transactionscursorresponse.go (1)
V2TransactionsCursorResponse
(48-50)
test/e2e/api_accounts_list_test.go (8)
pkg/testserver/ginkgo/helpers.go (1)
DeferTestServer
(12-19)pkg/testserver/client.go (1)
DeferClient
(15-17)internal/controller/ledger/controller.go (1)
CreateTransaction
(84-87)pkg/client/models/components/v2errorsenum.go (1)
V2ErrorsEnumValidation
(15-15)pkg/client/models/operations/v2listaccounts.go (2)
V2ListAccountsRequest
(11-26)V2ListAccountsResponse
(81-85)pkg/client/models/operations/v2createtransaction.go (1)
V2CreateTransactionRequest
(9-23)pkg/client/models/operations/v2getaccount.go (1)
V2GetAccountRequest
(11-22)internal/controller/ledger/store.go (1)
Balance
(22-25)
pkg/testserver/server.go (1)
cmd/serve.go (5)
BindFlag
(58-58)ExperimentalFeaturesFlag
(70-70)NumscriptInterpreterFlag
(68-68)MaxPageSizeFlag
(66-66)DefaultPageSizeFlag
(65-65)
pkg/testserver/ginkgo/helpers.go (2)
cmd/root.go (1)
NewRootCommand
(23-43)pkg/testserver/server.go (1)
GetTestServerOptions
(12-18)
internal/storage/ledger/main_test.go (4)
internal/storage/system/store.go (1)
New
(133-143)internal/storage/driver/driver.go (2)
New
(285-302)Driver
(27-36)internal/storage/ledger/store.go (1)
New
(161-248)internal/storage/driver/main_test.go (1)
TestMain
(28-44)
🔇 Additional comments (49)
pkg/testserver/worker.go (3)
5-7
: Import changes look goodThe imports have been updated to use go-libs v3 testing package and strconv, aligning with the PR objective to upgrade to v3 of go-libs.
10-15
: Well-structured instrumentation functionThis function properly encapsulates the worker configuration for log hash block max size as an instrumentation function. It correctly uses the command-line flag constant from the cmd package.
17-22
: Well-structured instrumentation function for CRON specThis function mirrors the structure of the previous one, providing a consistent approach to instrumentation. Both functions follow the same pattern, which is good for maintainability.
pkg/testserver/ginkgo/matchers.go (7)
1-1
: Package name change is appropriateThe package name change from
testserver
toginkgo
better reflects the purpose of this file, which contains Ginkgo test matchers.
8-13
: Updated imports to go-libs v3The imports have been correctly updated to use go-libs v3 packages, which aligns with the PR objective to upgrade the library version.
27-30
: Updated type assertion for deferred serviceThe type assertion has been properly updated to handle the new deferred service model. The error message has also been updated accordingly.
33-37
: Added proper error handling for deferred serviceThe code now correctly waits for the deferred service to resolve and includes error handling, which is a good practice when working with deferred values.
39-41
: Updated client access patternThe client access pattern has been updated to use the new approach via
testserver.Client(testServer).Ledger.V2
, which aligns with the new architecture.
46-50
: Updated ledger data accessThe code now correctly accesses ledger data through the updated response structure
ledgers.V2LedgerListResponse.Cursor.Data
.
52-62
: Updated aggregated balances data structure accessThe code now correctly accesses the aggregated balances data through the updated response structure and performs the appropriate checks for empty data and USD balance.
pkg/testserver/ginkgo/helpers.go (3)
1-10
: Well-structured package and importsThe new helpers file is correctly organized with appropriate imports for the go-libs v3 packages and local packages. The package name is consistent with the matchers file.
12-19
: Well-designed DeferTestServer functionThis helper function simplifies the creation of test servers by wrapping the common configuration pattern. It properly uses the command root and appends options in a flexible way.
21-31
: Well-designed DeferTestWorker functionSimilar to the server function, this worker helper correctly configures the worker with appropriate instrumentation. It follows the same pattern, promoting consistency in the codebase.
pkg/testserver/server.go (7)
6-9
: Updated imports to go-libs v3The imports have been correctly updated to use go-libs v3 packages for bun, deferred, and testservice, aligning with the PR objective.
12-18
: Well-structured server options functionThis function provides a clean way to define common server options, including binding to a dynamic port, configuring PostgreSQL, and enabling HTTP server instrumentation.
20-27
: Clean NewTestServer implementationThis function provides a simple and consistent way to create a test server with the provided PostgreSQL connection options and additional options. It reuses the GetTestServerOptions function, which is good for maintainability.
29-34
: Concise instrumentation function for experimental featuresThis function follows the pattern of other instrumentation functions, providing a consistent way to enable experimental features via command-line arguments.
36-41
: Clear instrumentation function for Numscript rewriteThis function properly configures the experimental Numscript interpreter flag, following the same pattern as other instrumentation functions.
43-48
: Well-implemented MaxPageSizeInstrumentation functionThis function correctly converts the uint64 size parameter to a string and appends it to the command-line arguments, following the established pattern.
50-55
: Consistent DefaultPageSizeInstrumentation implementationThis function follows the same pattern as the MaxPageSizeInstrumentation function, providing a consistent approach to configuration. The code is clean and easy to understand.
test/e2e/api_accounts_list_test.go (17)
7-12
: Imports upgraded to go-libs v3
These imports look correct and consistent with the v3 migration.
16-16
: No concerns
No issues spotted on this line.
21-21
: No concerns
No issues spotted on this line.
23-23
: No concerns
No issues spotted on this line.
34-42
: DeferTestServer usage
This updated approach usingginkgo.DeferTestServer
is consistent with the new library pattern and appears correct.
44-49
: BeforeEach block
Looks good. Properly sets up the default ledger before tests.
63-101
: BeforeEach metadata and transaction setup
This initialization is clear and ensures test data is ready for subsequent checks.
117-125
: Count accounts test
Properly checks response headers for “Count”.
127-165
: List accounts test
The logic for verifying the listed accounts and volumes is straightforward.
166-210
: Filtering by address
Filtering and verifying the results is correct.
211-231
: Filtering by metadata
Implementation cleanly checks metadata-based filtering.
232-250
: Using $not filter
Filter negation logic is tested thoroughly.
254-263
: Count accounts empty
Ensures zero accounts are correctly counted.
264-273
: List accounts empty
Validates empty list handling as expected.
284-335
: Pagination logic
Pagination and cursor checks for multiple pages look well-structured.
338-367
: Next and previous cursors
Thoroughly verifies next/previous cursor functionality for multi-page results.
375-415
: Transactions in past and future
Test ensures future transaction is ignored in effective volumes as intended.pkg/generate/generator_test.go (6)
6-11
: Imports for go-libs v3
All updated imports look valid.
25-34
: NewTestServer usage
Server initialization with deferred connection options is consistent and appears correct.
39-39
: CreateLedger call
Proper approach to initializing the default ledger before running tests.
55-55
: Apply action
Seamless usage of the new client function for applying generator actions.
59-59
: ListTransactions call
Retrieving transactions from the same new client pattern is consistent.
63-69
: Reverted transaction checks
Verifying the “reverted” flags and metadata is correctly handled.internal/storage/ledger/main_test.go (6)
7-9
: Imports referencing go-libs v3
Looks consistent with the updated package structure.
18-18
: No concerns
This single line change is fine.
26-27
: Logging and PGTesting
Import usage is straightforward here.
33-35
: Deferred variables
Deferred creation of server, DB, and driver is a clean approach for test setup.
40-44
: srv.LoadAsync
Asynchronous loading of Postgres server is well-structured.
45-70
: defaultBunDB.LoadAsync
Database initialization logic and migrations are handled properly.
No description provided.