Skip to content

Commit

Permalink
tests: mock_build_safe_raw_tx
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrenbelt committed Sep 2, 2022
1 parent 6a2bfa6 commit 586e0df
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_skills/test_keep3r_job/test_behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
SynchronizedData,
WaitingRound,
)
from packages.valory.contracts.gnosis_safe.contract import (
PUBLIC_ID as GNOSIS_SAFE_CONTRACT_ID,
)
from packages.valory.contracts.keep3r_test_job.contract import (
PUBLIC_ID as TEST_JOB_CONTRACT_ID,
)
Expand Down Expand Up @@ -235,6 +238,27 @@ def mock_build_work_tx_call(self, data: Any) -> None:
),
)


def mock_build_safe_raw_tx(self) -> None:
"""Mock build safe raw transaction"""

self.mock_contract_api_request(
request_kwargs=dict(
performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION,
),
contract_id=str(GNOSIS_SAFE_CONTRACT_ID),
response_kwargs=dict(
performative=ContractApiMessage.Performative.RAW_TRANSACTION,
callable="get_raw_safe_transaction_hash",
raw_transaction=ContractApiMessage.RawTransaction(
ledger_id="ethereum",
body={
"tx_hash": "0xb0e6add595e00477cf347d09797b156719dc5233283ac76e4efce2a674fe72d9"
},
),
),
)

def mock_ethereum_ledger_state_call(self, data: Any) -> None:
"""Mock ethereum ledger get state call"""

Expand Down Expand Up @@ -329,6 +353,7 @@ def test_bonding_tx(self) -> None:
"""Test bonding tx"""

self.mock_keep3r_v1_raw_tx("build_bond_tx", DUMMY_RAW_TX)
self.mock_build_safe_raw_tx()
self.mock_a2a_transaction()
self._test_done_flag_set()
self.end_round(done_event=Event.BONDING_TX)
Expand Down Expand Up @@ -362,6 +387,7 @@ def test_activation_tx(self) -> None:
"""Test activation tx"""

self.mock_keep3r_v1_raw_tx("build_activation_tx", DUMMY_RAW_TX)
self.mock_build_safe_raw_tx()
self.mock_a2a_transaction()
self._test_done_flag_set()
self.end_round(done_event=Event.ACTIVATION_TX)
Expand Down Expand Up @@ -437,6 +463,7 @@ def test_is_workable(
"""Test is_workable."""

self.mock_test_job_call("workable", is_workable)
self.mock_build_safe_raw_tx()
self.behaviour.act_wrapper()
self.mock_a2a_transaction()
self._test_done_flag_set()
Expand Down

0 comments on commit 586e0df

Please sign in to comment.