Skip to content

Commit 76faa0a

Browse files
authored
style: minor tweak (#1194)
1 parent 90cc240 commit 76faa0a

1 file changed

Lines changed: 5 additions & 170 deletions

File tree

api/middleware/middleware_test.go

Lines changed: 5 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,7 @@ import (
2222

2323
func TestHandleXGenesisID(t *testing.T) {
2424
// Create a test genesis ID
25-
genesisID := thor.Bytes32{
26-
0x01,
27-
0x02,
28-
0x03,
29-
0x04,
30-
0x05,
31-
0x06,
32-
0x07,
33-
0x08,
34-
0x09,
35-
0x0a,
36-
0x0b,
37-
0x0c,
38-
0x0d,
39-
0x0e,
40-
0x0f,
41-
0x10,
42-
0x11,
43-
0x12,
44-
0x13,
45-
0x14,
46-
0x15,
47-
0x16,
48-
0x17,
49-
0x18,
50-
0x19,
51-
0x1a,
52-
0x1b,
53-
0x1c,
54-
0x1d,
55-
0x1e,
56-
0x1f,
57-
0x20,
58-
}
25+
genesisID := thor.MustParseBytes32("0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20")
5926
expectedID := genesisID.String()
6027

6128
// Create middleware
@@ -176,108 +143,9 @@ func TestHandleXGenesisID(t *testing.T) {
176143
func TestHandleXGenesisIDWithDifferentGenesisIDs(t *testing.T) {
177144
// Test with different genesis IDs
178145
genesisIDs := []thor.Bytes32{
179-
{
180-
0x01,
181-
0x02,
182-
0x03,
183-
0x04,
184-
0x05,
185-
0x06,
186-
0x07,
187-
0x08,
188-
0x09,
189-
0x0a,
190-
0x0b,
191-
0x0c,
192-
0x0d,
193-
0x0e,
194-
0x0f,
195-
0x10,
196-
0x11,
197-
0x12,
198-
0x13,
199-
0x14,
200-
0x15,
201-
0x16,
202-
0x17,
203-
0x18,
204-
0x19,
205-
0x1a,
206-
0x1b,
207-
0x1c,
208-
0x1d,
209-
0x1e,
210-
0x1f,
211-
0x20,
212-
},
213-
{
214-
0xff,
215-
0xfe,
216-
0xfd,
217-
0xfc,
218-
0xfb,
219-
0xfa,
220-
0xf9,
221-
0xf8,
222-
0xf7,
223-
0xf6,
224-
0xf5,
225-
0xf4,
226-
0xf3,
227-
0xf2,
228-
0xf1,
229-
0xf0,
230-
0xef,
231-
0xee,
232-
0xed,
233-
0xec,
234-
0xeb,
235-
0xea,
236-
0xe9,
237-
0xe8,
238-
0xe7,
239-
0xe6,
240-
0xe5,
241-
0xe4,
242-
0xe3,
243-
0xe2,
244-
0xe1,
245-
0xe0,
246-
},
247-
{
248-
0x00,
249-
0x00,
250-
0x00,
251-
0x00,
252-
0x00,
253-
0x00,
254-
0x00,
255-
0x00,
256-
0x00,
257-
0x00,
258-
0x00,
259-
0x00,
260-
0x00,
261-
0x00,
262-
0x00,
263-
0x00,
264-
0x00,
265-
0x00,
266-
0x00,
267-
0x00,
268-
0x00,
269-
0x00,
270-
0x00,
271-
0x00,
272-
0x00,
273-
0x00,
274-
0x00,
275-
0x00,
276-
0x00,
277-
0x00,
278-
0x00,
279-
0x00,
280-
},
146+
thor.MustParseBytes32("0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"),
147+
thor.MustParseBytes32("0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0"),
148+
thor.MustParseBytes32("0x0000000000000000000000000000000000000000000000000000000000000000"),
281149
}
282150

283151
for i, genesisID := range genesisIDs {
@@ -305,40 +173,7 @@ func TestHandleXGenesisIDWithDifferentGenesisIDs(t *testing.T) {
305173

306174
func TestHandleXGenesisIDWithBodyDiscard(t *testing.T) {
307175
// Test that request body is properly discarded when genesis ID mismatch occurs
308-
genesisID := thor.Bytes32{
309-
0x01,
310-
0x02,
311-
0x03,
312-
0x04,
313-
0x05,
314-
0x06,
315-
0x07,
316-
0x08,
317-
0x09,
318-
0x0a,
319-
0x0b,
320-
0x0c,
321-
0x0d,
322-
0x0e,
323-
0x0f,
324-
0x10,
325-
0x11,
326-
0x12,
327-
0x13,
328-
0x14,
329-
0x15,
330-
0x16,
331-
0x17,
332-
0x18,
333-
0x19,
334-
0x1a,
335-
0x1b,
336-
0x1c,
337-
0x1d,
338-
0x1e,
339-
0x1f,
340-
0x20,
341-
}
176+
genesisID := thor.MustParseBytes32("0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20")
342177
middleware := HandleXGenesisID(genesisID)
343178

344179
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)