@@ -331,22 +331,24 @@ void TestPayloadOffset(ui64 firstSector, ui64 lastSector, ui64 currentSector, ui
331
331
TSectorsWithData sectors (format.SectorSize , LogErasureDataParts + 1 );
332
332
constexpr ui64 magic = 0x123951924 ;
333
333
ui64 nonce = 1 ;
334
- for (ui32 i = 0 ; i < LogErasureDataParts + 1 ; ++i) {
335
- memset (sectors[i].Begin (), 0 , sectors[i].Size ());
336
- sectors[i].SetCanary ();
337
- auto *footer = sectors[i].GetDataFooter ();
338
- footer->Version = PDISK_DATA_VERSION;
339
- footer->Nonce = nonce++;
340
- NPDisk::TPDiskHashCalculator hasher;
341
- if (i < LogErasureDataParts) {
342
- ui64 offset = format.SectorSize * i;
343
- footer->Hash = hasher.HashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
334
+ for (ui32 useT1haHash = 0 ; useT1haHash < 2 ; ++useT1haHash) {
335
+ for (ui32 i = 0 ; i < LogErasureDataParts + 1 ; ++i) {
336
+ memset (sectors[i].Begin (), 0 , sectors[i].Size ());
337
+ sectors[i].SetCanary ();
338
+ auto *footer = sectors[i].GetDataFooter ();
339
+ footer->Version = PDISK_DATA_VERSION;
340
+ footer->Nonce = nonce++;
341
+ NPDisk::TPDiskHashCalculator hasher (useT1haHash);
342
+ if (i < LogErasureDataParts) {
343
+ ui64 offset = format.SectorSize * i;
344
+ footer->Hash = hasher.HashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
345
+ }
344
346
}
347
+ TSectorRestorator restorator (false , LogErasureDataParts, true , format);
348
+ restorator.Restore (sectors.Data (), 0 , magic, 0 , 0 );
349
+ UNIT_ASSERT_C (restorator.GoodSectorCount == LogErasureDataParts + 1 ,
350
+ " restorator.GoodSectorCount# " << restorator.GoodSectorCount );
345
351
}
346
- TSectorRestorator restorator (false , LogErasureDataParts, true , format);
347
- restorator.Restore (sectors.Data (), 0 , magic, 0 , 0 );
348
- UNIT_ASSERT_C (restorator.GoodSectorCount == LogErasureDataParts + 1 ,
349
- " restorator.GoodSectorCount# " << restorator.GoodSectorCount );
350
352
}
351
353
352
354
Y_UNIT_TEST (SectorRestoratorOldNewHash) {
@@ -356,30 +358,32 @@ void TestPayloadOffset(ui64 firstSector, ui64 lastSector, ui64 currentSector, ui
356
358
const ui64 magic = 0x123951924 ;
357
359
const ui64 offset = format.SectorSize * 17 ;
358
360
ui64 nonce = 1 ;
359
- for (ui32 i = 0 ; i < sectors.Size (); ++i) {
360
- memset (sectors[i].Begin (), 13 , sectors[i].Size ());
361
- sectors[i].SetCanary ();
362
- auto *footer = sectors[i].GetDataFooter ();
363
- footer->Version = PDISK_DATA_VERSION;
364
- footer->Nonce = nonce++;
365
- NPDisk::TPDiskHashCalculator hasher;
366
- switch (i) {
367
- case 0 :
368
- footer->Hash = hasher.OldHashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
369
- break ;
370
- case 1 :
371
- footer->Hash = hasher.T1ha0HashSector <TT1ha0NoAvxHasher>(offset, magic, sectors[i].Begin (), sectors[i].Size ());
372
- break ;
373
- case 2 :
374
- footer->Hash = hasher.HashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
375
- break ;
376
- default :
377
- UNIT_ASSERT (false );
361
+ for (ui32 useT1haHash = 0 ; useT1haHash < 2 ; ++useT1haHash) {
362
+ for (ui32 i = 0 ; i < sectors.Size (); ++i) {
363
+ memset (sectors[i].Begin (), 13 , sectors[i].Size ());
364
+ sectors[i].SetCanary ();
365
+ auto *footer = sectors[i].GetDataFooter ();
366
+ footer->Version = PDISK_DATA_VERSION;
367
+ footer->Nonce = nonce++;
368
+ NPDisk::TPDiskHashCalculator hasher (useT1haHash);
369
+ switch (i) {
370
+ case 0 :
371
+ footer->Hash = hasher.OldHashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
372
+ break ;
373
+ case 1 :
374
+ footer->Hash = hasher.T1ha0HashSector <TT1ha0NoAvxHasher>(offset, magic, sectors[i].Begin (), sectors[i].Size ());
375
+ break ;
376
+ case 2 :
377
+ footer->Hash = hasher.HashSector (offset, magic, sectors[i].Begin (), sectors[i].Size ());
378
+ break ;
379
+ default :
380
+ UNIT_ASSERT (false );
381
+ }
382
+ TSectorRestorator restorator (false , 1 , false , format);
383
+ restorator.Restore (sectors[i].Begin (), offset, magic, 0 , 0 );
384
+ UNIT_ASSERT_C (restorator.GoodSectorCount == 1 , " i# " << i
385
+ << " GoodSectorCount# " << restorator.GoodSectorCount );
378
386
}
379
- TSectorRestorator restorator (false , 1 , false , format);
380
- restorator.Restore (sectors[i].Begin (), offset, magic, 0 , 0 );
381
- UNIT_ASSERT_C (restorator.GoodSectorCount == 1 , " i# " << i
382
- << " GoodSectorCount# " << restorator.GoodSectorCount );
383
387
}
384
388
}
385
389
0 commit comments