From 0c7b2611de0d2f3070592e999102897d65283ee3 Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Thu, 29 Aug 2024 09:01:23 -0400 Subject: [PATCH] remove create_and_setup_escrow function --- .../src/modules/job/job.service.spec.ts | 4 +- .../job/routing-protocol.service.spec.ts | 5 +- .../tests/integration/chain/test_escrow.py | 9 ++ .../test_process_exchange_oracle_webhooks.py | 4 +- .../tests/utils/setup_escrow.py | 9 +- .../sdk/python/human-protocol-sdk/README.md | 19 ++- .../escrow/escrow_client.py | 77 --------- .../escrow/test_escrow_client.py | 147 ------------------ .../human-protocol-sdk/src/escrow.ts | 73 --------- .../human-protocol-sdk/test/escrow.test.ts | 109 ------------- 10 files changed, 38 insertions(+), 418 deletions(-) diff --git a/packages/apps/fortune/recording-oracle/src/modules/job/job.service.spec.ts b/packages/apps/fortune/recording-oracle/src/modules/job/job.service.spec.ts index 3e09e591fc..c6f6c0e45c 100644 --- a/packages/apps/fortune/recording-oracle/src/modules/job/job.service.spec.ts +++ b/packages/apps/fortune/recording-oracle/src/modules/job/job.service.spec.ts @@ -52,9 +52,7 @@ jest.mock('minio', () => { jest.mock('@human-protocol/sdk', () => ({ ...jest.requireActual('@human-protocol/sdk'), EscrowClient: { - build: jest.fn().mockImplementation(() => ({ - createAndSetupEscrow: jest.fn().mockResolvedValue(MOCK_ADDRESS), - })), + build: jest.fn().mockImplementation(() => ({})), }, StorageClient: jest.fn().mockImplementation(() => ({ downloadFileFromUrl: jest.fn().mockResolvedValue( diff --git a/packages/apps/job-launcher/server/src/modules/job/routing-protocol.service.spec.ts b/packages/apps/job-launcher/server/src/modules/job/routing-protocol.service.spec.ts index aff19a8c66..162a6e7870 100644 --- a/packages/apps/job-launcher/server/src/modules/job/routing-protocol.service.spec.ts +++ b/packages/apps/job-launcher/server/src/modules/job/routing-protocol.service.spec.ts @@ -3,7 +3,6 @@ import { Test } from '@nestjs/testing'; import { RoutingProtocolService } from './routing-protocol.service'; import { NETWORKS } from '@human-protocol/sdk'; import { - MOCK_ADDRESS, MOCK_FILE_HASH, MOCK_FILE_KEY, MOCK_FILE_URL, @@ -12,9 +11,7 @@ import { jest.mock('@human-protocol/sdk', () => ({ ...jest.requireActual('@human-protocol/sdk'), EscrowClient: { - build: jest.fn().mockImplementation(() => ({ - createAndSetupEscrow: jest.fn().mockResolvedValue(MOCK_ADDRESS), - })), + build: jest.fn().mockImplementation(() => ({})), }, StorageClient: jest.fn().mockImplementation(() => ({ uploadFiles: jest diff --git a/packages/examples/cvat/recording-oracle/tests/integration/chain/test_escrow.py b/packages/examples/cvat/recording-oracle/tests/integration/chain/test_escrow.py index 2bcb156c87..86620df729 100644 --- a/packages/examples/cvat/recording-oracle/tests/integration/chain/test_escrow.py +++ b/packages/examples/cvat/recording-oracle/tests/integration/chain/test_escrow.py @@ -32,6 +32,7 @@ bulk_payout, create_escrow, fund_escrow, + setup_escrow, get_intermediate_results_url, ) @@ -51,6 +52,7 @@ def setUp(self): self.escrow_address = create_escrow(self.w3) fund_escrow(self.w3, self.escrow_address) + setup_escrow(self.w3, self.escrow_address) def escrow(self, status: str = "Pending", balance: float = amount): mock_escrow = MagicMock() @@ -79,6 +81,7 @@ def test_validate_escrow_without_funds(self): def test_validate_escrow_invalid_status(self): escrow_address = create_escrow(self.w3) fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) bulk_payout( self.w3, escrow_address, @@ -132,6 +135,8 @@ def test_get_encrypted_escrow_manifest(self): def test_store_results(self): escrow_address = create_escrow(self.w3) + fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) with patch("src.chain.escrow.get_web3") as mock_function: mock_function.return_value = self.w3 results = store_results( @@ -143,6 +148,8 @@ def test_store_results(self): def test_store_results_invalid_url(self): escrow_address = create_escrow(self.w3) + fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) with patch("src.chain.escrow.get_web3") as mock_function: mock_function.return_value = self.w3 with pytest.raises(EscrowClientError, match="Invalid URL: invalid_url"): @@ -150,6 +157,8 @@ def test_store_results_invalid_url(self): def test_store_results_invalid_hash(self): escrow_address = create_escrow(self.w3) + fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) with patch("src.chain.escrow.get_web3") as mock_function: mock_function.return_value = self.w3 with pytest.raises(EscrowClientError, match="Invalid empty hash"): diff --git a/packages/examples/cvat/recording-oracle/tests/integration/cron/test_process_exchange_oracle_webhooks.py b/packages/examples/cvat/recording-oracle/tests/integration/cron/test_process_exchange_oracle_webhooks.py index ab90d5cad2..6329ef4226 100644 --- a/packages/examples/cvat/recording-oracle/tests/integration/cron/test_process_exchange_oracle_webhooks.py +++ b/packages/examples/cvat/recording-oracle/tests/integration/cron/test_process_exchange_oracle_webhooks.py @@ -19,7 +19,7 @@ from src.services.webhook import OracleWebhookDirectionTags from tests.utils.constants import DEFAULT_GAS_PAYER_PRIV, SIGNATURE -from tests.utils.setup_escrow import create_escrow, fund_escrow +from tests.utils.setup_escrow import create_escrow, fund_escrow, setup_escrow class ServiceIntegrationTest(unittest.TestCase): @@ -52,6 +52,7 @@ def make_webhook(self, escrow_address): def test_process_exchange_oracle_webhook(self): escrow_address = create_escrow(self.w3) fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) webhook = self.make_webhook(escrow_address) self.session.add(webhook) @@ -111,6 +112,7 @@ def test_process_job_launcher_webhooks_invalid_manifest_url(self, mock_manifest_ mock_manifest_url.return_value = "invalid_url" escrow_address = create_escrow(self.w3) fund_escrow(self.w3, escrow_address) + setup_escrow(self.w3, self.escrow_address) webhook = self.make_webhook(escrow_address) diff --git a/packages/examples/cvat/recording-oracle/tests/utils/setup_escrow.py b/packages/examples/cvat/recording-oracle/tests/utils/setup_escrow.py index b840fbc44b..cf0f979532 100644 --- a/packages/examples/cvat/recording-oracle/tests/utils/setup_escrow.py +++ b/packages/examples/cvat/recording-oracle/tests/utils/setup_escrow.py @@ -25,10 +25,17 @@ def create_escrow(web3: Web3): escrow_client = EscrowClient(web3) staking_client.approve_stake(amount) staking_client.stake(amount) - return escrow_client.create_and_setup_escrow( + return escrow_client.create( token_address=NETWORKS[ChainId.LOCALHOST]["hmt_address"], trusted_handlers=[web3.eth.default_account], job_requester_id=JOB_REQUESTER_ID, + ) + + +def setup_escrow(web3: Web3, escrow_address: str): + escrow_client = EscrowClient(web3) + escrow_client.setup( + escrow_address=escrow_address, escrow_config=EscrowConfig( exchange_oracle_address=EXCHANGE_ORACLE_ADDRESS, exchange_oracle_fee=EXCHANGE_ORACLE_FEE, diff --git a/packages/sdk/python/human-protocol-sdk/README.md b/packages/sdk/python/human-protocol-sdk/README.md index f5698192a4..341347b7c5 100644 --- a/packages/sdk/python/human-protocol-sdk/README.md +++ b/packages/sdk/python/human-protocol-sdk/README.md @@ -137,16 +137,17 @@ escrow_config = EscrowConfig( ) ``` -Calling `create_and_setup_escrow`, the escrow can be created and set up as follows: +Calling `create`, the escrow can be created: ```python from human_protocol_sdk import EscrowClient escrow_client = EscrowClient(w3) -escrow_address = escrow_client.create_and_setup_escrow( +job_requester_id = 'job-requester' +escrow_address = escrow_client.create( token_address = "0x5FbDB2315678afecb367f032d93F642f64180aa3", trusted_handlers = ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"], - escrow_config = escrow_config + job_requester_id = job_requester_id ) ``` @@ -159,6 +160,18 @@ escrow_client.fund( ) ``` +Calling `setup`, the escrow can be setup: + +```python +from human_protocol_sdk import EscrowClient + +escrow_client = EscrowClient(w3) +escrow_client.setup( + escrow_address = escrow_address, + escrow_config = escrow_config +) +``` + While no payouts have been performed, aborting and canceling a job is still possible. ```python diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_client.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_client.py index bdeaf018f5..4b52c93a7b 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_client.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_client.py @@ -356,83 +356,6 @@ def get_w3_with_priv_key(priv_key: str): tx_options, ) - def create_and_setup_escrow( - self, - token_address: str, - trusted_handlers: List[str], - job_requester_id: str, - escrow_config: EscrowConfig, - amount: Decimal, - ) -> str: - """ - Creates and sets up an escrow. - - :param token_address: Token to use for pay outs - :param trusted_handlers: Array of addresses that can perform actions on the contract - :param job_requester_id: The id of the job requester - :param escrow_config: Object containing all the necessary information to setup an escrow - - :return: The address of the escrow created - - :raise EscrowClientError: If an error occurs while checking the parameters - - :example: - .. code-block:: python - - from eth_typing import URI - from web3 import Web3 - from web3.middleware import construct_sign_and_send_raw_middleware - from web3.providers.auto import load_provider_from_uri - - from human_protocol_sdk.escrow import EscrowClient - - def get_w3_with_priv_key(priv_key: str): - w3 = Web3(load_provider_from_uri(URI("http://localhost:8545"))) - gas_payer = w3.eth.account.from_key(priv_key) - w3.eth.default_account = gas_payer.address - w3.middleware_onion.add( - construct_sign_and_send_raw_middleware(gas_payer), - "construct_sign_and_send_raw_middleware", - ) - return (w3, gas_payer) - - (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY') - escrow_client = EscrowClient(w3) - - token_address = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4' - trusted_handlers = [ - '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', - '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' - ] - job_requester_id = 'job-requester' - escrow_config = EscrowConfig( - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - 10, - 10, - 10, - "htttp://localhost/manifest.json", - "b5dad76bf6772c0f07fd5e048f6e75a5f86ee079", - ) - amount = Web3.to_wei(5, 'ether') # convert from ETH to WEI - escrow_address = escrow_client.create_and_setup_escrow( - token_address, - trusted_handlers, - job_requester_id, - escrow_config, - amount - ) - """ - - escrow_address = self.create_escrow( - token_address, trusted_handlers, job_requester_id - ) - self.fund(escrow_address, amount) - self.setup(escrow_address, escrow_config) - - return escrow_address - def fund( self, escrow_address: str, diff --git a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/escrow/test_escrow_client.py b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/escrow/test_escrow_client.py index c3575ae5e2..4495a9ee00 100644 --- a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/escrow/test_escrow_client.py +++ b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/escrow/test_escrow_client.py @@ -622,153 +622,6 @@ def test_setup_with_tx_options(self): tx_options, ) - def test_create_and_setup_escrow(self): - mock_function_create = MagicMock() - self.escrow.factory_contract.functions.createEscrow = mock_function_create - token_address = "0x1234567890123456789012345678901234567890" - amount = 100 - self.escrow.get_token_address = MagicMock(return_value=token_address) - mock_contract = MagicMock() - mock_contract.functions.setup = MagicMock() - self.escrow._get_escrow_contract = MagicMock(return_value=mock_contract) - escrow_address = "0x1234567890123456789012345678901234567890" - token_address = "0x1234567890123456789012345678901234567890" - trusted_handlers = [self.w3.eth.default_account] - job_requester_id = "job-requester" - escrow_config = EscrowConfig( - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - 10, - 10, - 10, - "https://www.example.com/result", - "test", - ) - with patch( - "human_protocol_sdk.escrow.escrow_client.handle_transaction" - ) as mock_function: - with patch( - "human_protocol_sdk.escrow.escrow_client.next" - ) as mock_function_next: - mock_function_next.return_value = SimpleNamespace( - args=SimpleNamespace(escrow=escrow_address) - ) - response = self.escrow.create_and_setup_escrow( - token_address, - trusted_handlers, - job_requester_id, - escrow_config, - amount, - ) - - self.assertEqual(response, escrow_address) - mock_function_create.assert_called_once_with( - token_address, trusted_handlers, job_requester_id - ) - mock_function_next.assert_called_once() - - self.escrow.get_token_address.assert_called_once_with(escrow_address) - - mock_function.assert_any_call( - self.w3, - "Create Escrow", - mock_function_create.return_value, - EscrowClientError, - None, - ) - mock_function.assert_any_call( - self.w3, "Fund", ANY, EscrowClientError, None - ) - mock_function.assert_any_call( - self.w3, - "Setup", - mock_contract.functions.setup.return_value, - EscrowClientError, - None, - ) - - def test_create_and_setup_escrow_invalid_token(self): - self.escrow.setup = MagicMock() - token_address = "invalid_address" - trusted_handlers = [self.w3.eth.default_account] - job_requester_id = "job-requester" - escrow_config = EscrowConfig( - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - 10, - 10, - 10, - "https://www.example.com/result", - "test", - ) - amount = 100 - - with self.assertRaises(EscrowClientError) as cm: - self.escrow.create_and_setup_escrow( - token_address, trusted_handlers, job_requester_id, escrow_config, amount - ) - self.assertEqual(f"Invalid token address: {token_address}", str(cm.exception)) - self.escrow.setup.assert_not_called() - - def test_create_and_setup_escrow_invalid_handler(self): - self.escrow.setup = MagicMock() - token_address = "0x1234567890123456789012345678901234567890" - trusted_handlers = ["invalid_address"] - job_requester_id = "job-requester" - escrow_config = EscrowConfig( - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - 10, - 10, - 10, - "https://www.example.com/result", - "test", - ) - amount = 100 - - with self.assertRaises(EscrowClientError) as cm: - self.escrow.create_and_setup_escrow( - token_address, trusted_handlers, job_requester_id, escrow_config, amount - ) - self.assertEqual( - f"Invalid handler address: {trusted_handlers[0]}", str(cm.exception) - ) - self.escrow.setup.assert_not_called() - - def test_create_and_setup_escrow_without_account(self): - mock_provider = MagicMock(spec=HTTPProvider) - w3 = Web3(mock_provider) - mock_chain_id = ChainId.LOCALHOST.value - type(w3.eth).chain_id = PropertyMock(return_value=mock_chain_id) - - escrowClient = EscrowClient(w3) - - escrowClient.setup = MagicMock() - token_address = "0x1234567890123456789012345678901234567890" - trusted_handlers = ["0x1234567890123456789012345678901234567890"] - job_requester_id = "job-requester" - escrow_config = EscrowConfig( - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - "0x1234567890123456789012345678901234567890", - 10, - 10, - 10, - "https://www.example.com/result", - "test", - ) - amount = 100 - - with self.assertRaises(EscrowClientError) as cm: - escrowClient.create_and_setup_escrow( - token_address, trusted_handlers, job_requester_id, escrow_config, amount - ) - self.assertEqual("You must add an account to Web3 instance", str(cm.exception)) - escrowClient.setup.assert_not_called() - def test_fund(self): escrow_address = token_address = "0x1234567890123456789012345678901234567890" amount = 100 diff --git a/packages/sdk/typescript/human-protocol-sdk/src/escrow.ts b/packages/sdk/typescript/human-protocol-sdk/src/escrow.ts index 704178d674..a616ebca9b 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/escrow.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/escrow.ts @@ -377,79 +377,6 @@ export class EscrowClient extends BaseEthersClient { } } - /** - * This function creates and sets up an escrow. - * - * @param {string} tokenAddress Token address to use for pay outs. - * @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract. - * @param {string} jobRequesterId Job Requester Id - * @param {IEscrowConfig} escrowConfig Configuration object with escrow settings. - * @returns {Promise} Returns the address of the escrow created. - * - * - * **Code example** - * - * ```ts - * import { ethers, Wallet, providers } from 'ethers'; - * import { EscrowClient } from '@human-protocol/sdk'; - * - * const rpcUrl = 'YOUR_RPC_URL'; - * const privateKey = 'YOUR_PRIVATE_KEY' - * - * const provider = new providers.JsonRpcProvider(rpcUrl); - * const signer = new Wallet(privateKey, provider); - * const escrowClient = await EscrowClient.build(signer); - * - * const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4'; - * const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266']; - * const jobRequesterId = "job-requester-id"; - * - * const escrowConfig = { - * recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', - * reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', - * exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', - * recordingOracleFee: bigint.from('10'), - * reputationOracleFee: bigint.from('10'), - * exchangeOracleFee: bigint.from('10'), - * manifestUrl: 'htttp://localhost/manifest.json', - * manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079', - * }; - * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI - * - * const escrowAddress = await escrowClient.createAndSetupEscrow( - * tokenAddress, - * trustedHandlers, - * jobRequesterId, - * escrowConfig, - * amount - * ); - * ``` - */ - @requiresSigner - async createAndSetupEscrow( - tokenAddress: string, - trustedHandlers: string[], - jobRequesterId: string, - escrowConfig: IEscrowConfig, - amount: bigint - ): Promise { - try { - const escrowAddress = await this.createEscrow( - tokenAddress, - trustedHandlers, - jobRequesterId - ); - - await this.fund(escrowAddress, amount); - - await this.setup(escrowAddress, escrowConfig); - - return escrowAddress; - } catch (e) { - return throwError(e); - } - } - /** * This function adds funds of the chosen token to the escrow. * diff --git a/packages/sdk/typescript/human-protocol-sdk/test/escrow.test.ts b/packages/sdk/typescript/human-protocol-sdk/test/escrow.test.ts index e6396a61bf..b5d61f4c4b 100644 --- a/packages/sdk/typescript/human-protocol-sdk/test/escrow.test.ts +++ b/packages/sdk/typescript/human-protocol-sdk/test/escrow.test.ts @@ -72,7 +72,6 @@ describe('EscrowClient', () => { mockEscrowContract = { createEscrow: vi.fn(), setup: vi.fn(), - createAndSetupEscrow: vi.fn(), fund: vi.fn(), storeResults: vi.fn(), complete: vi.fn(), @@ -606,114 +605,6 @@ describe('EscrowClient', () => { }); }); - describe('createAndSetupEscrow', () => { - test('should successfully create and setup escrow', async () => { - const escrowAddress = ethers.ZeroAddress; - const tokenAddress = ethers.ZeroAddress; - const trustedHandlers = [ethers.ZeroAddress]; - const jobRequesterId = 'job-requester'; - - const escrowConfig = { - recordingOracle: ethers.ZeroAddress, - reputationOracle: ethers.ZeroAddress, - exchangeOracle: ethers.ZeroAddress, - recordingOracleFee: 10n, - reputationOracleFee: 10n, - exchangeOracleFee: 10n, - manifestUrl: VALID_URL, - manifestHash: FAKE_HASH, - }; - - escrowClient.escrowFactoryContract.hasEscrow.mockReturnValue(true); - escrowClient.createEscrow = vi.fn().mockReturnValue(escrowAddress); - escrowClient.fund = vi.fn().mockResolvedValue(true); - const setupSpy = vi - .spyOn(escrowClient.escrowContract, 'setup') - .mockImplementation(() => ({ - wait: vi.fn().mockResolvedValue(true), - })); - - await escrowClient.createAndSetupEscrow( - tokenAddress, - trustedHandlers, - jobRequesterId, - escrowConfig, - 30n - ); - - expect(escrowClient.createEscrow).toHaveBeenCalledWith( - tokenAddress, - trustedHandlers, - jobRequesterId - ); - expect(escrowClient.fund).toHaveBeenCalledWith(escrowAddress, 30n); - expect(setupSpy).toHaveBeenCalledWith( - ethers.ZeroAddress, - ethers.ZeroAddress, - ethers.ZeroAddress, - 10n, - 10n, - 10n, - VALID_URL, - FAKE_HASH, - {} - ); - }); - - test('should throw an error if setup escrow fails', async () => { - const escrowConfig = { - recordingOracle: ethers.ZeroAddress, - reputationOracle: ethers.ZeroAddress, - exchangeOracle: ethers.ZeroAddress, - recordingOracleFee: 10n, - reputationOracleFee: 10n, - exchangeOracleFee: 10n, - manifestUrl: VALID_URL, - manifestHash: FAKE_HASH, - }; - - escrowClient.escrowFactoryContract.hasEscrow.mockReturnValue(true); - escrowClient.fund = vi.fn().mockResolvedValue(true); - escrowClient.escrowContract.setup.mockRejectedValueOnce(new Error()); - - await expect( - escrowClient.setup(ethers.ZeroAddress, escrowConfig) - ).rejects.toThrow(); - - expect(escrowClient.escrowContract.setup).toHaveBeenCalledWith( - ethers.ZeroAddress, - ethers.ZeroAddress, - ethers.ZeroAddress, - 10n, - 10n, - 10n, - VALID_URL, - FAKE_HASH, - {} - ); - }); - - test('should thorw an error if the amount is not specified', async () => { - const escrowAddress = ethers.ZeroAddress; - const tokenAddress = ethers.ZeroAddress; - const trustedHandlers = [ethers.ZeroAddress]; - const jobRequesterId = 'job-requester'; - - escrowClient.escrowFactoryContract.hasEscrow.mockReturnValue(true); - escrowClient.createEscrow = vi.fn().mockReturnValue(escrowAddress); - - await expect( - escrowClient.createAndSetupEscrow( - tokenAddress, - trustedHandlers, - jobRequesterId, - {}, - 0 - ) - ).rejects.toThrow(); - }); - }); - describe('fund', () => { test('should throw an error if escrowAddress is an invalid address', async () => { const invalidAddress = FAKE_ADDRESS;