-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathinput_parser_test.star
More file actions
182 lines (162 loc) · 5.86 KB
/
input_parser_test.star
File metadata and controls
182 lines (162 loc) · 5.86 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
_input_parser = import_module("/src/mev/input_parser.star")
_net = import_module("/src/util/net.star")
_registry = import_module("/src/package_io/registry.star")
_default_network_params = struct(network_id=1000, name="my-l2", seconds_per_slot=2)
_default_participant_index = 0
_default_participant_name = "node0"
_default_registry = _registry.Registry()
def test_mev_input_parser_extra_attributes(plan):
expect.fails(
lambda: _input_parser.parse(
mev_args={"extra": None, "name": "x"},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
"Invalid attributes in MEV configuration for node0 on network my-l2: extra,name",
)
def test_mev_input_parser_invalid_builder_params(plan):
expect.fails(
lambda: _input_parser.parse(
mev_args={"enabled": True, "builder_port": "7"},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
"Missing builder_host in MEV configuration for node0 on network my-l2",
)
expect.fails(
lambda: _input_parser.parse(
mev_args={"enabled": True, "builder_host": "localhost"},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
"Missing builder_port in MEV configuration for node0 on network my-l2",
)
def test_mev_input_parser_default_args(plan):
_default_params = struct(
enabled=True,
image="flashbots/rollup-boost:0.7.4",
type="rollup-boost",
builder_host=None,
builder_port=None,
builder_timeout="1000",
l2_timeout="1000",
service_name="op-mev-rollup-boost-1000-my-l2-node0",
labels={
"op.kind": "mev",
"op.network.id": "1000",
"op.network.participant.index": "0",
"op.network.participant.name": "node0",
"op.mev.type": "rollup-boost",
},
ports={
_net.RPC_PORT_NAME: _net.port(number=8551),
_net.WS_PORT_NAME: _net.port(number=1112, application_protocol="ws"),
},
)
expect.eq(
_input_parser.parse(
mev_args=None,
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
None,
)
expect.eq(
_input_parser.parse(
mev_args={},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
None,
)
expect.eq(
_input_parser.parse(
mev_args={"enabled": False},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
None,
)
expect.eq(
_input_parser.parse(
mev_args={
"enabled": True,
"image": None,
"type": None,
"builder_host": None,
"builder_port": None,
},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
),
_default_params,
)
def test_mev_input_parser_custom_params(plan):
parsed = _input_parser.parse(
mev_args={
"enabled": True,
"image": "op-rollup-boost:brightest",
"builder_host": "localhost",
"builder_port": 8080,
},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=_default_registry,
)
expect.eq(
parsed,
struct(
enabled=True,
image="op-rollup-boost:brightest",
type="rollup-boost",
builder_host="localhost",
builder_port=8080,
builder_timeout="1000",
l2_timeout="1000",
service_name="op-mev-rollup-boost-1000-my-l2-node0",
labels={
"op.kind": "mev",
"op.network.id": "1000",
"op.network.participant.index": "0",
"op.network.participant.name": "node0",
"op.mev.type": "rollup-boost",
},
ports={
_net.RPC_PORT_NAME: _net.port(number=8551),
_net.WS_PORT_NAME: _net.port(number=1112, application_protocol="ws"),
},
),
)
def test_mev_input_parser_custom_registry(plan):
registry = _registry.Registry({_registry.ROLLUP_BOOST: "rollup-boost:greatest"})
parsed = _input_parser.parse(
mev_args={"enabled": True},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=registry,
)
expect.eq(parsed.image, "rollup-boost:greatest")
parsed = _input_parser.parse(
mev_args={"enabled": True, "image": "rollup-boost:oldest"},
network_params=_default_network_params,
participant_index=_default_participant_index,
participant_name=_default_participant_name,
registry=registry,
)
expect.eq(parsed.image, "rollup-boost:oldest")