Skip to content

Commit

Permalink
Fix unloaded proposer removing transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Feb 19, 2024
1 parent 0560d9d commit 8a39352
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion safe_cli/operators/safe_tx_service_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,11 @@ def remove_proposed_transaction(self, safe_tx_hash: bytes):
if not signer:
print_formatted_text(
HTML(
f"<ansired>The proposer with address: {safe_tx.proposer} wasn loaded</ansired>"
f"<ansired>The proposer with address: {safe_tx.proposer} was not loaded</ansired>"
)
)
return False

if isinstance(signer, LocalAccount):
signature = signer.signHash(message_hash).signature
else:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_safe_tx_service_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ def test_remove_transaction(
safe_operator.address = "0x23793e7Ce4f2Fd31C993893f658181fD39fB5dEb"
signer = list(safe_operator.accounts)[0]
safe_tx_mock = MagicMock()
safe_tx_mock.proposer = signer.address
get_transaction_mock.return_value = (safe_tx_mock, None)
safe_tx_hash = HexBytes(
"0x07eeea19b7d005b561f367e714bf65734d0ecc477de3e8b1fbc20ccb18c8747b"
)
expected_signature = "0xbc305f59a62c5bbb002645f658ee62cfa1966f20aca4dc1922b813e9d41bf1f02abd356891a3725af2066dd1758c930574298b4ba180117dc6146bbc4369cc0c1c"
safe_tx_mock.proposer = signer.address
self.assertTrue(safe_operator.remove_proposed_transaction(safe_tx_hash))
remove_transaction_mock.assert_called_with(
safe_tx_hash.hex(), expected_signature
)
# Different proposer should return False
safe_tx_mock.proposer = Account.create().address
self.assertFalse(safe_operator.remove_proposed_transaction(safe_tx_hash))

@mock.patch.object(SafeTxServiceOperator, "get_permitted_signers", return_value=[])
@mock.patch.object(
Expand Down

0 comments on commit 8a39352

Please sign in to comment.