taint

Crypto forensics for private use
git clone git://git.defalsify.org/taint.git
Log | Files | Refs | LICENSE

base.py (1173B)


      1 # standard imports
      2 import os
      3 import unittest
      4 import logging
      5 import tempfile
      6 import shutil
      7 
      8 # external imports
      9 from chainlib.chain import ChainSpec
     10 
     11 # local imports
     12 from taint.account import Account
     13 
     14 
     15 BLOOM_BITS = 1024 * 1024 * 8
     16 
     17 script_dir = os.path.realpath(os.path.dirname(__file__))
     18 data_dir = os.path.join(script_dir, 'testdata')
     19 
     20 logg = logging.getLogger().getChild(__name__)
     21 
     22 
     23 class TestBase(unittest.TestCase):
     24 
     25     def setUp(self):
     26         os.makedirs(data_dir, exist_ok=True)
     27         self.salt = Account.salt
     28         self.session_data_dir = tempfile.mkdtemp(dir=data_dir)
     29         self.bits_size = BLOOM_BITS
     30         self.bytes_size = (BLOOM_BITS - 1) / 8 + 1
     31 
     32         self.chain_spec = ChainSpec('foo', 'bar', 42, 'baz')
     33 
     34         self.alice = Account(self.chain_spec, os.urandom(20), label='alice', tags=[b'inky'])
     35         self.bob = Account(self.chain_spec, os.urandom(20), label='bob', tags=[b'pinky'])
     36         self.eve = Account(self.chain_spec, os.urandom(20), label='eve', tags=[b'blinky'])
     37         self.mallory = Account(self.chain_spec, os.urandom(20), label='mallory', tags=[b'sue'])
     38 
     39 
     40     def tearDown(self):
     41         shutil.rmtree(self.session_data_dir)