Skip to content

Commit 2bb8147

Browse files
committed
test: update local network testing for horizon
test(integration-tests): add rav v2 test support test(integration-tests): add load-test v2 test support test(integration-tests): update local testing for v2 test(integration-tests): update test middleware for v2 fix(integration-tests): fund v1 and v2 escrow in test setup
1 parent e244a37 commit 2bb8147

File tree

19 files changed

+688
-73
lines changed

19 files changed

+688
-73
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/docker-compose.dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ services:
66
- ../target/release/indexer-service-rs:/usr/local/bin/indexer-service-rs
77
- ./indexer-service/start.sh:/usr/local/bin/start.sh
88
- ./indexer-service/config.toml:/opt/config/config.toml
9-
- ../local-network/contracts.json:/opt/contracts.json:ro
10-
- ../local-network/.env:/opt/.env:ro
9+
- ./local-network/tap-contracts.json:/opt/contracts.json:ro
10+
- ./local-network/.env:/opt/.env:ro
1111
- ../migrations:/opt/migrations:ro
1212
entrypoint: ["/usr/local/bin/start.sh"]
1313
environment:
@@ -34,7 +34,7 @@ services:
3434
- ../target/release/indexer-tap-agent:/usr/local/bin/indexer-tap-agent
3535
- ./tap-agent:/opt/config:ro
3636
- ./local-network/.env:/opt/.env:ro
37-
- ./local-network/contracts.json:/opt/contracts.json:ro
37+
- ./local-network/tap-contracts.json:/opt/contracts.json:ro
3838
- ../migrations:/opt/migrations:ro
3939
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
4040
environment:

contrib/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
container_name: indexer-service
77
volumes:
88
- ./indexer-service:/opt/config:ro # From contrib dir to indexer-service dir
9-
- ./local-network/contracts.json:/opt/contracts.json:ro
9+
- ./local-network/tap-contracts.json:/opt/contracts.json:ro
1010
- ./local-network/.env:/opt/.env:ro
1111
- ../migrations:/opt/migrations:ro
1212
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
@@ -35,7 +35,7 @@ services:
3535
volumes:
3636
- ./tap-agent:/opt/config:ro # From contrib dir to tap-agent dir
3737
- ./local-network/.env:/opt/.env:ro
38-
- ./local-network/contracts.json:/opt/contracts.json:ro
38+
- ./local-network/tap-contracts.json:/opt/contracts.json:ro
3939
- ../migrations:/opt/migrations:ro
4040
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
4141
environment:

contrib/indexer-service/config.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ status_url = "http://graph-node:8030/graphql"
1212
[subgraphs.network]
1313
query_url = "http://graph-node:8000/subgraphs/name/graph-network"
1414
deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"
15+
syncing_interval_secs = 5
16+
recently_closed_allocation_buffer_secs = 10
1517

1618
[subgraphs.escrow]
1719
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
1820
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
21+
syncing_interval_secs = 5
22+
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
1924

2025
[blockchain]
2126
chain_id = 1337
@@ -46,4 +51,9 @@ trigger_value_divisor = 500_000
4651
"ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610"
4752

4853
[horizon]
49-
enabled = false
54+
# Enable Horizon migration support and detection
55+
# When enabled: Check if Horizon contracts are active in the network
56+
# - If Horizon contracts detected: Hybrid migration mode (new V2 receipts only, process existing V1 receipts)
57+
# - If Horizon contracts not detected: Remain in legacy mode (V1 receipts only)
58+
# When disabled: Pure legacy mode, no Horizon detection performed
59+
enabled = true

contrib/indexer-service/start.sh

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,37 @@ fi
88
cat /opt/.env
99

1010
# Extract TAPVerifier address from contracts.json
11+
stdbuf -oL echo "🔍 DEBUG: Extracting TAPVerifier address from contracts.json..."
1112
VERIFIER_ADDRESS=$(jq -r '."1337".TAPVerifier.address' /opt/contracts.json)
13+
stdbuf -oL echo "🔍 DEBUG: TAPVerifier address: $VERIFIER_ADDRESS"
1214

1315
# Override with test values taken from test-assets/src/lib.rs
1416
ALLOCATION_ID="0xfa44c72b753a66591f241c7dc04e8178c30e13af" # ALLOCATION_ID_0
1517

