Skip to content

Commit a4bd432

Browse files
lightclientfjl
andauthored
tests: add tests for typed txs and receipts (ethereum#442)
* tests: add tests for typed txs and receipts * eth: allow null result for tx and block methods * eth: update * eth: add names * eth: Information * eth: capitalize * tests: add yParity in transactions * schemas: allow null in transaction 'to' * schemas: add newlines between definitions in transaction.yaml * schemas: allow null in receipt 'to' * schemas: add newline in receipt.yaml * schemas: undo blank lines * add type definition notFound * fix indent * fix build issue * remove blank lines in eth spec * rename results back * undo capitalization --------- Co-authored-by: Felix Lange <fjl@twurst.com>
1 parent 67ac8e7 commit a4bd432

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+123
-43
lines changed

src/eth/block.yaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
result:
1414
name: Block information
1515
schema:
16-
$ref: '#/components/schemas/Block'
16+
oneOf:
17+
- $ref: '#/components/schemas/notFound'
18+
- $ref: '#/components/schemas/Block'
1719
- name: eth_getBlockByNumber
1820
summary: Returns information about a block by number.
1921
params:
@@ -29,7 +31,9 @@
2931
result:
3032
name: Block information
3133
schema:
32-
$ref: '#/components/schemas/Block'
34+
oneOf:
35+
- $ref: '#/components/schemas/notFound'
36+
- $ref: '#/components/schemas/Block'
3337
- name: eth_getBlockTransactionCountByHash
3438
summary: Returns the number of transactions in a block from a block matching the given block hash.
3539
params:
@@ -39,7 +43,10 @@
3943
result:
4044
name: Transaction count
4145
schema:
42-
$ref: '#/components/schemas/uint'
46+
oneOf:
47+
- $ref: '#/components/schemas/notFound'
48+
- title: Transaction count
49+
$ref: '#/components/schemas/uint'
4350
- name: eth_getBlockTransactionCountByNumber
4451
summary: Returns the number of transactions in a block matching the given block number.
4552
params:
@@ -49,7 +56,10 @@
4956
result:
5057
name: Transaction count
5158
schema:
52-
$ref: '#/components/schemas/uint'
59+
oneOf:
60+
- $ref: '#/components/schemas/notFound'
61+
- title: Transaction count
62+
$ref: '#/components/schemas/uint'
5363
- name: eth_getUncleCountByBlockHash
5464
summary: Returns the number of uncles in a block from a block matching the given block hash.
5565
params:
@@ -59,7 +69,10 @@
5969
result:
6070
name: Uncle count
6171
schema:
62-
$ref: '#/components/schemas/uint'
72+
oneOf:
73+
- $ref: '#/components/schemas/notFound'
74+
- title: Uncle count
75+
$ref: '#/components/schemas/uint'
6376
- name: eth_getUncleCountByBlockNumber
6477
summary: Returns the number of transactions in a block matching the given block number.
6578
params:
@@ -69,4 +82,7 @@
6982
result:
7083
name: Uncle count
7184
schema:
72-
$ref: '#/components/schemas/uint'
85+
oneOf:
86+
- $ref: '#/components/schemas/notFound'
87+
- title: Uncle count
88+
$ref: '#/components/schemas/uint'

src/eth/transaction.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
result:
99
name: Transaction information
1010
schema:
11-
$ref: '#/components/schemas/TransactionInfo'
11+
oneOf:
12+
- $ref: '#/components/schemas/notFound'
13+
- $ref: '#/components/schemas/TransactionInfo'
1214
- name: eth_getTransactionByBlockHashAndIndex
1315
summary: Returns information about a transaction by block hash and transaction index position.
1416
params:
@@ -23,7 +25,9 @@
2325
result:
2426
name: Transaction information
2527
schema:
26-
$ref: '#/components/schemas/TransactionInfo'
28+
oneOf:
29+
- $ref: '#/components/schemas/notFound'
30+
- $ref: '#/components/schemas/TransactionInfo'
2731
- name: eth_getTransactionByBlockNumberAndIndex
2832
summary: Returns information about a transaction by block number and transaction index position.
2933
params:
@@ -38,7 +42,9 @@
3842
result:
3943
name: Transaction information
4044
schema:
41-
$ref: '#/components/schemas/TransactionInfo'
45+
oneOf:
46+
- $ref: '#/components/schemas/notFound'
47+
- $ref: '#/components/schemas/TransactionInfo'
4248
- name: eth_getTransactionReceipt
4349
summary: Returns the receipt of a transaction by transaction hash.
4450
params:
@@ -47,6 +53,8 @@
4753
schema:
4854
$ref: '#/components/schemas/hash32'
4955
result:
50-
name: Receipt Information
56+
name: Receipt information
5157
schema:
52-
$ref: '#/components/schemas/ReceiptInfo'
58+
oneOf:
59+
- $ref: '#/components/schemas/notFound'
60+
- $ref: '#/components/schemas/ReceiptInfo'

src/schemas/base-types.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ hash32:
6060
title: 32 byte hex value
6161
type: string
6262
pattern: ^0x[0-9a-f]{64}$
63+
notFound:
64+
title: 'Not Found (null)'
65+
type: 'null'

src/schemas/receipt.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Log:
3636
$ref: '#/components/schemas/bytes32'
3737
ReceiptInfo:
3838
type: object
39-
title: Receipt info
39+
title: Receipt information
4040
required:
4141
- blockHash
4242
- blockNumber
@@ -71,7 +71,11 @@ ReceiptInfo:
7171
to:
7272
title: to
7373
description: Address of the receiver or null in a contract creation transaction.
74-
$ref: '#/components/schemas/address'
74+
oneOf:
75+
- title: Contract Creation (null)
76+
type: 'null'
77+
- title: Recipient Address
78+
$ref: '#/components/schemas/address'
7579
cumulativeGasUsed:
7680
title: cumulative gas used
7781
description: The sum of gas used by this transaction and all preceding transactions in the same block.

src/schemas/transaction.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ Transaction1559Unsigned:
3838
$ref: '#/components/schemas/uint'
3939
to:
4040
title: to address
41-
$ref: '#/components/schemas/address'
41+
oneOf:
42+
- title: Contract Creation (null)
43+
type: 'null'
44+
- title: Address
45+
$ref: '#/components/schemas/address'
4246
gas:
4347
title: gas limit
4448
$ref: '#/components/schemas/uint'
@@ -89,7 +93,11 @@ Transaction2930Unsigned:
8993
$ref: '#/components/schemas/uint'
9094
to:
9195
title: to address
92-
$ref: '#/components/schemas/address'
96+
oneOf:
97+
- title: Contract Creation (null)
98+
type: 'null'
99+
- title: Address
100+
$ref: '#/components/schemas/address'
93101
gas:
94102
title: gas limit
95103
$ref: '#/components/schemas/uint'
@@ -131,7 +139,11 @@ TransactionLegacyUnsigned:
131139
$ref: '#/components/schemas/uint'
132140
to:
133141
title: to address
134-
$ref: '#/components/schemas/address'
142+
oneOf:
143+
- title: Contract Creation (null)
144+
type: 'null'
145+
- title: Address
146+
$ref: '#/components/schemas/address'
135147
gas:
136148
title: gas limit
137149
$ref: '#/components/schemas/uint'
@@ -263,7 +275,11 @@ GenericTransaction:
263275
$ref: '#/components/schemas/uint'
264276
to:
265277
title: to address
266-
$ref: '#/components/schemas/address'
278+
oneOf:
279+
- title: Contract Creation (null)
280+
type: 'null'
281+
- title: Address
282+
$ref: '#/components/schemas/address'
267283
from:
268284
title: from address
269285
$ref: '#/components/schemas/address'
@@ -296,4 +312,3 @@ GenericTransaction:
296312
title: chainId
297313
description: Chain ID that this transaction is valid on.
298314
$ref: '#/components/schemas/uint'
299-

tests/bad.rlp

0 Bytes
Binary file not shown.

tests/chain.rlp

3.98 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
>> {"jsonrpc":"2.0","id":1,"method":"debug_getRawBlock","params":["0x3"]}
2-
<< {"jsonrpc":"2.0","id":1,"result":"0xf90288f90218a0fe21bb173f43067a9f90cfc59bbb6830a7a2929b5de4a61f372a9db28e87f9aea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a061effbbcca94f0d3e02e5bd22e986ad57142acabf0cb3d129a6ad8d0f8752e94a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008003834c4b408252081e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000842806be9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421f869f86702842806be9e82520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a040ce7918eeb045ebf8c8b1887ca139d076bda00fa828a07881d442a72626c42da0156576a68e456e295e4c9cf67cf9f53151f329438916e0f24fc69d6bbb7fbacfc0c0"}
2+
<< {"jsonrpc":"2.0","id":1,"result":"0xf90276f90218a0b019ea73504c933a601125fc37ebfd9629a2119a91792a5653365ed73ec56acba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0f17a0db4c6c1d9461d74a6c8d9426769b68d1146ca14a9175cb629b7aaeb600da0b7123db22d2b11088a0c80e4e44e0740ce7965754b75e366b9d1f297e5ea8181a0223f7b7cb197a5886eb3ffc6d05896b38539cefbbf8c3da4855a61e7a854bf4ab90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008003834c4b4082cf501e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000842806be9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421f857f85502842806be9d82cf6c80808460806040820a95a030e29b76d4ce26f1f5c69e6fb814d9a138ee5f5238f0bf7ed80ede0db82406bfa07e81c4c6d80b3e5a333bb16ff95dca3f11d9f33421bd8234ab54d57b35cbcb8bc0c0"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
>> {"jsonrpc":"2.0","id":1,"method":"debug_getRawBlock","params":["0x0"]}
2-
<< {"jsonrpc":"2.0","id":1,"result":"0xf9021cf90216a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421c0c0c0"}
2+
<< {"jsonrpc":"2.0","id":1,"result":"0xf9021cf90216a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a05db86e9a500ed3158bdd0e8a01927f070bbf6630f39118510283150efe9aa31ba056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421c0c0c0"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
>> {"jsonrpc":"2.0","id":1,"method":"debug_getRawHeader","params":["0x3"]}
2-
<< {"jsonrpc":"2.0","id":1,"result":"0xf90218a0fe21bb173f43067a9f90cfc59bbb6830a7a2929b5de4a61f372a9db28e87f9aea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a061effbbcca94f0d3e02e5bd22e986ad57142acabf0cb3d129a6ad8d0f8752e94a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008003834c4b408252081e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000842806be9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}
2+
<< {"jsonrpc":"2.0","id":1,"result":"0xf90218a0b019ea73504c933a601125fc37ebfd9629a2119a91792a5653365ed73ec56acba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0f17a0db4c6c1d9461d74a6c8d9426769b68d1146ca14a9175cb629b7aaeb600da0b7123db22d2b11088a0c80e4e44e0740ce7965754b75e366b9d1f297e5ea8181a0223f7b7cb197a5886eb3ffc6d05896b38539cefbbf8c3da4855a61e7a854bf4ab90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008003834c4b4082cf501e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000842806be9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}

0 commit comments

Comments
 (0)