Skip to content

Commit de47407

Browse files
committed
test(rav): use signed receipts in requests
1 parent 6922218 commit de47407

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

integration-tests/src/rav_tests.rs

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub async fn test_tap_rav_v1() -> Result<()> {
3030
// Setup HTTP client
3131
let http_client = Arc::new(Client::new());
3232

33+
// Create wallet for signing receipts
34+
let wallet: PrivateKeySigner = ACCOUNT0_SECRET.parse().unwrap();
35+
3336
// Query the network subgraph to find active allocations
3437
let allocation_id = find_allocation(http_client.clone(), GRAPH_URL).await?;
3538

@@ -64,16 +67,27 @@ pub async fn test_tap_rav_v1() -> Result<()> {
6467
);
6568

6669
for i in 0..NUM_RECEIPTS {
67-
let response = http_client
68-
.post(format!("{}/api/subgraphs/id/{}", GATEWAY_URL, SUBGRAPH_ID))
69-
.header("Content-Type", "application/json")
70-
.header("Authorization", format!("Bearer {}", GATEWAY_API_KEY))
71-
.json(&json!({
70+
// Create TAP receipt for this query
71+
let receipt = create_tap_receipt(
72+
MAX_RECEIPT_VALUE,
73+
&allocation_id,
74+
TAP_VERIFIER_CONTRACT,
75+
CHAIN_ID,
76+
&wallet,
77+
)?;
78+
79+
let receipt_json = serde_json::to_string(&receipt).unwrap();
80+
let response = create_request(
81+
&http_client,
82+
format!("{}/api/subgraphs/id/{}", GATEWAY_URL, SUBGRAPH_ID).as_str(),
83+
&receipt_json,
84+
&json!({
7285
"query": "{ _meta { block { number } } }"
73-
}))
74-
.timeout(Duration::from_secs(10))
75-
.send()
76-
.await?;
86+
}),
87+
)
88+
.header("Authorization", format!("Bearer {}", GATEWAY_API_KEY))
89+
.send()
90+
.await?;
7791

7892
if response.status().is_success() {
7993
total_successful += 1;
@@ -111,16 +125,27 @@ pub async fn test_tap_rav_v1() -> Result<()> {
111125
for i in 0..MAX_TRIGGERS {
112126
println!("Sending trigger query {}/{}...", i + 1, MAX_TRIGGERS);
113127

114-
let response = http_client
115-
.post(format!("{}/api/subgraphs/id/{}", GATEWAY_URL, SUBGRAPH_ID))
116-
.header("Content-Type", "application/json")
117-
.header("Authorization", format!("Bearer {}", GATEWAY_API_KEY))
118-
.json(&json!({
128+
// Create TAP receipt for this trigger query
129+
let receipt = create_tap_receipt(
130+
MAX_RECEIPT_VALUE,
131+
&allocation_id,
132+
TAP_VERIFIER_CONTRACT,
133+
CHAIN_ID,
134+
&wallet,
135+
)?;
136+
137+
let receipt_json = serde_json::to_string(&receipt).unwrap();
138+
let response = create_request(
139+
&http_client,
140+
format!("{}/api/subgraphs/id/{}", GATEWAY_URL, SUBGRAPH_ID).as_str(),
141+
&receipt_json,
142+
&json!({
119143
"query": "{ _meta { block { number } } }"
120-
}))
121-
.timeout(Duration::from_secs(10))
122-
.send()
123-
.await?;
144+
}),
145+
)
146+
.header("Authorization", format!("Bearer {}", GATEWAY_API_KEY))
147+
.send()
148+
.await?;
124149

125150
if response.status().is_success() {
126151
total_successful += 1;

0 commit comments

Comments
 (0)