Skip to content

Commit 2325e1a

Browse files
Checksum client wallet address
1 parent 379d207 commit 2325e1a

3 files changed

Lines changed: 51 additions & 52 deletions

File tree

tests/integration/test_client_integration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_should_filter_out_self(self, acp_client):
5858

5959
# Verify none of the agents are the client itself
6060
for agent in agents:
61-
assert agent.wallet_address.lower() != acp_client.agent_address.lower()
61+
assert agent.wallet_address.lower() != acp_client.wallet_address.lower()
6262

6363
def test_should_respect_top_k_parameter(self, acp_client):
6464
"""Should respect the top_k parameter for result limiting"""
@@ -92,12 +92,12 @@ class TestGetAgent:
9292

9393
def test_should_get_own_agent_info(self, acp_client):
9494
"""Should successfully retrieve own agent information"""
95-
agent = acp_client.get_agent(acp_client.agent_address)
95+
agent = acp_client.get_agent(acp_client.wallet_address)
9696

9797
# Should return the agent or None
9898
# If the agent exists
9999
if agent:
100-
assert agent.wallet_address.lower() == acp_client.agent_address.lower()
100+
assert agent.wallet_address.lower() == acp_client.wallet_address.lower()
101101
assert hasattr(agent, 'id')
102102
assert hasattr(agent, 'job_offerings')
103103
assert hasattr(agent, 'name')
@@ -161,7 +161,7 @@ def test_get_by_client_and_provider_should_handle_no_account(self, acp_client):
161161
fake_provider = "0x0000000000000000000000000000000000000001"
162162

163163
account = acp_client.get_by_client_and_provider(
164-
acp_client.agent_address,
164+
acp_client.wallet_address,
165165
fake_provider
166166
)
167167

