File size: 971 Bytes
92c34be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# chainguard/tests/test_data_transfer.py

import unittest
import threading
from chainguard.data_transfer import SecureDataTransfer

class TestSecureDataTransfer(unittest.TestCase):
    def setUp(self):
        self.password = "transferpassword123"
        self.data = "Sensitive data being transferred."
        self.server = SecureDataTransfer(self.password)
        self.client = SecureDataTransfer(self.password)

    def test_data_transfer(self):
        def run_server():
            received_data = self.server.receive_data()
            self.assertEqual(received_data, self.data)

        server_thread = threading.Thread(target=run_server)
        server_thread.start()

        self.client.send_data(self.data)
        server_thread.join()

        # Validate blockchain integrity after transfer
        self.assertTrue(self.server.validate_blockchain())
        self.assertTrue(self.client.validate_blockchain())

if __name__ == '__main__':
    unittest.main()