def test_loadedBlock(self): # load the generated block from the file with open('test_txn_one.dat', 'rb') as f: version = f.read(4) size_in_bytes = f.read(4) content_size = struct.unpack('I', size_in_bytes)[0] content = f.read(content_size) read_block = bytearray() read_block.extend(version) read_block.extend(size_in_bytes) read_block.extend(content) # Convert the read in block to a transaction object txn_in = Transaction() txn_in.parseFromBytes(read_block) # Get the content and convert to a string loadedContent = txn_in.getContent() loadedString = loadedContent.decode('utf-8') # Make sure it matches the original input self.assertEqual( loadedString, self.original_content, 'Content not correctly loaded')