@@ -10,7 +10,7 @@ import (
1010const testRPCAddr = "tcp://0.0.0.0:26657"
1111
1212func TestDefaultForMode_AllModesValid (t * testing.T ) {
13- modes := []NodeMode {ModeValidator , ModeFull , ModeSeed , ModeArchive , ModeRPC , ModeIndexer }
13+ modes := []NodeMode {ModeValidator , ModeFull , ModeSeed , ModeArchive }
1414 for _ , mode := range modes {
1515 cfg := DefaultForMode (mode )
1616 if cfg .Mode != mode {
@@ -200,7 +200,7 @@ func TestWriteReadRoundTrip(t *testing.T) {
200200}
201201
202202func TestWriteReadRoundTrip_AllModes (t * testing.T ) {
203- modes := []NodeMode {ModeValidator , ModeFull , ModeSeed , ModeArchive , ModeRPC , ModeIndexer }
203+ modes := []NodeMode {ModeValidator , ModeFull , ModeSeed , ModeArchive }
204204 for _ , mode := range modes {
205205 t .Run (string (mode ), func (t * testing.T ) {
206206 dir := t .TempDir ()
@@ -250,6 +250,146 @@ func TestApplyOverrides(t *testing.T) {
250250 }
251251}
252252
253+ func TestApplyOverrides_Bool (t * testing.T ) {
254+ cfg := Default ()
255+ if err := ApplyOverrides (cfg , map [string ]string {
256+ "network.p2p.allow_duplicate_ip" : "true" ,
257+ }); err != nil {
258+ t .Fatalf ("ApplyOverrides: %v" , err )
259+ }
260+ if ! cfg .Network .P2P .AllowDuplicateIP {
261+ t .Error ("expected AllowDuplicateIP to be true" )
262+ }
263+
264+ if err := ApplyOverrides (cfg , map [string ]string {
265+ "network.p2p.allow_duplicate_ip" : "false" ,
266+ }); err != nil {
267+ t .Fatalf ("ApplyOverrides: %v" , err )
268+ }
269+ if cfg .Network .P2P .AllowDuplicateIP {
270+ t .Error ("expected AllowDuplicateIP to be false" )
271+ }
272+ }
273+
274+ func TestApplyOverrides_Uint (t * testing.T ) {
275+ cfg := Default ()
276+ if err := ApplyOverrides (cfg , map [string ]string {
277+ "chain.halt_height" : "999999" ,
278+ }); err != nil {
279+ t .Fatalf ("ApplyOverrides: %v" , err )
280+ }
281+ if cfg .Chain .HaltHeight != 999999 {
282+ t .Errorf ("halt_height: got %d, want 999999" , cfg .Chain .HaltHeight )
283+ }
284+ }
285+
286+ func TestApplyOverrides_Float (t * testing.T ) {
287+ cfg := Default ()
288+ if err := ApplyOverrides (cfg , map [string ]string {
289+ "mempool.drop_priority_threshold" : "0.75" ,
290+ }); err != nil {
291+ t .Fatalf ("ApplyOverrides: %v" , err )
292+ }
293+ if cfg .Mempool .DropPriorityThreshold != 0.75 {
294+ t .Errorf ("drop_priority_threshold: got %f, want 0.75" , cfg .Mempool .DropPriorityThreshold )
295+ }
296+ }
297+
298+ func TestApplyOverrides_Duration (t * testing.T ) {
299+ cfg := Default ()
300+ if err := ApplyOverrides (cfg , map [string ]string {
301+ "network.rpc.timeout_broadcast_tx_commit" : "30s" ,
302+ }); err != nil {
303+ t .Fatalf ("ApplyOverrides: %v" , err )
304+ }
305+ if cfg .Network .RPC .TimeoutBroadcastTxCommit .Duration != 30 * time .Second {
306+ t .Errorf ("timeout_broadcast_tx_commit: got %v, want 30s" ,
307+ cfg .Network .RPC .TimeoutBroadcastTxCommit .Duration )
308+ }
309+ }
310+
311+ func TestApplyOverrides_Int64 (t * testing.T ) {
312+ cfg := Default ()
313+ if err := ApplyOverrides (cfg , map [string ]string {
314+ "state_sync.backfill_blocks" : "500" ,
315+ }); err != nil {
316+ t .Fatalf ("ApplyOverrides: %v" , err )
317+ }
318+ if cfg .StateSync .BackfillBlocks != 500 {
319+ t .Errorf ("backfill_blocks: got %d, want 500" , cfg .StateSync .BackfillBlocks )
320+ }
321+ }
322+
323+ func TestApplyOverrides_UnknownKey (t * testing.T ) {
324+ cfg := Default ()
325+ err := ApplyOverrides (cfg , map [string ]string {
326+ "totally.fake.key" : "value" ,
327+ })
328+ if err == nil {
329+ t .Fatal ("expected error for unknown key" )
330+ }
331+ }
332+
333+ func TestApplyOverrides_InvalidBool (t * testing.T ) {
334+ cfg := Default ()
335+ err := ApplyOverrides (cfg , map [string ]string {
336+ "network.p2p.allow_duplicate_ip" : "maybe" ,
337+ })
338+ if err == nil {
339+ t .Fatal ("expected error for invalid bool value" )
340+ }
341+ }
342+
343+ func TestApplyOverrides_InvalidInt (t * testing.T ) {
344+ cfg := Default ()
345+ err := ApplyOverrides (cfg , map [string ]string {
346+ "evm.http_port" : "not_a_number" ,
347+ })
348+ if err == nil {
349+ t .Fatal ("expected error for non-numeric int value" )
350+ }
351+ }
352+
353+ func TestApplyOverrides_InvalidDuration (t * testing.T ) {
354+ cfg := Default ()
355+ err := ApplyOverrides (cfg , map [string ]string {
356+ "network.rpc.timeout_broadcast_tx_commit" : "not_a_duration" ,
357+ })
358+ if err == nil {
359+ t .Fatal ("expected error for invalid duration value" )
360+ }
361+ }
362+
363+ func TestApplyOverrides_Uint16Overflow (t * testing.T ) {
364+ cfg := Default ()
365+ err := ApplyOverrides (cfg , map [string ]string {
366+ "network.p2p.max_connections" : "70000" ,
367+ })
368+ if err == nil {
369+ t .Fatal ("expected error for uint16 overflow (65535 max)" )
370+ }
371+ }
372+
373+ func TestApplyOverrides_Int32Overflow (t * testing.T ) {
374+ cfg := Default ()
375+ err := ApplyOverrides (cfg , map [string ]string {
376+ "state_sync.fetchers" : "3000000000" ,
377+ })
378+ if err == nil {
379+ t .Fatal ("expected error for int32 overflow" )
380+ }
381+ }
382+
383+ func TestApplyOverrides_NegativeUint (t * testing.T ) {
384+ cfg := Default ()
385+ err := ApplyOverrides (cfg , map [string ]string {
386+ "chain.halt_height" : "-1" ,
387+ })
388+ if err == nil {
389+ t .Fatal ("expected error for negative uint value" )
390+ }
391+ }
392+
253393func TestApplyOverrides_Empty (t * testing.T ) {
254394 cfg := Default ()
255395 original := cfg .EVM .HTTPPort
@@ -339,8 +479,8 @@ func TestNodeMode_Validity(t *testing.T) {
339479 {ModeFull , true },
340480 {ModeSeed , true },
341481 {ModeArchive , true },
342- {ModeRPC , true },
343- {ModeIndexer , true },
482+ {"rpc" , false },
483+ {"indexer" , false },
344484 {"bogus" , false },
345485 {"" , false },
346486 }
@@ -352,7 +492,7 @@ func TestNodeMode_Validity(t *testing.T) {
352492}
353493
354494func TestNodeMode_IsFullnodeType (t * testing.T ) {
355- fullnodeTypes := []NodeMode {ModeFull , ModeArchive , ModeRPC , ModeIndexer }
495+ fullnodeTypes := []NodeMode {ModeFull , ModeArchive }
356496 for _ , m := range fullnodeTypes {
357497 if ! m .IsFullnodeType () {
358498 t .Errorf ("%s should be fullnode type" , m )
0 commit comments