File: test_codec.py

package info (click to toggle)
pyrlp 0.5.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 380 kB
  • sloc: python: 1,715; makefile: 221; sh: 16
file content (21 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest
import rlp

def test_compare_length():
    data = rlp.encode([1,2,3,4,5])
    assert rlp.compare_length(data, 100) == -1
    assert rlp.compare_length(data, 5) == 0
    assert rlp.compare_length(data, 1) == 1

    data = rlp.encode([])
    assert rlp.compare_length(data, 100) == -1
    assert rlp.compare_length(data, 0) == 0
    assert rlp.compare_length(data, -1) == 1

def test_favor_short_string_form():
    data = rlp.utils.decode_hex('b8056d6f6f7365')
    with pytest.raises(rlp.exceptions.DecodingError):
        rlp.decode(data)

    data = rlp.utils.decode_hex('856d6f6f7365')
    assert rlp.decode(data) == b'moose'