1618
# Get network subgraph deployment ID
17-
NETWORK_DEPLOYMENT=$(curl -s "http://graph-node:8000/subgraphs/name/graph-network" \
19+
stdbuf -oL echo "🔍 DEBUG: Fetching network subgraph deployment ID..."
20+
NETWORK_DEPLOYMENT=$(curl -s --max-time 10 "http://graph-node:8000/subgraphs/name/graph-network" \
1821
-H 'content-type: application/json' \
1922
-d '{"query": "{ _meta { deployment } }"}' | jq -r '.data._meta.deployment' 2>/dev/null)
23+
stdbuf -oL echo "🔍 DEBUG: Network deployment result: $NETWORK_DEPLOYMENT"
2024
stdbuf -oL echo "Graph-network subgraph deployment ID: $NETWORK_DEPLOYMENT"
2125

2226
# Get escrow subgraph deployment ID
23-
ESCROW_DEPLOYMENT=$(curl -s "http://graph-node:8000/subgraphs/name/semiotic/tap" \
27+
stdbuf -oL echo "🔍 DEBUG: Fetching escrow subgraph deployment ID..."
28+
ESCROW_DEPLOYMENT=$(curl -s --max-time 10 "http://graph-node:8000/subgraphs/name/semiotic/tap" \
2429
-H 'content-type: application/json' \
2530
-d '{"query": "{ _meta { deployment } }"}' | jq -r '.data._meta.deployment' 2>/dev/null)
31+
stdbuf -oL echo "🔍 DEBUG: Escrow deployment result: $ESCROW_DEPLOYMENT"
32+
33+
# Handle null deployment IDs by removing the lines entirely
34+
if [ "$NETWORK_DEPLOYMENT" = "null" ] || [ -z "$NETWORK_DEPLOYMENT" ]; then
35+
NETWORK_DEPLOYMENT=""
36+
fi
37+
38+
if [ "$ESCROW_DEPLOYMENT" = "null" ] || [ -z "$ESCROW_DEPLOYMENT" ]; then
39+
ESCROW_DEPLOYMENT=""
40+
fi
41+
2642

2743
stdbuf -oL echo "Escrow subgraph deployment ID: $ESCROW_DEPLOYMENT"
2844
stdbuf -oL echo "Using test Network subgraph deployment ID: $NETWORK_DEPLOYMENT"
@@ -35,8 +51,20 @@ stdbuf -oL echo "Using test Account0 address: $ACCOUNT0_ADDRESS"
3551
cp /opt/config/config.toml /opt/config.toml
3652

3753
# Replace the placeholders with actual values
38-
sed -i "s/NETWORK_DEPLOYMENT_PLACEHOLDER/$NETWORK_DEPLOYMENT/g" /opt/config.toml
39-
sed -i "s/ESCROW_DEPLOYMENT_PLACEHOLDER/$ESCROW_DEPLOYMENT/g" /opt/config.toml
54+
if [ -n "$NETWORK_DEPLOYMENT" ]; then
55+
sed -i "s/NETWORK_DEPLOYMENT_PLACEHOLDER/$NETWORK_DEPLOYMENT/g" /opt/config.toml
56+
else
57+
# Remove the deployment_id line entirely for network subgraph
58+
sed -i '/deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"/d' /opt/config.toml
59+
fi
60+
61+
if [ -n "$ESCROW_DEPLOYMENT" ]; then
62+
sed -i "s/ESCROW_DEPLOYMENT_PLACEHOLDER/$ESCROW_DEPLOYMENT/g" /opt/config.toml
63+
else
64+
# Remove the deployment_id line entirely for escrow subgraph
65+
sed -i '/deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"/d' /opt/config.toml
66+
fi
67+
4068
sed -i "s/VERIFIER_ADDRESS_PLACEHOLDER/$VERIFIER_ADDRESS/g" /opt/config.toml
4169
sed -i "s/INDEXER_ADDRESS_PLACEHOLDER/$RECEIVER_ADDRESS/g" /opt/config.toml
4270
sed -i "s/INDEXER_MNEMONIC_PLACEHOLDER/$INDEXER_MNEMONIC/g" /opt/config.toml

contrib/tap-agent/config.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ status_url = "http://graph-node:8030/graphql"
1212
[subgraphs.network]
1313
query_url = "http://graph-node:8000/subgraphs/name/graph-network"
1414
deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"
15+
syncing_interval_secs = 5
16+
recently_closed_allocation_buffer_secs = 10
1517

1618
[subgraphs.escrow]
1719
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
1820
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
21+
syncing_interval_secs = 5
22+
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
1924

2025
[blockchain]
2126
chain_id = 1337
@@ -46,4 +51,9 @@ trigger_value_divisor = 500_000
4651
"ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610"
4752

4853
[horizon]
49-
enabled = false
54+
# Enable Horizon migration support and detection
55+
# When enabled: Check if Horizon contracts are active in the network
56+
# - If Horizon contracts detected: Hybrid migration mode (new V2 receipts only, process existing V1 receipts)
57+
# - If Horizon contracts not detected: Remain in legacy mode (V1 receipts only)
58+
# When disabled: Pure legacy mode, no Horizon detection performed
59+
enabled = true

contrib/tap-agent/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fi
105105

106106
echo "Escrow subgraph deployment ID: $ESCROW_DEPLOYMENT"
107107

108+
108109
# Copy the config template
109110
cp /opt/config/config.toml /opt/config.toml
110111

crates/tap-agent/src/agent/sender_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,8 @@ impl Actor for SenderAccount {
888888

889889
match escrow_subgraph
890890
.query::<LatestRavs, _>(latest_ravs_v2::Variables {
891-
payer: format!("{:x?}", sender_id),
892-
data_service: format!("{:x?}", data_service),
891+
payer: format!("{sender_id:x?}"),
892+
data_service: format!("{data_service:x?}"),
893893
service_provider: format!("{:x?}", config.indexer_address),
894894
collection_ids: collection_ids.clone(),
895895
})

crates/tap-agent/src/agent/sender_accounts_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ impl AllocationId {
177177
impl Display for AllocationId {
178178
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
179179
match self {
180-
AllocationId::Legacy(allocation_id) => write!(f, "{}", allocation_id),
181-
AllocationId::Horizon(collection_id) => write!(f, "{}", collection_id),
180+
AllocationId::Legacy(allocation_id) => write!(f, "{allocation_id}"),
181+
AllocationId::Horizon(collection_id) => write!(f, "{collection_id}"),
182182
}
183183
}
184184
}

crates/tap-agent/src/tap/context/receipt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl ReceiptRead<TapReceipt> for TapAgentContext<Horizon> {
269269
let collection_id = FixedBytes::<32>::from_str(&record.collection_id).map_err(|e| {
270270
AdapterError::ReceiptRead {
271271
error: format!(
272-
"Error decoding allocation_id while retrieving receipt from database: {e}"
272+
"Error decoding collection_id while retrieving receipt from database: {e}"
273273
),
274274
}
275275
})?;

0 commit comments

Comments
 (0)