@@ -36,3 +36,91 @@ func TestApplyDefaults_MergesStatusThresholds(t *testing.T) {
3636 require .Equal (t , uint64 (30 ), chain .Status .HealthyMaxPendingBlocks )
3737 require .Equal (t , uint64 (120 ), chain .Status .SlowMaxPendingBlocks )
3838}
39+
40+ func TestApplyDefaults_AppliesEnabledDefaultWhenOmitted (t * testing.T ) {
41+ t .Parallel ()
42+
43+ enabled := false
44+ chains := Chains {
45+ "ethereum_mainnet" : {
46+ Type : enum .NetworkTypeEVM ,
47+ PollInterval : time .Second ,
48+ Nodes : []NodeConfig {{URL : "https://example.com" }},
49+ },
50+ }
51+
52+ err := chains .ApplyDefaults (Defaults {
53+ Enabled : & enabled ,
54+ PollInterval : time .Second ,
55+ ReorgRollbackWindow : 20 ,
56+ })
57+ require .NoError (t , err )
58+
59+ require .NotNil (t , chains ["ethereum_mainnet" ].Enabled )
60+ require .False (t , * chains ["ethereum_mainnet" ].Enabled )
61+ }
62+
63+ func TestApplyDefaults_PreservesExplicitEnabledValue (t * testing.T ) {
64+ t .Parallel ()
65+
66+ defaultEnabled := false
67+ chainEnabled := true
68+ chains := Chains {
69+ "ethereum_mainnet" : {
70+ Enabled : & chainEnabled ,
71+ Type : enum .NetworkTypeEVM ,
72+ PollInterval : time .Second ,
73+ Nodes : []NodeConfig {{URL : "https://example.com" }},
74+ },
75+ }
76+
77+ err := chains .ApplyDefaults (Defaults {
78+ Enabled : & defaultEnabled ,
79+ PollInterval : time .Second ,
80+ ReorgRollbackWindow : 20 ,
81+ })
82+ require .NoError (t , err )
83+
84+ require .NotNil (t , chains ["ethereum_mainnet" ].Enabled )
85+ require .True (t , * chains ["ethereum_mainnet" ].Enabled )
86+ }
87+
88+ func TestEnabledNames_DefaultsToEnabledWhenOmitted (t * testing.T ) {
89+ t .Parallel ()
90+
91+ disabled := false
92+ chains := Chains {
93+ "ethereum_mainnet" : {
94+ Type : enum .NetworkTypeEVM ,
95+ Nodes : []NodeConfig {{URL : "https://example.com" }},
96+ },
97+ "tron_mainnet" : {
98+ Enabled : & disabled ,
99+ Type : enum .NetworkTypeTron ,
100+ Nodes : []NodeConfig {{URL : "https://example.com" }},
101+ },
102+ }
103+
104+ require .ElementsMatch (t , []string {"ethereum_mainnet" }, chains .EnabledNames ())
105+ }
106+
107+ func TestEnabledNames_IncludesExplicitlyEnabledChains (t * testing.T ) {
108+ t .Parallel ()
109+
110+ enabled := true
111+ disabled := false
112+ chains := Chains {
113+ "ethereum_mainnet" : {
114+ Enabled : & enabled ,
115+ Type : enum .NetworkTypeEVM ,
116+ Nodes : []NodeConfig {{URL : "https://example.com" }},
117+ },
118+ "tron_mainnet" : {
119+ Enabled : & disabled ,
120+ Type : enum .NetworkTypeTron ,
121+ Nodes : []NodeConfig {{URL : "https://example.com" }},
122+ },
123+ }
124+
125+ require .ElementsMatch (t , []string {"ethereum_mainnet" }, chains .EnabledNames ())
126+ }
0 commit comments