Пример #1
0
def bytes32(val):
    if isinstance(val, int):
        result = Webu.toBytes(val)
    else:
        raise TypeError('val %r could not be converted to bytes')
    if len(result) < 32:
        return result.rjust(32, b'\0')
    else:
        return result
Пример #2
0
def test_set_address(ens, name, full_name, namehash_hex):
    assert ens.address(name) is None
    owner = ens.owner('tester')

    ens.setup_address(name, TEST_ADDRESS)
    assert ens.address(name) == TEST_ADDRESS

    # check that .eth is only appended if guess_tld is True
    namehash = Webu.toBytes(hexstr=namehash_hex)
    normal_name = ens.nameprep(full_name)
    if ens.nameprep(name) == normal_name:
        assert ens.address(name, guess_tld=False) == TEST_ADDRESS
    else:
        assert ens.address(name, guess_tld=False) is None

    # check that the correct namehash is set:
    assert ens.resolver(normal_name).addr(namehash) == TEST_ADDRESS

    # check that the correct owner is set:
    assert ens.owner(name) == owner

    ens.setup_address(name, None)
    assert ens.address(name) is None
Пример #3
0
def test_setup_name(ens, name, normalized_name, namehash_hex):
    address = ens.webu.eth.accounts[3]
    assert not ens.name(address)
    owner = ens.owner('tester')

    ens.setup_name(name, address)
    assert ens.name(address) == normalized_name

    # check that .eth is only appended if guess_tld is True
    if ens.nameprep(name) != normalized_name:
        assert ens.address(name, guess_tld=False) is None

    # check that the correct namehash is set:
    node = Webu.toBytes(hexstr=namehash_hex)
    assert ens.resolver(normalized_name).addr(node) == address

    # check that the correct owner is set:
    assert ens.owner(name) == owner

    ens.setup_name(None, address)
    ens.setup_address(name, None)
    assert not ens.name(address)
    assert not ens.address(name)
Пример #4
0
def test_to_bytes_text(val, expected):
    assert Webu.toBytes(text=val) == expected
Пример #5
0
def test_to_bytes_hexstr(val, expected):
    assert Webu.toBytes(hexstr=val) == expected
Пример #6
0
def test_to_bytes_primitive(val, expected):
    assert Webu.toBytes(val) == expected