Ejemplo n.º 1
0
 def test_create_eth_provider(self):
     name = "provider name"
     args = "arguments"
     return_value = "value"
     config = ConfigFactory.create_empty_config()
     config._Config__eth_provider_name = name
     config._Config__eth_provider_args = args
     utils = ConfigUtilsMock()
     utils.expect('create_eth_provider',
                  {'provider': name, 'args': args},
                  return_value)
     result = config._Config__create_eth_provider(utils)
     self.assertEqual(return_value, result)
     utils.verify()
Ejemplo n.º 2
0
 def test_create_analyzers(self):
     analyzers_config = "config list"
     logger = "logger"
     return_value = "value"
     config = ConfigFactory.create_empty_config()
     config._Config__analyzers_config = analyzers_config
     config._Config__logger = logger
     utils = ConfigUtilsMock()
     utils.expect('create_analyzers',
                  {'analyzers_config': analyzers_config, 'logger': logger},
                  return_value)
     result = config._Config__create_analyzers(utils)
     self.assertEqual(return_value, result)
     utils.verify()
Ejemplo n.º 3
0
 def test_create_web3_client(self):
     eth_provider = "eth_provider"
     account_passwd = "account password"
     account_keystore_file = "./mykey.json"
     created_web3_provider = "created provider"
     config = ConfigFactory.create_empty_config()
     config._Config__eth_provider = eth_provider
     config._Config__account_passwd = account_passwd
     config._Config__account_keystore_file = account_keystore_file
     utils = ConfigUtilsMock()
     utils.expect('create_web3_client',
                  {'eth_provider': eth_provider, 'account_passwd': account_passwd,
                   'keystore_file': account_keystore_file, 'max_attempts': 30},
                  created_web3_provider)
     result = config._Config__create_web3_client(utils)
     self.assertEqual(created_web3_provider, result)
     utils.verify()
Ejemplo n.º 4
0
 def test_create_upload_provider(self):
     account = "account"
     upload_provider_name = "provider name"
     upload_provider_args = "arguments"
     upload_provider = "value"
     config = ConfigFactory.create_empty_config()
     config._Config__account = account
     config._Config__upload_provider_name = upload_provider_name
     config._Config__upload_provider_is_enabled = True
     config._Config__upload_provider_args = upload_provider_args
     utils = ConfigUtilsMock()
     utils.expect('create_upload_provider',
                  {'account': account,
                   'upload_provider_name': upload_provider_name,
                   'upload_provider_args': upload_provider_args,
                   'upload_provider_is_enabled': True},
                  upload_provider)
     result = config._Config__create_upload_provider(utils)
     self.assertEqual(upload_provider, result)
     utils.verify()
Ejemplo n.º 5
0
 def test_create_components(self):
     eth_provider_name = "eth provider name"
     eth_provider_args = "eth provider arguments"
     created_eth_provider = "created_eth_provider"
     new_account = "0xc1220b0bA0760817A9E8166C114D3eb2741F5949"
     account_passwd = "account password"
     account_keystore_file = "./mykey.json"
     new_private_key = "abcdefg"
     account = "0x12345"
     analyzers_config = "config list"
     created_analyzers = "analyzers"
     upload_provider_name = "upload provider name"
     upload_provider_args = "upload provider arguments"
     upload_provider = "created upload provier"
     audit_contract_abi_uri = "some uri"
     audit_contract_address = "0xc1220b0bA0760817A9E8166C114D3eb2741F5949"
     created_audit_contract = "contract"
     created_web3_client = Web3Mock()
     config = ConfigFactory.create_empty_config()
     config._Config__eth_provider_name = eth_provider_name
     config._Config__eth_provider_args = eth_provider_args
     config._Config__account = account
     config._Config__account_passwd = account_passwd
     config._Config__account_keystore_file = account_keystore_file
     config._Config__analyzers_config = analyzers_config
     config._Config__evt_db_path = "/tmp/evts.test"
     config._Config__upload_provider_name = upload_provider_name
     config._Config__upload_provider_args = upload_provider_args
     config._Config__upload_provider_is_enabled = True
     config._Config__audit_contract_abi_uri = audit_contract_abi_uri
     config._Config__audit_contract_address = audit_contract_address
     utils = ConfigUtilsMock()
     utils.expect('create_eth_provider',
                 {'provider': eth_provider_name, 'args': eth_provider_args},
                 created_eth_provider)
     utils.expect('create_web3_client',
                  {'eth_provider': created_eth_provider, 'account_passwd': account_passwd,
                   'keystore_file': account_keystore_file, 'max_attempts': 30},
                  (created_web3_client, new_account, new_private_key))
     utils.expect('check_audit_contract_settings',
                  {'config': config},
                  None)
     utils.expect('create_contract',
                  {'web3_client': created_web3_client, 'audit_contract_abi_uri': audit_contract_abi_uri,
                   'audit_contract_address': audit_contract_address},
                  created_audit_contract)
     utils.expect('check_configuration_settings',
                  {'config': config},
                  None)
     utils.expect('create_analyzers',
                  {'analyzers_config': analyzers_config},
                  created_analyzers)
     utils.expect('create_upload_provider',
                  {'account': new_account,
                   'upload_provider_name': upload_provider_name,
                   'upload_provider_args': upload_provider_args,
                   'upload_provider_is_enabled': True},
                  upload_provider)
     config._Config__create_components(utils)
     self.assertEqual(created_eth_provider, config.eth_provider)
     self.assertEqual(created_web3_client, config.web3_client)
     self.assertEqual(new_account, config.account)
     self.assertEqual(created_analyzers, config.analyzers)
     self.assertEqual(upload_provider, config.upload_provider)
     self.assertEqual(created_audit_contract, config.audit_contract)
     utils.verify()