fuel_core_e2e_client/
config.rsuse crate::SYNC_TIMEOUT;
use fuel_core_types::{
fuel_tx::ContractId,
fuel_vm::SecretKey,
};
use serde::{
Deserialize,
Serialize,
};
use std::{
str::FromStr,
time::Duration,
};
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct SuiteConfig {
pub endpoint: String,
#[serde(with = "humantime_serde")]
pub wallet_sync_timeout: Duration,
pub full_test: bool,
pub coinbase_contract_id: ContractId,
pub wallet_a: ClientConfig,
pub wallet_b: ClientConfig,
}
impl SuiteConfig {
pub fn sync_timeout(&self) -> Duration {
self.wallet_sync_timeout
}
}
impl Default for SuiteConfig {
fn default() -> Self {
Self {
endpoint: "http://localhost:4000".to_string(),
wallet_sync_timeout: SYNC_TIMEOUT,
full_test: false,
coinbase_contract_id: ContractId::from_str(
"0x7777777777777777777777777777777777777777777777777777777777777777",
)
.unwrap(),
wallet_a: ClientConfig {
endpoint: None,
secret:
"0xde97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c"
.parse()
.unwrap(),
},
wallet_b: ClientConfig {
endpoint: None,
secret:
"0x37fa81c84ccd547c30c176b118d5cb892bdb113e8e80141f266519422ef9eefd"
.parse()
.unwrap(),
},
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct ClientConfig {
pub endpoint: Option<String>,
pub secret: SecretKey,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_config_snapshot() {
let config = SuiteConfig::default();
let serialized = toml::to_string(&config).unwrap();
insta::assert_snapshot!(serialized);
}
#[test]
fn can_roundtrip_config() {
let config = SuiteConfig::default();
let serialized = toml::to_string(&config).unwrap();
let deserialized: SuiteConfig = toml::from_str(&serialized).unwrap();
assert_eq!(config, deserialized);
}
}