コード例 #1
0
    def test_6_block_batch_non_sufficient_pow(self):
        """
            testing block batch with non_sufficient_pow
        """
        # check if required files are generated 
        test_helper.setup_validate_test_environment(BATCH_SIZE, BATCH_NO, verbose=self.verbose)

        test_helper.exec_compute_witness(self.ctx, '{}block_batch_non_sufficient_pow.json'.format(self.conf_dir_path), BATCH_SIZE, BATCH_NO, verbose=self.verbose)
        
        # checking if output found error with help of regex
        with open('./output/witness1', 'r') as witness:
            lines = witness.readlines()
            check = re.match('^~out_0 0$', lines[6])
            self.assertIsNotNone(check, 'non sufficient pow of block batch was accepted')
コード例 #2
0
 def test_3_malicious_prev_block(self):
     """
         returns valid getBlockHash
         malicious return for getBlock
             - malicious prev block hash
     """
     # check if required files are generated 
     test_helper.setup_validate_test_environment(BATCH_SIZE, BATCH_NO, verbose=self.verbose)
     
     test_helper.exec_compute_witness(self.ctx, '{}malicious_prev_block.json'.format(self.conf_dir_path), BATCH_SIZE, BATCH_NO, verbose=self.verbose)
     
     # checking if output found error with help of regex
     with open('./output/witness1', 'r') as witness:
         lines = witness.readlines()
         check = re.match('^~out_0 0$', lines[6])
         self.assertIsNotNone(check, 'malicious prevBlock was accepted')
コード例 #3
0
    def test_7_crossover_of_epochs(self):
        """
            testing block batch that overlaps an epoch
        """
        batch_size = 5
        batch_no = 99994

        # check if required files are generated 
        test_helper.setup_validate_test_environment(batch_size, batch_no, verbose=self.verbose)

        test_helper.exec_compute_witness(self.ctx, '{}crossover_of_epochs.json'.format(self.conf_dir_path), batch_size, batch_no, verbose=self.verbose)
        
        with open('./output/witness{}'.format(batch_no), 'r') as witness:
            lines = witness.readlines()
            check = re.match('^~out_0 0$', lines[6])
            self.assertIsNotNone(check, '{} blocks at a crossover between epochs were processed.'.format(batch_size))
コード例 #4
0
    def test_2_malicious_blocks_version_hex(self):
        """
            Valid return for getBlockHash
            Malicious return for first getBlock 
                - wrong merkle root for block sequence
        """
        # check if required files are generated 
        test_helper.setup_validate_test_environment(BATCH_SIZE, BATCH_NO, verbose=self.verbose)

        test_helper.exec_compute_witness(self.ctx, '{}malicious_blocks_version_hex.json'.format(self.conf_dir_path), BATCH_SIZE, BATCH_NO, verbose=self.verbose)
        
        # checking if output found error with help of regex
        with open('./output/witness1', 'r') as witness:
            lines = witness.readlines()
            check = re.match('^~out_0 0$', lines[6])
            self.assertIsNotNone(check, 'malicious version hex of blocks in batch were accepted')
コード例 #5
0
    def test_1_start_of_epoch(self):
        batch_size = 2
        batch_no = 1

        # check if required files are generated
        test_helper.setup_validate_test_environment(batch_size,
                                                    batch_no,
                                                    verbose=self.verbose)

        test_helper.exec_compute_witness(
            self.ctx, '{}start_of_epoch.json'.format(self.conf_dir_path),
            batch_size, batch_no, self.verbose)

        with open('./output/witness{}'.format(batch_no), 'r') as witness:
            lines = witness.readlines()
            check = re.match('^~out_0 1$', lines[6])
            self.assertIsNotNone(
                check,
                '{} blocks at start of epoch werent processed correctly.'.
                format(batch_size))