# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest
import hashlib

test_records = []
class TestTransactionLog(unittest.TestCase):

	def test_validate_chaining(self):
		frappe.get_doc({
			"doctype": "Transaction Log",
			"reference_doctype": "Test Doctype",
			"document_name": "Test Document 1",
			"data": "first_data"
		}).insert(ignore_permissions=True)

		second_log = frappe.get_doc({
						"doctype": "Transaction Log",
						"reference_doctype": "Test Doctype",
						"document_name": "Test Document 2",
						"data": "second_data"
					}).insert(ignore_permissions=True)

		third_log = frappe.get_doc({
						"doctype": "Transaction Log",
						"reference_doctype": "Test Doctype",
						"document_name": "Test Document 3",
						"data": "third_data"
					}).insert(ignore_permissions=True)


		sha = hashlib.sha256()
		sha.update(str(third_log.transaction_hash) + str(second_log.chaining_hash))

		self.assertEqual(sha.hexdigest(), third_log.chaining_hash)

@@ -954,16 +954,39 @@
 .update(
+%0A%09%09%09frappe.safe_encode(
 str(thir
@@ -1012,11 +1012,35 @@
 ash)
+)
  + 
+%0A%09%09%09frappe.safe_encode(
 str(
@@ -1065,16 +1065,20 @@
 g_hash))
+%0A%09%09)
 %0A%0A%09%09self

fix py3 test case