-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathblock_header.json
More file actions
298 lines (298 loc) · 7.73 KB
/
Copy pathblock_header.json
File metadata and controls
298 lines (298 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
{
"title": "Block Header Operations",
"description": "Covers block header parsing, invalid-input rejection, serialization, field getters, copy equality, and object cleanup using the mainnet genesis block header",
"stateful": true,
"tests": [
{
"description": "Rejects empty raw block header bytes",
"request": {
"id": "block_header#1",
"method": "btck_block_header_create",
"params": {
"raw_block_header": ""
},
"ref": "$empty_header"
},
"expected_response": {
"error": {}
}
},
{
"description": "Rejects raw header bytes shorter than the required 80-byte block header",
"request": {
"id": "block_header#2",
"method": "btck_block_header_create",
"params": {
"raw_block_header": "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b"
},
"ref": "$short_header"
},
"expected_response": {
"error": {}
}
},
{
"description": "Creates a header from the exact 80-byte mainnet genesis block header",
"request": {
"id": "block_header#3",
"method": "btck_block_header_create",
"params": {
"raw_block_header": "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c"
},
"ref": "$header"
},
"expected_response": {
"result": {
"ref": "$header"
}
}
},
{
"description": "Verifies block header serialization round-trips to the original bytes",
"request": {
"id": "block_header#4",
"method": "btck_block_header_to_bytes",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {
"result": "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c"
}
},
{
"description": "Gets the hash for the exact genesis block header",
"request": {
"id": "block_header#5",
"method": "btck_block_header_get_hash",
"params": {
"header": {
"ref": "$header"
}
},
"ref": "$header_hash"
},
"expected_response": {
"result": {
"ref": "$header_hash"
}
}
},
{
"description": "Verifies the serialized exact header hash matches the mainnet genesis block hash",
"request": {
"id": "block_header#6",
"method": "btck_block_hash_to_bytes",
"params": {
"block_hash": {
"ref": "$header_hash"
}
}
},
"expected_response": {
"result": "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000"
}
},
{
"description": "Gets the previous block hash from the genesis block header",
"request": {
"id": "block_header#7",
"method": "btck_block_header_get_prev_hash",
"params": {
"header": {
"ref": "$header"
}
},
"ref": "$prev_hash"
},
"expected_response": {
"result": {
"ref": "$prev_hash"
}
}
},
{
"description": "Verifies the genesis previous block hash is all zero bytes",
"request": {
"id": "block_header#8",
"method": "btck_block_hash_to_bytes",
"params": {
"block_hash": {
"ref": "$prev_hash"
}
}
},
"expected_response": {
"result": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"description": "Verifies the genesis block header version",
"request": {
"id": "block_header#9",
"method": "btck_block_header_get_version",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {
"result": 1
}
},
{
"description": "Verifies the genesis block header timestamp",
"request": {
"id": "block_header#10",
"method": "btck_block_header_get_timestamp",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {
"result": 1231006505
}
},
{
"description": "Verifies the genesis block header proof-of-work bits",
"request": {
"id": "block_header#11",
"method": "btck_block_header_get_bits",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {
"result": 486604799
}
},
{
"description": "Verifies the genesis block header nonce",
"request": {
"id": "block_header#12",
"method": "btck_block_header_get_nonce",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {
"result": 2083236893
}
},
{
"description": "Copies the parsed genesis block header",
"request": {
"id": "block_header#13",
"method": "btck_block_header_copy",
"params": {
"header": {
"ref": "$header"
}
},
"ref": "$header_copy"
},
"expected_response": {
"result": {
"ref": "$header_copy"
}
}
},
{
"description": "Destroys the original header after the copy has been created",
"request": {
"id": "block_header#14",
"method": "btck_block_header_destroy",
"params": {
"header": {
"ref": "$header"
}
}
},
"expected_response": {}
},
{
"description": "Gets the hash from the copied header after the original header is destroyed",
"request": {
"id": "block_header#15",
"method": "btck_block_header_get_hash",
"params": {
"header": {
"ref": "$header_copy"
}
},
"ref": "$header_copy_hash"
},
"expected_response": {
"result": {
"ref": "$header_copy_hash"
}
}
},
{
"description": "Destroys the copied header after deriving its hash",
"request": {
"id": "block_header#16",
"method": "btck_block_header_destroy",
"params": {
"header": {
"ref": "$header_copy"
}
}
},
"expected_response": {}
},
{
"description": "Verifies the copied header hash equals the original header hash",
"request": {
"id": "block_header#17",
"method": "btck_block_hash_equals",
"params": {
"hash1": {
"ref": "$header_hash"
},
"hash2": {
"ref": "$header_copy_hash"
}
}
},
"expected_response": {
"result": true
}
},
{
"description": "Destroys the original header hash after comparison",
"request": {
"id": "block_header#18",
"method": "btck_block_hash_destroy",
"params": {
"block_hash": {
"ref": "$header_hash"
}
}
},
"expected_response": {}
},
{
"description": "Destroys the hash returned for the copied header",
"request": {
"id": "block_header#19",
"method": "btck_block_hash_destroy",
"params": {
"block_hash": {
"ref": "$header_copy_hash"
}
}
},
"expected_response": {}
}
]
}