Skip to content

Commit 87dab30

Browse files
committed
test: update all tests to use get_grpc_url
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 26ac63b commit 87dab30

File tree

4 files changed

+13
-47
lines changed

4 files changed

+13
-47
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ mod tests {
609609
use reqwest::Url;
610610
use ruint::aliases::U256;
611611
use sqlx::{postgres::PgListener, PgPool};
612-
use test_assets::{flush_messages, TAP_SENDER as SENDER};
612+
use test_assets::{flush_messages, TAP_SENDER as SENDER, TAP_SIGNER as SIGNER};
613613
use thegraph_core::alloy::hex::ToHexExt;
614614
use tokio::sync::{mpsc, mpsc::error::TryRecvError, watch, Notify};
615615

@@ -625,8 +625,7 @@ mod tests {
625625
test::{
626626
actors::{DummyActor, MockSenderAccount, MockSenderAllocation, TestableActor},
627627
create_rav, create_received_receipt, get_grpc_url, store_rav, store_receipt,
628-
ALLOCATION_ID_0, ALLOCATION_ID_1, INDEXER, SENDER_2, SIGNER,
629-
TAP_EIP712_DOMAIN_SEPARATOR,
628+
ALLOCATION_ID_0, ALLOCATION_ID_1, INDEXER, SENDER_2, TAP_EIP712_DOMAIN_SEPARATOR,
630629
},
631630
};
632631

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

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,6 @@ pub mod tests {
871871
use serde_json::json;
872872
use sqlx::PgPool;
873873
use tap_aggregator::grpc::{tap_aggregator_client::TapAggregatorClient, RavResponse};
874-
use tap_aggregator::server::run_server;
875874
use tap_core::receipt::{
876875
checks::{Check, CheckError, CheckList, CheckResult},
877876
state::Checking,
@@ -948,9 +947,7 @@ pub mod tests {
948947
None => create_mock_sender_account().await.1,
949948
};
950949

951-
let endpoint = Endpoint::new(sender_aggregator_endpoint.to_string())
952-
.unwrap()
953-
.connect_timeout(Duration::default());
950+
let endpoint = Endpoint::new(sender_aggregator_endpoint.to_string()).unwrap();
954951

955952
let sender_aggregator = TapAggregatorClient::connect(endpoint.clone())
956953
.await
@@ -1162,19 +1159,6 @@ pub mod tests {
11621159

11631160
#[sqlx::test(migrations = "../../migrations")]
11641161
async fn test_trigger_rav_request(pgpool: PgPool) {
1165-
// Start a TAP aggregator server.
1166-
let (_handle, aggregator_endpoint) = run_server(
1167-
0,
1168-
SIGNER.0.clone(),
1169-
vec![SIGNER.1].into_iter().collect(),
1170-
TAP_EIP712_DOMAIN_SEPARATOR.clone(),
1171-
100 * 1024,
1172-
100 * 1024,
1173-
1,
1174-
)
1175-
.await
1176-
.unwrap();
1177-
11781162
// Start a mock graphql server using wiremock
11791163
let mock_server = MockServer::start().await;
11801164

@@ -1208,7 +1192,7 @@ pub mod tests {
12081192
// Create a sender_allocation.
12091193
let (sender_allocation, notify) = create_sender_allocation(
12101194
pgpool.clone(),
1211-
"http://".to_owned() + &aggregator_endpoint.to_string(),
1195+
get_grpc_url().await,
12121196
&mock_server.uri(),
12131197
Some(sender_account),
12141198
)
@@ -1614,19 +1598,6 @@ pub mod tests {
16141598

16151599
#[sqlx::test(migrations = "../../migrations")]
16161600
async fn test_rav_request_when_all_receipts_invalid(pgpool: PgPool) {
1617-
// Start a TAP aggregator server.
1618-
let (_handle, aggregator_endpoint) = run_server(
1619-
0,
1620-
SIGNER.0.clone(),
1621-
vec![SIGNER.1].into_iter().collect(),
1622-
TAP_EIP712_DOMAIN_SEPARATOR.clone(),
1623-
100 * 1024,
1624-
100 * 1024,
1625-
1,
1626-
)
1627-
.await
1628-
.unwrap();
1629-
16301601
// Start a mock graphql server using wiremock
16311602
let mock_server = MockServer::start().await;
16321603

@@ -1665,7 +1636,7 @@ pub mod tests {
16651636

16661637
let (sender_allocation, notify) = create_sender_allocation(
16671638
pgpool.clone(),
1668-
"http://".to_owned() + &aggregator_endpoint.to_string(),
1639+
get_grpc_url().await,
16691640
&mock_server.uri(),
16701641
Some(sender_account),
16711642
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ impl RAVStore for TapAgentContext {
135135
mod test {
136136
use indexer_monitor::EscrowAccounts;
137137
use sqlx::PgPool;
138-
use test_assets::TAP_SENDER as SENDER;
138+
use test_assets::{TAP_SENDER as SENDER, TAP_SIGNER as SIGNER};
139139
use tokio::sync::watch;
140140

141141
use super::*;
142-
use crate::test::{create_rav, ALLOCATION_ID_0, SIGNER};
142+
use crate::test::{create_rav, ALLOCATION_ID_0};
143143

144144
#[derive(Debug)]
145145
struct TestableRav(SignedRAV);

crates/tap-agent/src/test.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,27 @@ use bigdecimal::num_bigint::BigInt;
55
use lazy_static::lazy_static;
66
use sqlx::{types::BigDecimal, PgPool};
77
use std::net::SocketAddr;
8-
use std::u32;
9-
use std::{collections::HashSet, time::Duration};
108
use tap_aggregator::server::run_server;
119
use tap_core::{
1210
rav::{ReceiptAggregateVoucher, SignedRAV},
1311
receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt},
1412
signed_message::EIP712SignedMessage,
1513
tap_eip712_domain,
1614
};
15+
use test_assets::TAP_SIGNER as SIGNER;
1716
use thegraph_core::alloy::{
1817
primitives::{address, hex::ToHexExt, Address},
1918
signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
2019
sol_types::Eip712Domain,
2120
};
22-
use tokio::{sync::OnceCell, task::JoinHandle};
21+
use tokio::task::JoinHandle;
2322

2423
pub const ALLOCATION_ID_0: Address = address!("abababababababababababababababababababab");
2524
pub const ALLOCATION_ID_1: Address = address!("bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc");
2625

2726
lazy_static! {
2827
// pub static ref SENDER: (PrivateKeySigner, Address) = wallet(0);
2928
pub static ref SENDER_2: (PrivateKeySigner, Address) = wallet(1);
30-
pub static ref SIGNER: (PrivateKeySigner, Address) = wallet(2);
3129
pub static ref INDEXER: (PrivateKeySigner, Address) = wallet(3);
3230
pub static ref TAP_EIP712_DOMAIN_SEPARATOR: Eip712Domain =
3331
tap_eip712_domain(1, Address::from([0x11u8; 20]),);
@@ -160,14 +158,12 @@ pub async fn get_grpc_url() -> String {
160158

161159
/// Function to start a aggregator server for testing
162160
async fn create_grpc_aggregator() -> (JoinHandle<()>, SocketAddr) {
163-
let wallet = PrivateKeySigner::random();
164-
let address = wallet.address();
165-
let accepted_addresses = HashSet::from([address]);
166-
let domain_separator = tap_eip712_domain(1, Address::from([0x11u8; 20]));
161+
let wallet = SIGNER.0.clone();
162+
let accepted_addresses = vec![SIGNER.1].into_iter().collect();
163+
let domain_separator = TAP_EIP712_DOMAIN_SEPARATOR.clone();
167164
let max_request_body_size = 1024 * 1024; // 1 MB
168165
let max_response_body_size = 1024 * 1024; // 1 MB
169-
let max_concurrent_connections = 10;
170-
// Use port `1234` as it is the default being used in tests
166+
let max_concurrent_connections = 255;
171167
let port = 0;
172168

173169
run_server(

0 commit comments

Comments
 (0)