fuel_core_e2e_client/
config.rs1use crate::SYNC_TIMEOUT;
2use fuel_core_types::{
3 fuel_tx::ContractId,
4 fuel_vm::SecretKey,
5};
6use serde::{
7 Deserialize,
8 Serialize,
9};
10use std::{
11 str::FromStr,
12 time::Duration,
13};
14
15#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
16pub struct SuiteConfig {
17 pub endpoint: String,
19 #[serde(with = "humantime_serde")]
22 pub wallet_sync_timeout: Duration,
23 pub full_test: bool,
25 pub coinbase_contract_id: ContractId,
27 pub wallet_a: ClientConfig,
29 pub wallet_b: ClientConfig,
30}
31
32impl SuiteConfig {
33 pub fn sync_timeout(&self) -> Duration {
34 self.wallet_sync_timeout
35 }
36}
37
38impl Default for SuiteConfig {
39 fn default() -> Self {
40 Self {
41 endpoint: "http://localhost:4000".to_string(),
42 wallet_sync_timeout: SYNC_TIMEOUT,
43 full_test: false,
44 coinbase_contract_id: ContractId::from_str(
45 "0x7777777777777777777777777777777777777777777777777777777777777777",
46 )
47 .unwrap(),
48 wallet_a: ClientConfig {
49 endpoint: None,
50 secret:
51 "0xde97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c"
52 .parse()
53 .unwrap(),
54 },
55 wallet_b: ClientConfig {
56 endpoint: None,
57 secret:
58 "0x37fa81c84ccd547c30c176b118d5cb892bdb113e8e80141f266519422ef9eefd"
59 .parse()
60 .unwrap(),
61 },
62 }
63 }
64}
65
66#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
67pub struct ClientConfig {
68 pub endpoint: Option<String>,
70 pub secret: SecretKey,
72}
73
74#[cfg(test)]
75mod tests {
76 use super::*;
77
78 #[test]
79 fn default_config_snapshot() {
80 let config = SuiteConfig::default();
81 let serialized = toml::to_string(&config).unwrap();
82 insta::assert_snapshot!(serialized);
83 }
84
85 #[test]
86 fn can_roundtrip_config() {
87 let config = SuiteConfig::default();
88 let serialized = toml::to_string(&config).unwrap();
89 let deserialized: SuiteConfig = toml::from_str(&serialized).unwrap();
90 assert_eq!(config, deserialized);
91 }
92}