Esempio n. 1
0
 def command_add_ether_wallet(self):
     try:
         wallet = Vault().find_wallet(name=self.name)
     except ValueError:
         return logging.error("The wallet's name can not be found.")
     wallet.add_ether(2000000000000000000)
     logging.info("Some ethers have been added.")
Esempio n. 2
0
class TestBase(unittest.TestCase):
    def generate_wallet(self):
        if not self.has_temporary_files():
            self.temp_files()

        self.wallet = Vault().create_wallet('test')
        self.wallet.add_ether(init_ether)

    def temp_files(self):
        self.workdir = tempfile.TemporaryDirectory()
        os.environ['HOME'] = self.workdir.name
        self._temporary = True

    def generate_c_org(self):
        if not self.has_temporary_files():
            self.temp_files()

        rootdir = os.path.dirname(os.path.abspath(__file__))
        c_orgs = utils.get_c_org_path()
        os.makedirs(c_orgs)
        contracts = os.path.join(c_orgs, "contracts")
        os.makedirs(contracts)
        contract = os.path.join(rootdir, "ressources", ".c-org", "contracts",
                                "ContinuousOrganisation.sol")
        shutil.copy(contract, contracts)
        global_file = os.path.join(rootdir, "ressources", ".c-org",
                                   "global.yaml")
        shutil.copy(global_file, c_orgs)
        vault_file = os.path.join(rootdir, "ressources", ".c-org",
                                  "vault.yaml")
        shutil.copy(vault_file, c_orgs)

    def has_temporary_files(self):
        return hasattr(self, '_temporary') and self._temporary

    def generate_manager(self):
        if not self.has_temporary_files():
            self.temp_files()

        name = "my-co"
        c_name = utils.clean_name(name)
        self.my_co_path = os.path.join(utils.get_c_org_path(), c_name)
        os.makedirs(self.my_co_path)
        global_params = GlobalParams()
        global_params.create_or_update(name, self.my_co_path)
        rootdir = os.path.dirname(os.path.abspath(__file__))
        config_file = os.path.join(rootdir, "ressources", "config.yaml")
        shutil.copy(config_file, self.my_co_path)
        self.c_org_manager = ContinuousOrganisationManager(name)

    def cleanup(self):
        if self.has_temporary_files():
            self.workdir.cleanup()

    def tearDown(self):
        self.cleanup()