def setup_operator(self,
                    number_owners: int = 1,
                    version="1.1.1") -> SafeOperator:
     assert number_owners >= 1, "Number of owners cannot be less than 1!"
     if version == "1.1.1":
         safe_address = self.deploy_test_safe(
             owners=[self.ethereum_test_account.address]).safe_address
     elif version == "1.3.0":
         safe_address = self.deploy_test_safe_v1_3_0(
             owners=[self.ethereum_test_account.address]).address
     else:
         raise ValueError(f"{version} not supported")
     safe_operator = SafeOperator(safe_address, self.ethereum_node_url)
     safe_operator.load_cli_owners([self.ethereum_test_account.key.hex()])
     for _ in range(number_owners - 1):
         account = Account.create()
         safe_operator.add_owner(account.address)
         safe_operator.load_cli_owners([account.key.hex()])
     return safe_operator
Example #2
0
    def test_remove_owner(self):
        safe_address = self.deploy_test_safe(
            owners=[self.ethereum_test_account.address]).safe_address
        safe_operator = SafeOperator(safe_address, self.ethereum_node_url)
        random_address = Account.create().address
        with self.assertRaises(NonExistingOwnerException):
            safe_operator.remove_owner(random_address)

        safe_operator.load_cli_owners([self.ethereum_test_account.key.hex()])
        new_owner = Account.create().address
        safe = Safe(safe_address, self.ethereum_client)
        self.assertTrue(safe_operator.add_owner(new_owner))
        self.assertIn(new_owner, safe.retrieve_owners())

        self.assertTrue(safe_operator.remove_owner(new_owner))
        self.assertNotIn(new_owner, safe_operator.accounts)
        self.assertNotIn(new_owner, safe.retrieve_owners())
Example #3
0
    def test_add_owner(self):
        safe_address = self.deploy_test_safe(
            owners=[self.ethereum_test_account.address]).safe_address
        safe_operator = SafeOperator(safe_address, self.ethereum_node_url)
        with self.assertRaises(ExistingOwnerException):
            safe_operator.add_owner(self.ethereum_test_account.address)

        new_owner = Account.create().address
        with self.assertRaises(NotEnoughSignatures):
            safe_operator.add_owner(new_owner)

        safe_operator.accounts.add(self.ethereum_test_account)

        with self.assertRaises(SenderRequiredException):
            safe_operator.add_owner(new_owner)

        safe_operator.default_sender = self.ethereum_test_account

        safe = Safe(safe_address, self.ethereum_client)
        self.assertTrue(safe_operator.add_owner(new_owner))
        self.assertIn(self.ethereum_test_account, safe_operator.accounts)
        self.assertIn(new_owner, safe.retrieve_owners())