diff options
author | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-10-27 03:13:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-27 03:13:42 +0800 |
commit | af91a56a5594d07d7da6caaeff79f5a7fb31ff98 (patch) | |
tree | 03d76693036b6acd5e336aa5156e0f69b9fa3fe0 /python-packages/order_utils/test | |
parent | 0f6307169604f36b0316f236eb96d6001b788f50 (diff) | |
download | dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar.gz dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar.bz2 dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar.lz dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar.xz dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.tar.zst dexon-sol-tools-af91a56a5594d07d7da6caaeff79f5a7fb31ff98.zip |
feat(order_utils.py): ERC721 asset data codec (#1186)
Diffstat (limited to 'python-packages/order_utils/test')
-rw-r--r-- | python-packages/order_utils/test/test_asset_data_utils.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/python-packages/order_utils/test/test_asset_data_utils.py b/python-packages/order_utils/test/test_asset_data_utils.py index eeada5873..079368714 100644 --- a/python-packages/order_utils/test/test_asset_data_utils.py +++ b/python-packages/order_utils/test/test_asset_data_utils.py @@ -3,9 +3,12 @@ import pytest from zero_ex.order_utils.asset_data_utils import ( - encode_erc20_asset_data, decode_erc20_asset_data, + decode_erc721_asset_data, + encode_erc20_asset_data, + encode_erc721_asset_data, ERC20_ASSET_DATA_BYTE_LENGTH, + ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH, ) @@ -33,3 +36,37 @@ def test_decode_erc20_asset_data_invalid_proxy_id(): decode_erc20_asset_data( "0xffffffff" + (" " * ERC20_ASSET_DATA_BYTE_LENGTH) ) + + +def test_encode_erc721_asset_data_type_error_on_token_address(): + """Test that passing a non-string for token_address raises a TypeError.""" + with pytest.raises(TypeError): + encode_erc721_asset_data(123, 123) + + +def test_encode_erc721_asset_data_type_error_on_token_id(): + """Test that passing a non-int for token_id raises a TypeError.""" + with pytest.raises(TypeError): + encode_erc721_asset_data("asdf", "asdf") + + +def test_decode_erc721_asset_data_type_error(): + """Test that passing a non-string for asset_data raises a TypeError.""" + with pytest.raises(TypeError): + decode_erc721_asset_data(123) + + +def test_decode_erc721_asset_data_with_asset_data_too_short(): + """Test that passing in too short of a string raises a ValueError.""" + with pytest.raises(ValueError): + decode_erc721_asset_data( + " " * (ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH - 1) + ) + + +def test_decode_erc721_asset_data_invalid_proxy_id(): + """Test that passing in too short of a string raises a ValueError.""" + with pytest.raises(ValueError): + decode_erc721_asset_data( + "0xffffffff" + " " * (ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH - 1) + ) |