diff --git a/python-packages/contract_demo/test/test_exchange.py b/python-packages/contract_demo/test/test_exchange.py index 07492a4030..e47fcc78fd 100644 --- a/python-packages/contract_demo/test/test_exchange.py +++ b/python-packages/contract_demo/test/test_exchange.py @@ -63,3 +63,55 @@ def test_get_order_info(): assert isinstance(order_info.order_taker_asset_filled_amount, int) assert order_info.order_taker_asset_filled_amount == 0 + + +def test_get_orders_info(): + """Demonstrate Exchange.getOrderInfo().""" + order: Order = { + "makerAddress": "0x0000000000000000000000000000000000000000", + "takerAddress": "0x0000000000000000000000000000000000000000", + "feeRecipientAddress": "0x0000000000000000000000000000000000000000", + "senderAddress": "0x0000000000000000000000000000000000000000", + "makerAssetAmount": 1000000000000000000, + "takerAssetAmount": 1000000000000000000, + "makerFee": 0, + "takerFee": 0, + "expirationTimeSeconds": 12345, + "salt": 12345, + "makerAssetData": (b"\x00") * 20, + "takerAssetData": (b"\x00") * 20, + } + + web3_instance = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) + + # false positive from pylint: disable=no-member + contract_address = NETWORK_TO_ADDRESSES[ + NetworkId(int(web3_instance.net.version)) + ].exchange + + assert_valid( + order_to_jsdict(order, exchange_address=contract_address), + "/orderSchema", + ) + + # false positive from pylint: disable=no-member + exchange: datatypes.Contract = web3_instance.eth.contract( + address=to_checksum_address(contract_address), + abi=zero_ex.contract_artifacts.abi_by_name("Exchange"), + ) + + orders_info = exchange.call().getOrdersInfo([order]) + + for order_info in orders_info: + order_info = OrderInfo(*order_info) + assert isinstance(order_info.order_status, int) + assert order_info.order_status == 4 + + assert isinstance(order_info.order_hash, bytes) + assert order_info.order_hash.hex() == generate_order_hash_hex( + order, + exchange_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange, + ) + + assert isinstance(order_info.order_taker_asset_filled_amount, int) + assert order_info.order_taker_asset_filled_amount == 0 diff --git a/python-packages/order_utils/setup.py b/python-packages/order_utils/setup.py index 6f94656805..fc361c23b7 100755 --- a/python-packages/order_utils/setup.py +++ b/python-packages/order_utils/setup.py @@ -168,12 +168,12 @@ def run(self): "0x-contract-addresses", "0x-contract-artifacts", "0x-json-schemas", + "0x-web3", "eth-abi", "eth_utils", "hypothesis>=3.31.2", # HACK! this is web3's dependency! # above works around https://github.com/ethereum/web3.py/issues/1179 "mypy_extensions", - "web3", ], extras_require={ "dev": [