@@ -119,29 +119,49 @@ def test_generate_file_hash(tmpdir, file_name, file_contents, expected):
119119
120120
121121def test_generate_file_hash_for_large_files (tmp_path ):
122- expected_links = (
123- (b'QmZ5RgT3jJhRNMEgLSEsez9uz1oDnNeAysLLxRco8jz5Be' , 262158 ),
124- (b'QmUZvm5TertyZagJfoaw5E5DRvH6Ssu4Wsdfw69NHaNRTc' , 262158 ),
125- (b'QmTA3tDxTZn5DGaDshGTu9XHon3kcRt17dgyoomwbJkxvJ' , 262158 ),
126- (b'QmXRkS2AtimY2gujGJDXjSSkpt2Xmgog6FjtmEzt2PwcsA' , 262158 ),
127- (b'QmVuqvYLEo76hJVE9c5h9KP2MbQuTxSFyntV22qdz6F1Dr' , 262158 ),
128- (b'QmbsEhRqFwKAUoc6ivZyPa1vGUxFKBT4ciH79gVszPcFEG' , 262158 ),
129- (b'QmegS44oDgNU2hnD3j8r1WH8xZ2RWfe3Z5eb6aJRHXwJsw' , 262158 ),
130- (b'QmbC1ZyGUoxZrmTTjgmiB3KSRRXJFkhpnyKYkiVC6PUMzf' , 262158 ),
131- (b'QmZvpEyzP7C8BABesRvpYWPec2HGuzgnTg4VSPiTpQWGpy' , 262158 ),
132- (b'QmZhzU2QJF4rUpRSWZxjutWz22CpFELmcNXkGAB1GVb26H' , 262158 ),
133- (b'QmZeXvgS1NTxtVv9AeHMpA9oGCRrnVTa9bSCSDgAt52iyT' , 262158 ),
134- (b'QmPy1wpe1mACVrXRBtyxriT2T5AffZ1SUkE7xxnAHo4Dvs' , 262158 ),
135- (b'QmcHbhgwAVddCyFVigt2DLSg8FGaQ1GLqkyy5M3U5DvTc6' , 262158 ),
136- (b'QmNsx32qEiEcHRL1TFcy2bPvwqjHZGp62mbcVa9FUpY9Z5' , 262158 ),
137- (b'QmVx2NfXEvHaS8uaRTYaF4ExeLaCSGpTSDhhYBEAembdbk' , 69716 ),
122+ pic_expected_links = (
123+ (b'QmZ5RgT3jJhRNMEgLSEsez9uz1oDnNeAysLLxRco8jz5Be' , 262144 ),
124+ (b'QmUZvm5TertyZagJfoaw5E5DRvH6Ssu4Wsdfw69NHaNRTc' , 262144 ),
125+ (b'QmTA3tDxTZn5DGaDshGTu9XHon3kcRt17dgyoomwbJkxvJ' , 262144 ),
126+ (b'QmXRkS2AtimY2gujGJDXjSSkpt2Xmgog6FjtmEzt2PwcsA' , 262144 ),
127+ (b'QmVuqvYLEo76hJVE9c5h9KP2MbQuTxSFyntV22qdz6F1Dr' , 262144 ),
128+ (b'QmbsEhRqFwKAUoc6ivZyPa1vGUxFKBT4ciH79gVszPcFEG' , 262144 ),
129+ (b'QmegS44oDgNU2hnD3j8r1WH8xZ2RWfe3Z5eb6aJRHXwJsw' , 262144 ),
130+ (b'QmbC1ZyGUoxZrmTTjgmiB3KSRRXJFkhpnyKYkiVC6PUMzf' , 262144 ),
131+ (b'QmZvpEyzP7C8BABesRvpYWPec2HGuzgnTg4VSPiTpQWGpy' , 262144 ),
132+ (b'QmZhzU2QJF4rUpRSWZxjutWz22CpFELmcNXkGAB1GVb26H' , 262144 ),
133+ (b'QmZeXvgS1NTxtVv9AeHMpA9oGCRrnVTa9bSCSDgAt52iyT' , 262144 ),
134+ (b'QmPy1wpe1mACVrXRBtyxriT2T5AffZ1SUkE7xxnAHo4Dvs' , 262144 ),
135+ (b'QmcHbhgwAVddCyFVigt2DLSg8FGaQ1GLqkyy5M3U5DvTc6' , 262144 ),
136+ (b'QmNsx32qEiEcHRL1TFcy2bPvwqjHZGp62mbcVa9FUpY9Z5' , 262144 ),
137+ (b'QmVx2NfXEvHaS8uaRTYaF4ExeLaCSGpTSDhhYBEAembdbk' , 69702 ),
138138 )
139- expected_root_hash = 'QmQgQUbBeMTnH1j3QWwNw9LkXjpWDJrjyGYfZpnPp8x5Lu'
140- test = Path (__file__ ).parent / 'pic.jpg'
141- ipfs_multihash = generate_links (test .read_bytes ())
142- hashes = [(x .Hash , x .Tsize ) for x in ipfs_multihash ]
143- for x in expected_links :
144- assert x in hashes
139+ txt_expected_links = (
140+ (b'QmbYfXF7A7hgXUzEZSifji3D6Nf856kdK8Edu8n7knQSHr' , 262144 ),
141+ (b'QmZw2JEKQu8n5zisuU7JDAeWSUm2XvqjqV72bizCdDQUDM' , 19264 ),
142+ )
143+ pic_expected_root_hash = 'QmQgQUbBeMTnH1j3QWwNw9LkXjpWDJrjyGYfZpnPp8x5Lu'
144+ txt_exp_hash = 'QmegXsU7EopJ9EVj9ELwgHGE75Xke6FYBP84PaygiAsqB5'
145+ pic_path = Path (__file__ ).parent / 'pic.jpg'
146+ txt_path = Path (__file__ ).parent / 'txt.txt'
147+ txt_multihash , txt_blocksizes = generate_links (txt_path .read_bytes ())
148+ pic_multihash , pic_blocksizes = generate_links (pic_path .read_bytes ())
149+ txt_hashes = [(x .Hash , x .Tsize ) for x in txt_multihash ]
150+ pic_hashes = [(x .Hash , x .Tsize ) for x in pic_multihash ]
151+ # for x in txt_expected_links:
152+ # assert x in txt_hashes
153+ # for y in pic_expected_links:
154+ # assert y in pic_hashes
145155 # test works until here, where it has to calculate the root hash
146- root_hash = generate_file_hash (test .read_bytes ())
147- assert root_hash == expected_root_hash
156+ txt_root_hash = generate_file_hash (txt_path .read_bytes ())
157+ pic_root_hash = generate_file_hash (pic_path .read_bytes ())
158+ print ("txt: actual / expected" )
159+ print (txt_root_hash )
160+ print (txt_exp_hash )
161+ print (f'txt blocksizes: count: { len (txt_blocksizes )} , set: { set (txt_blocksizes )} ' )
162+ print ("pic: actual / expected" )
163+ print (pic_root_hash )
164+ print (pic_expected_root_hash )
165+ print (f'pic blocksizes: count: { len (pic_blocksizes )} , set: { set (pic_blocksizes )} ' )
166+ assert txt_root_hash == txt_exp_hash
167+ assert pic_root_hash == pic_expected_root_hash
0 commit comments