@@ -44,10 +44,6 @@ func setupManagerForNamespaceTest(t *testing.T, daConfig config.DAConfig) (*Mana
4444 mockStore .On ("SetMetadata" , mock .Anything , mock .Anything , mock .Anything ).Return (nil ).Maybe ()
4545 mockStore .On ("GetMetadata" , mock .Anything , storepkg .DAIncludedHeightKey ).Return ([]byte {}, ds .ErrNotFound ).Maybe ()
4646
47- // Mock the persistence file operations
48- mockStore .On ("GetMetadata" , mock .Anything , namespaceMigrationKey ).Return ([]byte {}, ds .ErrNotFound ).Maybe ()
49- mockStore .On ("SetMetadata" , mock .Anything , namespaceMigrationKey , mock .Anything ).Return (nil ).Maybe ()
50-
5147 _ , cancel := context .WithCancel (context .Background ())
5248
5349 // Create a mock signer
@@ -86,11 +82,6 @@ func setupManagerForNamespaceTest(t *testing.T, daConfig config.DAConfig) (*Mana
8682 manager .daHeight .Store (100 )
8783 manager .daIncludedHeight .Store (0 )
8884
89- // Initialize the namespace migration state from store
90- if migrationData , err := mockStore .GetMetadata (context .Background (), namespaceMigrationKey ); err == nil && len (migrationData ) > 0 {
91- manager .namespaceMigrationCompleted .Store (migrationData [0 ] == 1 )
92- }
93-
9485 t .Cleanup (cancel )
9586
9687 return manager , mockDAClient , mockStore , cancel
@@ -115,17 +106,17 @@ func TestProcessNextDAHeaderAndData_MixedResults(t *testing.T) {
115106 headerMessage : "" ,
116107 dataError : true ,
117108 dataMessage : "data retrieval failed" ,
118- expectError : true ,
119- errorContains : "data retrieval failed " ,
109+ expectError : false ,
110+ errorContains : "" ,
120111 },
121112 {
122113 name : "header fails, data succeeds" ,
123114 headerError : true ,
124115 headerMessage : "header retrieval failed" ,
125116 dataError : false ,
126117 dataMessage : "" ,
127- expectError : true ,
128- errorContains : "header retrieval failed " ,
118+ expectError : false ,
119+ errorContains : "" ,
129120 },
130121 {
131122 name : "header from future, data succeeds" ,
@@ -252,7 +243,7 @@ func TestNamespaceMigration_Completion(t *testing.T) {
252243 HeaderNamespace : "test-headers" ,
253244 DataNamespace : "test-data" ,
254245 }
255- manager , mockDA , mockStore , cancel := setupManagerForNamespaceTest (t , daConfig )
246+ manager , mockDA , _ , cancel := setupManagerForNamespaceTest (t , daConfig )
256247 defer cancel ()
257248
258249 // Set initial migration state
@@ -324,9 +315,6 @@ func TestNamespaceMigration_Completion(t *testing.T) {
324315 }
325316
326317 // If migration should complete, expect persistence call
327- if tt .expectMigrationComplete && ! tt .initialMigrationState {
328- mockStore .On ("SetMetadata" , mock .Anything , namespaceMigrationKey , []byte {1 }).Return (nil ).Once ()
329- }
330318
331319 ctx := context .Background ()
332320 err := manager .processNextDAHeaderAndData (ctx )
@@ -342,7 +330,6 @@ func TestNamespaceMigration_Completion(t *testing.T) {
342330 // The main goal is to test that the migration completion logic works
343331
344332 mockDA .AssertExpectations (t )
345- mockStore .AssertExpectations (t )
346333 })
347334 }
348335}
@@ -417,8 +404,8 @@ func TestLegacyNamespaceDetection(t *testing.T) {
417404 legacyNamespace : "old-namespace" ,
418405 headerNamespace : "" ,
419406 dataNamespace : "" ,
420- expectLegacyFallback : false , // Should use defaults
421- description : "When only legacy namespace is set, should use default new namespaces " ,
407+ expectLegacyFallback : true ,
408+ description : "When only legacy namespace is set, it acts as both header and data namespace " ,
422409 },
423410 {
424411 name : "all namespaces configured" ,
@@ -476,7 +463,13 @@ func TestLegacyNamespaceDetection(t *testing.T) {
476463 // Start with migration not completed
477464 manager .namespaceMigrationCompleted .Store (false )
478465
479- if tt .expectLegacyFallback && tt .legacyNamespace != "" {
466+ // Check if we should expect a legacy namespace check
467+ // This happens when legacy namespace is different from header/data namespaces
468+ expectLegacyCheck := tt .legacyNamespace != "" &&
469+ tt .legacyNamespace != headerNS &&
470+ tt .legacyNamespace != dataNS
471+
472+ if expectLegacyCheck {
480473 // Should try legacy namespace first
481474 mockDA .On ("GetIDs" , mock .Anything , uint64 (100 ), []byte (tt .legacyNamespace )).Return (& coreda.GetIDsResult {
482475 IDs : []coreda.ID {},
@@ -488,9 +481,11 @@ func TestLegacyNamespaceDetection(t *testing.T) {
488481 IDs : []coreda.ID {},
489482 }, coreda .ErrBlobNotFound ).Once ()
490483
491- mockDA .On ("GetIDs" , mock .Anything , uint64 (100 ), []byte (dataNS )).Return (& coreda.GetIDsResult {
492- IDs : []coreda.ID {},
493- }, coreda .ErrBlobNotFound ).Once ()
484+ if dataNS != headerNS {
485+ mockDA .On ("GetIDs" , mock .Anything , uint64 (100 ), []byte (dataNS )).Return (& coreda.GetIDsResult {
486+ IDs : []coreda.ID {},
487+ }, coreda .ErrBlobNotFound ).Once ()
488+ }
494489
495490 ctx := context .Background ()
496491 err := manager .processNextDAHeaderAndData (ctx )
0 commit comments