Skip to content

Commit

Permalink
Merge pull request #6 from 8ball030/fix-tests
Browse files Browse the repository at this point in the history
fix tests with proper api
  • Loading branch information
kjr217 authored May 8, 2024
2 parents 90b342b + 0ae34e8 commit 0a55d2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions hundred_x/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
DEVNET_REST_URL = "https://api.dev.ciaobella.dev"
DEVNET_WEBSOCKET_URL = "https://stream.dev.ciaobella.dev"

TESTNET_REST_URL = "https://staging.100x.finance"
TESTNET_WEBSOCKET_URL = "https://staging.100x.finance"
TESTNET_REST_URL = "https://api.staging.100x.finance"
TESTNET_WEBSOCKET_URL = "https://stream.staging.100x.finance"

MAINNET_REST_URL = "https://api.100x.finance"
MAINNET_WEBSOCKET_URL = "https://stream.100x.finance"
Expand All @@ -35,14 +35,14 @@
CONTRACTS = {
Environment.TESTNET: {
"USDB": "0x79A59c326C715AC2d31C169C85d1232319E341ce",
"PROTOCOL": "0x63bD0ca355Cfc117F5176E5eF3e34A6D60081937",
"VERIFYING_CONTRACT": "0x65CbB566D1A6E60107c0c7888761de1AdFa1ccC0",
"PROTOCOL": "0x0c3b9472b3923CfE199bAE24B5f5bD75FAD2bae9",
"VERIFYING_CONTRACT": "0x02Ca4fcB63E2D3C89fa20D86ccDcfc540c683545",
"CHAIN_ID": 168587773,
},
Environment.DEVNET: {
"USDB": "0x79A59c326C715AC2d31C169C85d1232319E341ce",
"PROTOCOL": "0x2c72Fbefcc6D23553EC4E209E7b23E118718a239",
"VERIFYING_CONTRACT": "0xFA322Cd45159384132C3D191618556349bA3bF53",
"PROTOCOL": "0x9E4d21FeFE19EbD9ce94b71A60bce6CD793DD2BF",
"VERIFYING_CONTRACT": "0x8ffdD4755aa383cD4CB715ABD8e1375926123729",
"CHAIN_ID": 168587773,
},
}
18 changes: 9 additions & 9 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TEST_PRIVATE_KEY = "0x8f58e47491ac5fe6897216208fe1fed316d6ee89de6c901bfc521c2178ebe6dd"
TEST_ADDRESS = "0xEEF7faba495b4875d67E3ED8FB3a32433d3DB3b3"
TEST_ORDER = {
"subaccount_id": 0,
"subaccount_id": 1,
"product_id": 1002,
"quantity": 1,
"price": 3000,
Expand All @@ -36,7 +36,7 @@ def setUp(self):
"""
Set up the Client class tests.
"""
self.client = HundredXClient(env=self.environment, private_key=TEST_PRIVATE_KEY)
self.client = HundredXClient(env=self.environment, private_key=TEST_PRIVATE_KEY, subaccount_id=1)

def test_client_init(
self,
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_deposit(
Test the deposit method of the Client class.
"""
self.client.login()
deposit = self.client.deposit(subaccount_id=0, quantity=100)
deposit = self.client.deposit(subaccount_id=1, quantity=100)
assert deposit is not None

def test_withdraw(
Expand All @@ -215,7 +215,7 @@ def test_withdraw(
Test the withdraw method of the Client class.
"""
self.client.login()
withdraw = self.client.withdraw(subaccount_id=0, quantity=100)
withdraw = self.client.withdraw(subaccount_id=1, quantity=100)
assert withdraw is not None

def test_withdraw_signature(
Expand All @@ -229,12 +229,12 @@ def test_withdraw_signature(
message_class=Withdraw,
quantity=int(100 * 10**18),
nonce=self.client._current_timestamp(),
**self.client.get_shared_params(subaccount_id=0, asset="USDB"),
**self.client.get_shared_params(subaccount_id=1, asset="USDB"),
)

assert (
withdrawal_message["signature"]
== "0x334a617170bd712c183ac1765bd207da6a029d9203eb5cda87fa3900b98713f86dc63d53318200ce9d889021743d84df6d41d352d452ec9370f1ef4f1a2a01141b" # noqa: E501
== "0x7e943abf014646836b59d2dcf120e533f5843fc7033c95b030184c6b2b062dfe37c1bdf6b7cec4d722cc75cd6bd36eadcb91868e2cc50fd974de92ce784a47531b" # noqa: E501
)

def test_order(
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_order_signature(self):

assert (
order_message["signature"]
== "0x5b236ae32e38833cbb594cf3a98342678fe13503578574b45c8e03543445d40a26046ecda4cdf373f50ffcc01781b818ee96394d8112aebc0906520f9e31d9c71b" # noqa: E501
== "0x4f686289d48c53017c94f554d5bc626aad44ccec5e2dc244bc7f8fe753aa40ab1151c35e88e74abca2a49ce191b03c424f89e8dfe6c34ee235ee60ad10151e7d1b" # noqa: E501
)

def test_cancel_order(
Expand All @@ -300,7 +300,7 @@ def test_cancel_orders(self):
**TEST_ORDER,
)
assert order is not None
cancel_order = self.client.cancel_all_orders(subaccount_id=0, product_id=1002)
cancel_order = self.client.cancel_all_orders(subaccount_id=1, product_id=1002)
assert cancel_order is not None

@pytest.mark.skip(reason="This test is not working, the endpoint fails with 400 response.")
Expand Down Expand Up @@ -330,4 +330,4 @@ def setUp(self):
"""
Set up the Client class tests.
"""
self.client = HundredXClient(env=self.environment, private_key=TEST_PRIVATE_KEY)
self.client = HundredXClient(env=self.environment, private_key=TEST_PRIVATE_KEY, subaccount_id=1)

0 comments on commit 0a55d2f

Please sign in to comment.