2022-12-02 01:18:23 +00:00
|
|
|
use config::networks;
|
|
|
|
use ethers::types::H256;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_checkpoint_fallback() {
|
|
|
|
let cf = config::checkpoints::CheckpointFallback::new();
|
|
|
|
|
|
|
|
assert_eq!(cf.services.get(&networks::Network::MAINNET), None);
|
|
|
|
assert_eq!(cf.services.get(&networks::Network::GOERLI), None);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
cf.networks,
|
|
|
|
[networks::Network::MAINNET, networks::Network::GOERLI].to_vec()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_construct_checkpoints() {
|
|
|
|
let cf = config::checkpoints::CheckpointFallback::new()
|
|
|
|
.build()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(cf.services[&networks::Network::MAINNET].len() > 1);
|
|
|
|
assert!(cf.services[&networks::Network::GOERLI].len() > 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_fetch_latest_checkpoints() {
|
|
|
|
let cf = config::checkpoints::CheckpointFallback::new()
|
|
|
|
.build()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let checkpoint = cf
|
|
|
|
.fetch_latest_checkpoint(&networks::Network::GOERLI)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert!(checkpoint != H256::zero());
|
|
|
|
let checkpoint = cf
|
|
|
|
.fetch_latest_checkpoint(&networks::Network::MAINNET)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert!(checkpoint != H256::zero());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_get_all_fallback_endpoints() {
|
|
|
|
let cf = config::checkpoints::CheckpointFallback::new()
|
|
|
|
.build()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let urls = cf.get_all_fallback_endpoints(&networks::Network::MAINNET);
|
2022-12-03 15:58:58 +00:00
|
|
|
assert!(!urls.is_empty());
|
2022-12-02 01:18:23 +00:00
|
|
|
let urls = cf.get_all_fallback_endpoints(&networks::Network::GOERLI);
|
2022-12-03 15:58:58 +00:00
|
|
|
assert!(!urls.is_empty());
|
2022-12-02 01:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_get_healthy_fallback_endpoints() {
|
|
|
|
let cf = config::checkpoints::CheckpointFallback::new()
|
|
|
|
.build()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let urls = cf.get_healthy_fallback_endpoints(&networks::Network::MAINNET);
|
2022-12-03 15:58:58 +00:00
|
|
|
assert!(!urls.is_empty());
|
2022-12-02 01:18:23 +00:00
|
|
|
let urls = cf.get_healthy_fallback_endpoints(&networks::Network::GOERLI);
|
2022-12-03 15:58:58 +00:00
|
|
|
assert!(!urls.is_empty());
|
2022-12-02 01:18:23 +00:00
|
|
|
}
|