def test_prepare_batch(self): secret_manager = mock.Mock() certificates_to_issue = dict() certificates_to_issue['1'] = mock.Mock() certificates_to_issue['2'] = mock.Mock() certificates_to_issue['3'] = mock.Mock() certificate_batch_handler = CertificateBatchHandler(secret_manager=secret_manager, certificate_handler=DummyCertificateHandler(), merkle_tree=MerkleTreeGenerator()) certificate_batch_handler.set_certificates_in_batch(certificates_to_issue) result = certificate_batch_handler.prepare_batch() self.assertEqual(b2h(result), '0932f1d2e98219f7d7452801e2b64ebd9e5c005539db12d9b1ddabe7834d9044')
def instantiate_blockchain_handlers(app_config, file_mode=True): issuing_address = app_config.issuing_address chain = app_config.chain secret_manager = initialize_signer(app_config) if file_mode: certificate_batch_handler = CertificateBatchHandler( secret_manager=secret_manager, certificate_handler=CertificateV2Handler(), merkle_tree=MerkleTreeGenerator()) else: certificate_batch_handler = CertificateBatchWebHandler( secret_manager=secret_manager, certificate_handler=CertificateWebV2Handler(), merkle_tree=MerkleTreeGenerator()) if chain == Chain.mockchain: transaction_handler = MockTransactionHandler() else: cost_constants = BitcoinTransactionCostConstants( app_config.tx_fee, app_config.dust_threshold, app_config.satoshi_per_byte) connector = BitcoinServiceProviderConnector(chain, app_config.bitcoind) transaction_handler = BitcoinTransactionHandler( connector, cost_constants, secret_manager, issuing_address=issuing_address) return certificate_batch_handler, transaction_handler, connector
def instantiate_blockchain_handlers(app_config): check_necessary_arguments(app_config) issuing_address = app_config.issuing_address chain = app_config.chain secret_manager = initialize_signer(app_config) certificate_batch_handler = CertificateBatchHandler( secret_manager=secret_manager, certificate_handler=CertificateV3Handler(), merkle_tree=MerkleTreeGenerator(), config=app_config) if chain == Chain.mockchain: transaction_handler = MockTransactionHandler() # ethereum chains elif chain == Chain.ethereum_mainnet or chain == Chain.ethereum_bloxberg: cost_constants = EthereumTransactionCostConstants( app_config.gas_price, app_config.gas_limit) connector = instantiate_connector(app_config, cost_constants) transaction_handler = EthereumSCTransactionHandler( connector, cost_constants, secret_manager, issuing_address=issuing_address) return certificate_batch_handler, transaction_handler, connector
def _get_certificate_batch_handler(self): secret_manager = mock.Mock() certificates_to_issue = dict() certificates_to_issue['1'] = mock.Mock() certificates_to_issue['2'] = mock.Mock() certificates_to_issue['3'] = mock.Mock() handler = CertificateBatchHandler( secret_manager=secret_manager, certificate_handler=DummyCertificateHandler(), merkle_tree=MerkleTreeGenerator()) return handler, certificates_to_issue
def instantiate_blockchain_handlers(app_config): issuing_address = app_config.issuing_address chain = app_config.chain secret_manager = initialize_signer(app_config) certificate_batch_handler = CertificateBatchHandler(secret_manager=secret_manager, certificate_handler=CertificateV2Handler(), merkle_tree=MerkleTreeGenerator()) if chain == Chain.mockchain: transaction_handler = MockTransactionHandler() # ethereum chains elif chain == Chain.ethereum_mainnet or chain == Chain.ethereum_ropsten: cost_constants = EthereumTransactionCostConstants(app_config.gas_price, app_config.gas_limit) connector = EthereumServiceProviderConnector(chain, app_config.api_token) transaction_handler = EthereumTransactionHandler(connector, cost_constants, secret_manager, issuing_address=issuing_address) return certificate_batch_handler, transaction_handler, connector
def _get_certificate_batch_handler(self): secret_manager = mock.Mock() certificates_to_issue = dict() certificates_to_issue['1'] = mock.Mock() certificates_to_issue['2'] = mock.Mock() certificates_to_issue['3'] = mock.Mock() config = mock.Mock() config.issuing_address = "http://example.com" handler = CertificateBatchHandler( secret_manager=secret_manager, certificate_handler=DummyCertificateHandler(), merkle_tree=MerkleTreeGenerator(), config=config) return handler, certificates_to_issue