1
1
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- //! Simple SubgraphClient Abstraction for Testing
4
+ //! TAP SubgraphClient Abstraction for Testing
5
5
//!
6
6
//! This provides a minimal abstraction to enable Layer 2 integration testing
7
7
//! without the complexity of async trait objects.
@@ -12,24 +12,24 @@ use indexer_monitor::SubgraphClient;
12
12
use serde_json;
13
13
use std:: sync:: Arc ;
14
14
15
- /// Simple enum wrapper for different SubgraphClient implementations
15
+ /// TAP-specific enum wrapper for different SubgraphClient implementations
16
16
/// This solves the dependency injection problem for testing
17
17
#[ derive( Clone ) ]
18
- pub enum SimpleSubgraphClient {
18
+ pub enum TapSubgraphClient {
19
19
/// Production implementation using real SubgraphClient
20
20
Production ( Arc < SubgraphClient > ) ,
21
21
/// Mock implementation for testing
22
- Mock ( SimpleSubgraphMock ) ,
22
+ Mock ( TapSubgraphMock ) ,
23
23
}
24
24
25
- impl SimpleSubgraphClient {
25
+ impl TapSubgraphClient {
26
26
/// Create a production client wrapper
27
27
pub fn production ( client : Arc < SubgraphClient > ) -> Self {
28
28
Self :: Production ( client)
29
29
}
30
30
31
31
/// Create a mock client for testing
32
- pub fn mock ( mock : SimpleSubgraphMock ) -> Self {
32
+ pub fn mock ( mock : TapSubgraphMock ) -> Self {
33
33
Self :: Mock ( mock)
34
34
}
35
35
@@ -188,16 +188,16 @@ impl SimpleSubgraphClient {
188
188
}
189
189
}
190
190
191
- /// Simple mock for testing SubgraphClient behavior
191
+ /// TAP-specific mock for testing SubgraphClient behavior
192
192
#[ derive( Clone ) ]
193
- pub struct SimpleSubgraphMock {
193
+ pub struct TapSubgraphMock {
194
194
/// Controls whether allocation validation succeeds
195
195
pub should_validate_allocation : bool ,
196
196
/// Controls whether the client appears healthy
197
197
pub is_healthy : bool ,
198
198
}
199
199
200
- impl SimpleSubgraphMock {
200
+ impl TapSubgraphMock {
201
201
/// Create a new mock with default settings
202
202
pub fn new ( ) -> Self {
203
203
Self {
@@ -219,7 +219,7 @@ impl SimpleSubgraphMock {
219
219
}
220
220
}
221
221
222
- impl Default for SimpleSubgraphMock {
222
+ impl Default for TapSubgraphMock {
223
223
fn default ( ) -> Self {
224
224
Self :: new ( )
225
225
}
@@ -233,8 +233,8 @@ mod tests {
233
233
234
234
#[ tokio:: test]
235
235
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) ;
238
238
239
239
let test_address = Address :: from ( [ 0x42 ; 20 ] ) ;
240
240
let allocation_id = AllocationId :: Legacy ( test_address. into ( ) ) ;
@@ -245,8 +245,8 @@ mod tests {
245
245
246
246
#[ tokio:: test]
247
247
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) ;
250
250
251
251
let test_address = Address :: from ( [ 0x42 ; 20 ] ) ;
252
252
let allocation_id = AllocationId :: Legacy ( test_address. into ( ) ) ;
@@ -257,11 +257,11 @@ mod tests {
257
257
258
258
#[ tokio:: test]
259
259
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) ;
262
262
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) ;
265
265
266
266
assert ! ( healthy_client. is_healthy( ) . await ) ;
267
267
assert ! ( !unhealthy_client. is_healthy( ) . await ) ;
0 commit comments