MCPcopy Create free account
hub / github.com/amule-project/amule / DbgTest

Method DbgTest

src/SHAHashSet.cpp:1080–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1078#define VERIFY(x) wxASSERT(x)
1079
1080void CAICHHashSet::DbgTest()
1081{
1082#ifdef _DEBUG
1083 //define TESTSIZE 4294567295
1084 uint8 maxLevel = 0;
1085 uint32 cHash = 1;
1086 uint8 curLevel = 0;
1087 //uint32 cParts = 0;
1088 maxLevel = 0;
1089/* CAICHHashTree* pTest = new CAICHHashTree(TESTSIZE, true, 9728000);
1090 for (uint64 i = 0; i+9728000 < TESTSIZE; i += 9728000) {
1091 CAICHHashTree* pTest2 = new CAICHHashTree(9728000, true, EMBLOCKSIZE);
1092 pTest->ReplaceHashTree(i, 9728000, &pTest2);
1093 cParts++;
1094 }
1095 CAICHHashTree* pTest2 = new CAICHHashTree(TESTSIZE-i, true, EMBLOCKSIZE);
1096 pTest->ReplaceHashTree(i, (TESTSIZE-i), &pTest2);
1097 cParts++;
1098*/
1099#define TESTSIZE m_pHashTree.m_nDataSize
1100 if (m_pHashTree.m_nDataSize <= EMBLOCKSIZE) {
1101 return;
1102 }
1103 CAICHHashSet TestHashSet(m_pOwner);
1104 TestHashSet.SetFileSize(m_pOwner->GetFileSize());
1105 TestHashSet.SetMasterHash(GetMasterHash(), AICH_VERIFIED);
1106 CMemFile file;
1107 uint64 i;
1108 for (i = 0; i+9728000 < TESTSIZE; i += 9728000) {
1109 VERIFY( CreatePartRecoveryData(i, &file) );
1110
1111 /*uint32 nRandomCorruption = (rand() * rand()) % (file.GetLength()-4);
1112 file.Seek(nRandomCorruption, CFile::begin);
1113 file.Write(&nRandomCorruption, 4);*/
1114
1115 file.Seek(0,wxFromStart);
1116 VERIFY( TestHashSet.ReadRecoveryData(i, &file) );
1117 file.Seek(0,wxFromStart);
1118 TestHashSet.FreeHashSet();
1119 uint32 j;
1120 for (j = 0; j+EMBLOCKSIZE < 9728000; j += EMBLOCKSIZE) {
1121 VERIFY( m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel) );
1122 //TRACE("%u - %s\r\n", cHash, m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel)->m_Hash.GetString());
1123 maxLevel = max(curLevel, maxLevel);
1124 curLevel = 0;
1125 cHash++;
1126 }
1127 VERIFY( m_pHashTree.FindHash(i+j, 9728000-j, &curLevel) );
1128 //TRACE("%u - %s\r\n", cHash, m_pHashTree.FindHash(i+j, 9728000-j, &curLevel)->m_Hash.GetString());
1129 maxLevel = max(curLevel, maxLevel);
1130 curLevel = 0;
1131 cHash++;
1132
1133 }
1134 VERIFY( CreatePartRecoveryData(i, &file) );
1135 file.Seek(0,wxFromStart);
1136 VERIFY( TestHashSet.ReadRecoveryData(i, &file) );
1137 file.Seek(0,wxFromStart);

Callers

nothing calls this directly

Calls 7

SetMasterHashMethod · 0.80
SeekMethod · 0.80
ReadRecoveryDataMethod · 0.80
FreeHashSetMethod · 0.80
SetFileSizeMethod · 0.45
GetFileSizeMethod · 0.45
FindHashMethod · 0.45

Tested by

no test coverage detected