@@ -119,7 +119,7 @@ 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 = (
122+ pic_expected_links = (
123123 (b'QmZ5RgT3jJhRNMEgLSEsez9uz1oDnNeAysLLxRco8jz5Be' , 262158 ),
124124 (b'QmUZvm5TertyZagJfoaw5E5DRvH6Ssu4Wsdfw69NHaNRTc' , 262158 ),
125125 (b'QmTA3tDxTZn5DGaDshGTu9XHon3kcRt17dgyoomwbJkxvJ' , 262158 ),
@@ -136,12 +136,32 @@ def test_generate_file_hash_for_large_files(tmp_path):
136136 (b'QmNsx32qEiEcHRL1TFcy2bPvwqjHZGp62mbcVa9FUpY9Z5' , 262158 ),
137137 (b'QmVx2NfXEvHaS8uaRTYaF4ExeLaCSGpTSDhhYBEAembdbk' , 69716 ),
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' , 262158 ),
141+ (b'QmZw2JEKQu8n5zisuU7JDAeWSUm2XvqjqV72bizCdDQUDM' , 19278 ),
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