@@ -20,6 +20,7 @@ def test_abi_encode_signed_int():
20
20
assert abi .decode_abi (['int8' ], abi .encode_abi (['int8' ], [1 ]))[0 ] == 1
21
21
assert abi .decode_abi (['int8' ], abi .encode_abi (['int8' ], [- 1 ]))[0 ] == - 1
22
22
23
+
23
24
def test_abi_encode_single_int ():
24
25
assert abi .encode_single (['int' , '256' , []], - 2 ** 255 ) == (b'\x80 ' + b'\x00 ' * 31 )
25
26
assert abi .encode_single (['int' , '256' , []], (b'\x80 ' + b'\x00 ' * 31 )) == (b'\x80 ' + b'\x00 ' * 31 )
@@ -32,34 +33,49 @@ def test_abi_encode_single_int():
32
33
with pytest .raises (abi .ValueOutOfBounds ):
33
34
assert abi .encode_single (['int' , '8' , []], 128 )
34
35
36
+
35
37
def test_abi_encode_single_ureal ():
36
38
assert abi .encode_single (['ureal' , '128x128' , []], 0 ) == (b'\x00 ' * 32 )
37
39
assert abi .encode_single (['ureal' , '128x128' , []], 1.125 ) == (b'\x00 ' * 15 + b'\x01 \x20 ' + '\x00 ' * 15 )
38
40
assert abi .encode_single (['ureal' , '128x128' , []], 2 ** 127 - 1 ) == (b'\x7f ' + b'\xff ' * 15 + b'\x00 ' * 16 )
39
41
42
+
40
43
def test_abi_encode_single_real ():
41
44
assert abi .encode_single (['real' , '128x128' , []], 1.125 ) == (b'\x00 ' * 15 + b'\x01 \x20 ' + b'\x00 ' * 15 )
42
45
assert abi .encode_single (['real' , '128x128' , []], - 1.125 ) == (b'\xff ' * 15 + b'\xfe ' + b'\xe0 ' + b'\x00 ' * 15 )
43
46
47
+
44
48
def test_abi_encode_single_hash ():
45
49
assert abi .encode_single (['hash' , '8' , []], b'\x00 ' * 8 ) == b'\x00 ' * 32
46
50
assert abi .encode_single (['hash' , '8' , []], '00' * 8 ) == b'\x00 ' * 32
47
51
52
+
48
53
def test_abi_decode_single_hash ():
49
54
typ = ['hash' , '8' , []]
50
55
assert b'\x01 ' * 8 == abi .decode_single (typ , abi .encode_single (typ , b'\x01 ' * 8 ))
51
56
57
+
58
+ def test_abi_encode_single_bytes ():
59
+ typ = ['bytes' , '8' , []]
60
+ assert abi .encode_single (typ , '\x01 \x02 ' ) == b'\x01 \x02 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
61
+
62
+ typ = ['bytes' , '' , []]
63
+ assert abi .encode_single (typ , '\x01 \x02 ' ) == b'\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x02 \x01 \x02 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
64
+
65
+
52
66
def test_abi_decode_single_bytes ():
53
67
typ = ['bytes' , '8' , []]
54
68
assert (b'\x01 \x02 ' + b'\x00 ' * 6 ) == abi .decode_single (typ , abi .encode_single (typ , '\x01 \x02 ' ))
55
69
56
70
typ = ['bytes' , '' , []]
57
71
assert b'\x01 \x02 ' == abi .decode_single (typ , abi .encode_single (typ , '\x01 \x02 ' ))
58
72
73
+
59
74
def test_abi_encode_single_prefixed_address ():
60
75
prefixed_address = '0x' + '0' * 40
61
76
assert abi .encode_single (['address' , '' , []], prefixed_address ) == b'\x00 ' * 32
62
77
78
+
63
79
def test_abi_decode_single_real ():
64
80
real_data = abi .encode_single (['real' , '128x128' , []], 1 )
65
81
assert abi .decode_single (['real' , '128x128' , []], real_data ) == 1
@@ -73,10 +89,11 @@ def test_abi_decode_single_real():
73
89
real_data = abi .encode_single (['real' , '128x128' , []], - 2 ** 127 )
74
90
assert abi .decode_single (['real' , '128x128' , []], real_data ) == - 2 ** 127
75
91
92
+
76
93
# Will be parametrized fron json fixtures
77
94
def test_state (filename , testname , testdata ):
78
95
testutils .check_abi_test (testutils .fixture_to_bytes (testdata ))
79
96
80
97
81
- def pytest_generate_tests (metafunc ):
82
- testutils .generate_test_params ('ABITests' , metafunc )
98
+ # def pytest_generate_tests(metafunc):
99
+ # testutils.generate_test_params('ABITests', metafunc)
0 commit comments