diff --git a/requirements.txt b/requirements.txt index 30f0d587..565eb51e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ prompt_toolkit==3.0.39 pyfiglet==1.0.0 pygments==2.16.1 requests==2.31.0 -safe-eth-py==6.0.0a1 +safe-eth-py==6.0.0b2 tabulate==0.9.0 web3==6.10.0 diff --git a/safe_cli/operators/safe_operator.py b/safe_cli/operators/safe_operator.py index 160e3ce8..f368aebc 100644 --- a/safe_cli/operators/safe_operator.py +++ b/safe_cli/operators/safe_operator.py @@ -512,7 +512,6 @@ def change_guard(self, guard: str) -> bool: return True def change_master_copy(self, new_master_copy: str) -> bool: - # TODO Check that master copy is valid if new_master_copy == self.safe_cli_info.master_copy: raise SameMasterCopyException(new_master_copy) else: diff --git a/tests/safe_cli_test_case_mixin.py b/tests/safe_cli_test_case_mixin.py index a1429fd3..fbcb9d7d 100644 --- a/tests/safe_cli_test_case_mixin.py +++ b/tests/safe_cli_test_case_mixin.py @@ -8,7 +8,11 @@ class SafeCliTestCaseMixin(SafeTestCaseMixin): def setup_operator(self, number_owners: int = 1, version="1.4.1") -> SafeOperator: assert number_owners >= 1, "Number of owners cannot be less than 1!" - if version == "1.1.1": + if version == "1.0.0": + safe = self.deploy_test_safe_v1_0_0( + owners=[self.ethereum_test_account.address] + ) + elif version == "1.1.1": safe = self.deploy_test_safe_v1_1_1( owners=[self.ethereum_test_account.address] ) diff --git a/tests/test_safe_operator.py b/tests/test_safe_operator.py index 1f948a64..d8765f0e 100644 --- a/tests/test_safe_operator.py +++ b/tests/test_safe_operator.py @@ -144,9 +144,8 @@ def test_change_fallback_handler(self): safe_operator.change_fallback_handler(current_fallback_handler) new_fallback_handler = Account.create().address - with self.assertRaises( - InvalidFallbackHandlerException - ): # Contract does not exist + with self.assertRaises(InvalidFallbackHandlerException): + # Contract does not exist self.assertTrue(safe_operator.change_fallback_handler(new_fallback_handler)) with mock.patch.object( @@ -158,9 +157,10 @@ def test_change_fallback_handler(self): ) self.assertEqual(safe.retrieve_fallback_handler(), new_fallback_handler) - safe_operator.change_master_copy(self.safe_contract_V1_1_1.address) + # Safes < 1.1.0 don't support the fallback handler + safe_operator_v1_0_0 = self.setup_operator(version="1.0.0") with self.assertRaises(FallbackHandlerNotSupportedException): - safe_operator.change_fallback_handler(Account.create().address) + safe_operator_v1_0_0.change_fallback_handler(Account.create().address) def test_change_guard(self): safe_operator = self.setup_operator(version="1.1.1") @@ -173,21 +173,20 @@ def test_change_guard(self): with self.assertRaises(SameGuardException): safe_operator.change_guard(current_guard) - new_guard = Account.create().address + not_valid_guard = Account.create().address with self.assertRaises(InvalidGuardException): # Contract does not exist - self.assertTrue(safe_operator.change_guard(new_guard)) + self.assertTrue(safe_operator.change_guard(not_valid_guard)) - with mock.patch.object( - EthereumClient, "is_contract", autospec=True, return_value=True - ): - self.assertTrue(safe_operator.change_guard(new_guard)) + new_guard = self.deploy_example_guard() + self.assertTrue(safe_operator.change_guard(new_guard)) self.assertEqual(safe_operator.safe_cli_info.guard, new_guard) self.assertEqual(safe.retrieve_guard(), new_guard) def test_change_master_copy(self): - safe_operator = self.setup_operator() + safe_operator = self.setup_operator(version="1.1.1") safe = Safe(safe_operator.address, self.ethereum_client) current_master_copy = safe.retrieve_master_copy_address() + self.assertEqual(current_master_copy, self.safe_contract_V1_1_1.address) with self.assertRaises(SameMasterCopyException): safe_operator.change_master_copy(current_master_copy) @@ -195,15 +194,10 @@ def test_change_master_copy(self): with self.assertRaises(InvalidMasterCopyException): safe_operator.change_master_copy(random_address) - self.assertTrue( - safe_operator.change_master_copy(self.safe_contract_V1_1_1.address) - ) - self.assertEqual( - safe_operator.safe_cli_info.master_copy, self.safe_contract_V1_1_1.address - ) - self.assertEqual( - safe.retrieve_master_copy_address(), self.safe_contract_V1_1_1.address - ) + new_master_copy = self.safe_contract_V1_3_0.address + self.assertTrue(safe_operator.change_master_copy(new_master_copy)) + self.assertEqual(safe_operator.safe_cli_info.master_copy, new_master_copy) + self.assertEqual(safe.retrieve_master_copy_address(), new_master_copy) def test_send_ether(self): safe_operator = self.setup_operator()