tests/unit/test_client.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ def test_should_raise_error_when_provider_is_self(self, acp_client, mock_fare_am
10021002
"""Should raise ACPError when provider address is same as client"""
10031003
with pytest.raises(ACPError, match="Provider address cannot be the same as the client address"):
10041004
acp_client.initiate_job(
1005-
provider_address=acp_client.agent_address,
1005+
provider_address=acp_client.wallet_address,
10061006
service_requirement={"task": "test"},
10071007
fare_amount=mock_fare_amount
10081008
)
@@ -1017,12 +1017,12 @@ def test_should_use_create_job_when_no_account_exists(
10171017

10181018
# Mock contract client methods
10191019
mock_create_op = MagicMock()
1020-
acp_client.contract_client.create_job = MagicMock(return_value=mock_create_op)
1021-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1022-
acp_client.contract_client.get_job_id = MagicMock(return_value=42)
1020+
acp_client.acp_contract_client.create_job = MagicMock(return_value=mock_create_op)
1021+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1022+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=42)
10231023

10241024
mock_memo_op = MagicMock()
1025-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1025+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
10261026

10271027
job_id = acp_client.initiate_job(
10281028
provider_address=TEST_PROVIDER_ADDRESS,
@@ -1031,7 +1031,7 @@ def test_should_use_create_job_when_no_account_exists(
10311031
)
10321032

10331033
# Verify create_job was called (not create_job_with_account)
1034-
acp_client.contract_client.create_job.assert_called_once()
1034+
acp_client.acp_contract_client.create_job.assert_called_once()
10351035
assert job_id == 42
10361036

10371037
@patch('virtuals_acp.client.VirtualsACP.get_by_client_and_provider')
@@ -1046,15 +1046,15 @@ def test_should_use_create_job_with_account_when_account_exists(
10461046

10471047
# Mock contract client methods
10481048
mock_create_op = MagicMock()
1049-
acp_client.contract_client.create_job_with_account = MagicMock(return_value=mock_create_op)
1050-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1051-
acp_client.contract_client.get_job_id = MagicMock(return_value=43)
1049+
acp_client.acp_contract_client.create_job_with_account = MagicMock(return_value=mock_create_op)
1050+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1051+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=43)
10521052

10531053
mock_memo_op = MagicMock()
1054-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1054+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
10551055

10561056
# Set config to NOT be a base contract (to trigger account path)
1057-
acp_client.contract_client.config.contract_address = "0xCustomContract123456789012345678901234567"
1057+
acp_client.acp_contract_client.config.contract_address = "0xCustomContract123456789012345678901234567"
10581058

10591059
job_id = acp_client.initiate_job(
10601060
provider_address=TEST_PROVIDER_ADDRESS,
@@ -1063,8 +1063,8 @@ def test_should_use_create_job_with_account_when_account_exists(
10631063
)
10641064

10651065
# Verify create_job_with_account was called with account ID
1066-
acp_client.contract_client.create_job_with_account.assert_called_once()
1067-
call_args = acp_client.contract_client.create_job_with_account.call_args[0]
1066+
acp_client.acp_contract_client.create_job_with_account.assert_called_once()
1067+
call_args = acp_client.acp_contract_client.create_job_with_account.call_args[0]
10681068
assert call_args[0] == 5 # account.id
10691069
assert job_id == 43
10701070

@@ -1076,12 +1076,12 @@ def test_should_convert_dict_requirement_to_json(
10761076
mock_get_account.return_value = None
10771077

10781078
mock_create_op = MagicMock()
1079-
acp_client.contract_client.create_job = MagicMock(return_value=mock_create_op)
1080-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1081-
acp_client.contract_client.get_job_id = MagicMock(return_value=44)
1079+
acp_client.acp_contract_client.create_job = MagicMock(return_value=mock_create_op)
1080+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1081+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=44)
10821082

10831083
mock_memo_op = MagicMock()
1084-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1084+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
10851085

10861086
requirement_dict = {"task": "translate", "language": "spanish"}
10871087

@@ -1092,8 +1092,8 @@ def test_should_convert_dict_requirement_to_json(
10921092
)
10931093

10941094
# Verify create_memo was called with JSON string
1095-
acp_client.contract_client.create_memo.assert_called_once()
1096-
call_args = acp_client.contract_client.create_memo.call_args[0]
1095+
acp_client.acp_contract_client.create_memo.assert_called_once()
1096+
call_args = acp_client.acp_contract_client.create_memo.call_args[0]
10971097

10981098
# The second argument should be the JSON-stringified requirement
10991099
import json
@@ -1107,12 +1107,12 @@ def test_should_use_string_requirement_as_is(
11071107
mock_get_account.return_value = None
11081108

11091109
mock_create_op = MagicMock()
1110-
acp_client.contract_client.create_job = MagicMock(return_value=mock_create_op)
1111-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1112-
acp_client.contract_client.get_job_id = MagicMock(return_value=45)
1110+
acp_client.acp_contract_client.create_job = MagicMock(return_value=mock_create_op)
1111+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1112+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=45)
11131113

11141114
mock_memo_op = MagicMock()
1115-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1115+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
11161116

11171117
requirement_str = "Please translate this document"
11181118

@@ -1123,8 +1123,8 @@ def test_should_use_string_requirement_as_is(
11231123
)
11241124

11251125
# Verify create_memo was called with the string as-is
1126-
acp_client.contract_client.create_memo.assert_called_once()
1127-
call_args = acp_client.contract_client.create_memo.call_args[0]
1126+
acp_client.acp_contract_client.create_memo.assert_called_once()
1127+
call_args = acp_client.acp_contract_client.create_memo.call_args[0]
11281128
assert call_args[1] == requirement_str
11291129

11301130
@patch('virtuals_acp.client.VirtualsACP.get_by_client_and_provider')
@@ -1137,12 +1137,12 @@ def test_should_use_default_expiry_if_not_provided(
11371137
mock_get_account.return_value = None
11381138

11391139
mock_create_op = MagicMock()
1140-
acp_client.contract_client.create_job = MagicMock(return_value=mock_create_op)
1141-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1142-
acp_client.contract_client.get_job_id = MagicMock(return_value=46)
1140+
acp_client.acp_contract_client.create_job = MagicMock(return_value=mock_create_op)
1141+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1142+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=46)
11431143

11441144
mock_memo_op = MagicMock()
1145-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1145+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
11461146

11471147
before = datetime.now(timezone.utc) + timedelta(days=1)
11481148

@@ -1156,8 +1156,8 @@ def test_should_use_default_expiry_if_not_provided(
11561156
after = datetime.now(timezone.utc) + timedelta(days=1)
11571157

11581158
# Verify create_job was called with an expiry around 1 day from now
1159-
acp_client.contract_client.create_job.assert_called_once()
1160-
call_args = acp_client.contract_client.create_job.call_args[0]
1159+
acp_client.acp_contract_client.create_job.assert_called_once()
1160+
call_args = acp_client.acp_contract_client.create_job.call_args[0]
11611161
expired_at = call_args[2] # Third argument is expired_at
11621162

11631163
# Should be within a few seconds of 1 day from now
@@ -1171,12 +1171,12 @@ def test_should_use_custom_evaluator_address(
11711171
mock_get_account.return_value = None
11721172

11731173
mock_create_op = MagicMock()
1174-
acp_client.contract_client.create_job = MagicMock(return_value=mock_create_op)
1175-
acp_client.contract_client.handle_operation = MagicMock(return_value="tx_response")
1176-
acp_client.contract_client.get_job_id = MagicMock(return_value=47)
1174+
acp_client.acp_contract_client.create_job = MagicMock(return_value=mock_create_op)
1175+
acp_client.acp_contract_client.handle_operation = MagicMock(return_value="tx_response")
1176+
acp_client.acp_contract_client.get_job_id = MagicMock(return_value=47)
11771177

11781178
mock_memo_op = MagicMock()
1179-
acp_client.contract_client.create_memo = MagicMock(return_value=mock_memo_op)
1179+
acp_client.acp_contract_client.create_memo = MagicMock(return_value=mock_memo_op)
11801180

11811181
custom_evaluator = "0x7777777777777777777777777777777777777777"
11821182

@@ -1188,8 +1188,8 @@ def test_should_use_custom_evaluator_address(
11881188
)
11891189

11901190
# Verify create_job was called with custom evaluator
1191-
acp_client.contract_client.create_job.assert_called_once()
1192-
call_args = acp_client.contract_client.create_job.call_args[0]
1191+
acp_client.acp_contract_client.create_job.assert_called_once()
1192+
call_args = acp_client.acp_contract_client.create_job.call_args[0]
11931193

11941194
# Second argument is evaluator address
11951195
from web3 import Web3

virtuals_acp/client.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ def acp_contract_client(self):
224224
@property
225225
def wallet_address(self):
226226
"""Get the wallet address from the first contract client."""
227-
# return Web3.to_checksum_address(self.acp_contract_client.agent_wallet_address)
228-
return self.acp_contract_client.agent_wallet_address
227+
return Web3.to_checksum_address(self.acp_contract_client.agent_wallet_address)
229228

230229
@property
231230
def acp_url(self):
@@ -494,8 +493,8 @@ def browse_agents(
494493
if top_k:
495494
url += f"&top_k={top_k}"
496495

497-
if self.agent_address:
498-
url += f"&walletAddressesToExclude={self.agent_address}"
496+
if self.wallet_address:
497+
url += f"&walletAddressesToExclude={self.wallet_address}"
499498

500499
if cluster:
501500
url += f"&cluster={cluster}"
@@ -525,7 +524,7 @@ def browse_agents(
525524
filtered_agents = [
526525
agent
527526
for agent in agents_data
528-
if agent["walletAddress"].lower() != self.agent_address.lower()
527+
if agent["walletAddress"].lower() != self.wallet_address.lower()
529528
and agent.get("contractAddress", "").lower()
530529
in available_contract_addresses
531530
]
@@ -555,18 +554,18 @@ def initiate_job(
555554
if expired_at is None:
556555
expired_at = datetime.now(timezone.utc) + timedelta(days=1)
557556

558-
if provider_address == self.agent_address:
557+
if provider_address == self.wallet_address:
559558
raise ACPError("Provider address cannot be the same as the client address")
560559

561560
eval_addr = (
562561
Web3.to_checksum_address(evaluator_address)
563562
if evaluator_address
564-
else self.agent_address
563+
else self.wallet_address
565564
)
566565

567566
# Lookup existing account between client and provider
568567
account = self.get_by_client_and_provider(
569-
self.agent_address, provider_address, self.acp_contract_client
568+
self.wallet_address, provider_address, self.acp_contract_client
570569
)
571570

572571
# Determine whether to call createJob or createJobWithAccount
@@ -611,7 +610,7 @@ def initiate_job(
611610
response = self.acp_contract_client.handle_operation([create_job_operation])
612611

613612
job_id = self.acp_contract_client.get_job_id(
614-
response, self.agent_address, provider_address
613+
response, self.wallet_address, provider_address
615614
)
616615

617616
operations = self.acp_contract_client.create_memo(
@@ -828,7 +827,7 @@ def _hydrate_jobs(
828827

829828
def get_job_by_onchain_id(self, onchain_job_id: int) -> "ACPJob":
830829
url = f"{self.acp_url}/jobs/{onchain_job_id}"
831-
headers = {"wallet-address": self.agent_address}
830+
headers = {"wallet-address": self.wallet_address}
832831

833832
try:
834833
response = requests.get(url, headers=headers)
@@ -888,7 +887,7 @@ def get_job_by_onchain_id(self, onchain_job_id: int) -> "ACPJob":
888887

889888
def get_memo_by_id(self, onchain_job_id: int, memo_id: int) -> "ACPMemo":
890889
url = f"{self.acp_url}/jobs/{onchain_job_id}/memos/{memo_id}"
891-
headers = {"wallet-address": self.agent_address}
890+
headers = {"wallet-address": self.wallet_address}
892891

893892
try:
894893
response = requests.get(url, headers=headers)

0 commit comments

Comments
 (0)