Skip to content

Commit 3c00443

Browse files
committed
refactor(agent): rename TapSubgraphClient
1 parent 74ccb43 commit 3c00443

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

crates/tap-agent/src/subgraph_client_abstraction.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//! Simple SubgraphClient Abstraction for Testing
4+
//! TAP SubgraphClient Abstraction for Testing
55
//!
66
//! This provides a minimal abstraction to enable Layer 2 integration testing
77
//! without the complexity of async trait objects.
@@ -12,24 +12,24 @@ use indexer_monitor::SubgraphClient;
1212
use serde_json;
1313
use std::sync::Arc;
1414

15-
/// Simple enum wrapper for different SubgraphClient implementations
15+
/// TAP-specific enum wrapper for different SubgraphClient implementations
1616
/// This solves the dependency injection problem for testing
1717
#[derive(Clone)]
18-
pub enum SimpleSubgraphClient {
18+
pub enum TapSubgraphClient {
1919
/// Production implementation using real SubgraphClient
2020
Production(Arc<SubgraphClient>),
2121
/// Mock implementation for testing
22-
Mock(SimpleSubgraphMock),
22+
Mock(TapSubgraphMock),
2323
}
2424

25-
impl SimpleSubgraphClient {
25+
impl TapSubgraphClient {
2626
/// Create a production client wrapper
2727
pub fn production(client: Arc<SubgraphClient>) -> Self {
2828
Self::Production(client)
2929
}
3030

3131
/// Create a mock client for testing
32-
pub fn mock(mock: SimpleSubgraphMock) -> Self {
32+
pub fn mock(mock: TapSubgraphMock) -> Self {
3333
Self::Mock(mock)
3434
}
3535

@@ -188,16 +188,16 @@ impl SimpleSubgraphClient {
188188
}
189189
}
190190

191-
/// Simple mock for testing SubgraphClient behavior
191+
/// TAP-specific mock for testing SubgraphClient behavior
192192
#[derive(Clone)]
193-
pub struct SimpleSubgraphMock {
193+
pub struct TapSubgraphMock {
194194
/// Controls whether allocation validation succeeds
195195
pub should_validate_allocation: bool,
196196
/// Controls whether the client appears healthy
197197
pub is_healthy: bool,
198198
}
199199

200-
impl SimpleSubgraphMock {
200+
impl TapSubgraphMock {
201201
/// Create a new mock with default settings
202202
pub fn new() -> Self {
203203
Self {
@@ -219,7 +219,7 @@ impl SimpleSubgraphMock {
219219
}
220220
}
221221

222-
impl Default for SimpleSubgraphMock {
222+
impl Default for TapSubgraphMock {
223223
fn default() -> Self {
224224
Self::new()
225225
}
@@ -233,8 +233,8 @@ mod tests {
233233

234234
#[tokio::test]
235235
async fn test_mock_allocation_validation_success() {
236-
let mock = SimpleSubgraphMock::new().with_allocation_validation(true);
237-
let client = SimpleSubgraphClient::mock(mock);
236+
let mock = TapSubgraphMock::new().with_allocation_validation(true);
237+
let client = TapSubgraphClient::mock(mock);
238238

239239
let test_address = Address::from([0x42; 20]);
240240
let allocation_id = AllocationId::Legacy(test_address.into());
@@ -245,8 +245,8 @@ mod tests {
245245

246246
#[tokio::test]
247247
async fn test_mock_allocation_validation_failure() {
248-
let mock = SimpleSubgraphMock::new().with_allocation_validation(false);
249-
let client = SimpleSubgraphClient::mock(mock);
248+
let mock = TapSubgraphMock::new().with_allocation_validation(false);
249+
let client = TapSubgraphClient::mock(mock);
250250

251251
let test_address = Address::from([0x42; 20]);
252252
let allocation_id = AllocationId::Legacy(test_address.into());
@@ -257,11 +257,11 @@ mod tests {
257257

258258
#[tokio::test]
259259
async fn test_mock_health_check() {
260-
let healthy_mock = SimpleSubgraphMock::new().with_health_status(true);
261-
let healthy_client = SimpleSubgraphClient::mock(healthy_mock);
260+
let healthy_mock = TapSubgraphMock::new().with_health_status(true);
261+
let healthy_client = TapSubgraphClient::mock(healthy_mock);
262262

263-
let unhealthy_mock = SimpleSubgraphMock::new().with_health_status(false);
264-
let unhealthy_client = SimpleSubgraphClient::mock(unhealthy_mock);
263+
let unhealthy_mock = TapSubgraphMock::new().with_health_status(false);
264+
let unhealthy_client = TapSubgraphClient::mock(unhealthy_mock);
265265

266266
assert!(healthy_client.is_healthy().await);
267267
assert!(!unhealthy_client.is_healthy().await);

crates/tap-agent/tests/production_integration_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use anyhow::Result;
1313
use indexer_monitor::EscrowAccounts;
1414
use indexer_tap_agent::{
1515
agent::sender_account::SenderAccountConfig,
16-
subgraph_client_abstraction::{SimpleSubgraphClient, SimpleSubgraphMock},
16+
subgraph_client_abstraction::{TapSubgraphClient, TapSubgraphMock},
1717
task_lifecycle::LifecycleManager,
1818
};
1919
use sqlx::Row;
@@ -105,10 +105,10 @@ impl ProductionTestEnvironment {
105105
async fn spawn_production_sender_account(
106106
&self,
107107
sender: Address,
108-
mock_client: SimpleSubgraphMock,
108+
mock_client: TapSubgraphMock,
109109
) -> Result<()> {
110110
// SUCCESS: We can now create controlled mock instances using the simple wrapper!
111-
let client = SimpleSubgraphClient::mock(mock_client);
111+
let client = TapSubgraphClient::mock(mock_client);
112112

113113
// Validate that the mock works as expected
114114
let is_healthy = client.is_healthy().await;
@@ -124,7 +124,7 @@ impl ProductionTestEnvironment {
124124
}
125125
}
126126

127-
// Note: SimpleSubgraphMock is now provided by the simple abstraction layer
127+
// Note: TapSubgraphMock is now provided by the simple abstraction layer
128128
// This solves the architectural limitation we discovered with a clean, working approach!
129129

130130
/// Test production database operations with real SQL (this works!)
@@ -169,11 +169,11 @@ async fn test_subgraph_client_abstraction_solution() -> Result<()> {
169169
let env = ProductionTestEnvironment::new(ProductionTestConfig::default()).await?;
170170

171171
// ✅ SOLVED: We can now create controlled mock instances
172-
let mock_config = SimpleSubgraphMock::new()
172+
let mock_config = TapSubgraphMock::new()
173173
.with_allocation_validation(true)
174174
.with_health_status(true);
175175

176-
let client = SimpleSubgraphClient::mock(mock_config.clone());
176+
let client = TapSubgraphClient::mock(mock_config.clone());
177177

178178
// ✅ SOLVED: Test allocation validation with controlled behavior
179179
let test_address = Address::from([0x42; 20]);

0 commit comments

Comments
 (0)