1
0
pbcabi/test/test_address.py

20 lines
759 B
Python
Raw Normal View History

2024-05-03 08:18:54 +00:00
import pytest
from pathlib import Path
from pbcabi.binaryreader import BinaryReader
import pbcabi.model
from pbcabi.data import BlockchainAddress
EXAMPLE_SHARDS = [
("Shard1", 2, "000000000000000000000000000000000000000001"),
("Shard0", 2, "000000000000000000000000000000000000000002"),
("Shard0", 3, "025FA781D389D7C7CAAF836E5E47ABED6CEFD2D928"),
("Shard1", 3, "04FE17D1009372C8ED3AC5B790B32E349359C2C7E9"),
("Shard0", 3, "01A2020BB33EF9E0323C7A3210D5CB7FD492AA0D65"),
]
@pytest.mark.parametrize('shard_id,num_shards,address', EXAMPLE_SHARDS)
def test_parse_abi(shard_id: int, num_shards:int, address: str):
address = BlockchainAddress.from_hex_hash(address)
assert address.shard_id(num_shards) == shard_id