fuels_test_helpers/
node_types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use std::{
    net::{Ipv4Addr, SocketAddr},
    path::PathBuf,
    time::Duration,
};

pub use fuel_core_chain_config::{ChainConfig, StateConfig};

pub(crate) const MAX_DATABASE_CACHE_SIZE: usize = 10 * 1024 * 1024;

#[derive(Clone, Debug)]
pub enum Trigger {
    Instant,
    Never,
    Interval { block_time: Duration },
}

#[cfg(feature = "fuel-core-lib")]
impl From<Trigger> for fuel_core_poa::Trigger {
    fn from(value: Trigger) -> Self {
        match value {
            Trigger::Instant => fuel_core_poa::Trigger::Instant,
            Trigger::Never => fuel_core_poa::Trigger::Never,
            Trigger::Interval { block_time } => fuel_core_poa::Trigger::Interval { block_time },
        }
    }
}

#[derive(Clone, Debug)]
pub enum DbType {
    InMemory,
    RocksDb(Option<PathBuf>),
}

#[cfg(feature = "fuel-core-lib")]
impl From<DbType> for fuel_core::service::DbType {
    fn from(value: DbType) -> Self {
        match value {
            DbType::InMemory => fuel_core::service::DbType::InMemory,
            DbType::RocksDb(..) => fuel_core::service::DbType::RocksDb,
        }
    }
}

#[derive(Clone, Debug)]
pub struct NodeConfig {
    pub addr: SocketAddr,
    pub max_database_cache_size: Option<usize>,
    pub database_type: DbType,
    pub utxo_validation: bool,
    pub debug: bool,
    pub block_production: Trigger,
    pub vm_backtrace: bool,
    pub silent: bool,
    pub starting_gas_price: u64,
    pub graphql_request_body_bytes_limit: u64,
}

impl Default for NodeConfig {
    fn default() -> Self {
        Self {
            addr: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0),
            max_database_cache_size: Some(MAX_DATABASE_CACHE_SIZE),
            database_type: DbType::InMemory,
            utxo_validation: true,
            debug: true,
            block_production: Trigger::Instant,
            vm_backtrace: false,
            silent: true,
            starting_gas_price: 1,
            graphql_request_body_bytes_limit: u64::MAX,
        }
    }
}