コード例 #1
0
 def test_blockchain_is_valid_transaction_data_duplicate_transaction(self):
     transaction = self._generate_transaction()
     self.blockchain.add_block([transaction.info, transaction.info])
     err_message = 'Repetead transaction uuid found'
     with self.assertRaises(BlockchainError) as err:
         Blockchain.is_valid_transaction_data(self.blockchain.chain)
         self.assertIsInstance(err, BlockchainError)
         self.assertIn(err_message, err.message)
コード例 #2
0
 def test_blockchain_is_valid_transaction_data_multiple_rewards(self):
     reward_transaction_1 = Transaction.reward_mining(Wallet())
     reward_transaction_2 = Transaction.reward_mining(Wallet())
     self.blockchain.add_block(
         [reward_transaction_1.info, reward_transaction_2.info])
     err_message = 'Multiple mining rewards in the same block'
     with self.assertRaises(BlockchainError) as err:
         Blockchain.is_valid_transaction_data(self.blockchain.chain)
         self.assertIsInstance(err, BlockchainError)
         self.assertIn(err_message, err.message)
コード例 #3
0
 def test_blockchain_is_valid_transaction_data_invalid_transaction(self):
     invalid_transaction = self._generate_transaction()
     invalid_transaction.input['signature'] = Wallet().sign(
         invalid_transaction.output)
     self.blockchain.add_block([invalid_transaction.info])
     err_message = 'Invalid transaction'
     with self.assertRaises(BlockchainError) as err:
         Blockchain.is_valid_transaction_data(self.blockchain.chain)
         self.assertIsInstance(err, BlockchainError)
         self.assertIn(err_message, err.message)
コード例 #4
0
 def test_blockchain_is_valid_transaction_invalid_historic_balance(self):
     wallet = Wallet()
     invalid_transaction = self._generate_transaction(wallet)
     invalid_transaction.output[wallet.address] = 1000
     invalid_transaction.input['amount'] = 1001
     invalid_transaction.input['signature'] = wallet.sign(
         invalid_transaction.output)
     self.blockchain.add_block([invalid_transaction.info])
     err_message = 'historic balance inconsistency'
     with self.assertRaises(BlockchainError) as err:
         Blockchain.is_valid_transaction_data(self.blockchain.chain)
         self.assertIsInstance(err, BlockchainError)
         self.assertIn(err_message, err.message)
コード例 #5
0
 def test_blockchain_is_valid_transaction_data(self):
     Blockchain.is_valid_transaction_data(self.blockchain.chain)