Skip to content

Commit b48fb8a

Browse files
committed
New unit tests focus on error cases only
1 parent e3d25ea commit b48fb8a

File tree

1 file changed

+2
-46
lines changed

1 file changed

+2
-46
lines changed

params/json.libevm_test.go

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestChainConfigJSONRoundTrip(t *testing.T) {
145145
}
146146
}
147147

148-
func TestUnmarshalChainConfigJSON(t *testing.T) {
148+
func TestUnmarshalChainConfigJSON_Errors(t *testing.T) {
149149
t.Parallel()
150150

151151
type testExtra struct {
@@ -178,19 +178,6 @@ func TestUnmarshalChainConfigJSON(t *testing.T) {
178178
wantExtra: (*testExtra)(nil),
179179
wantErrRegex: `^\*.+\.testExtra argument is nil; use \*.+\.ChainConfig.UnmarshalJSON\(\) directly$`,
180180
},
181-
"no_extra_at_extra_key": {
182-
jsonData: `{"chainId": 1}`,
183-
extra: &testExtra{},
184-
wantConfig: ChainConfig{ChainID: big.NewInt(1)},
185-
wantExtra: &testExtra{},
186-
},
187-
"no_extra_at_root_depth": {
188-
jsonData: `{"chainId": 1}`,
189-
extra: &testExtra{},
190-
reuseJSONRoot: true,
191-
wantConfig: ChainConfig{ChainID: big.NewInt(1)},
192-
wantExtra: &testExtra{},
193-
},
194181
"wrong_extra_type_at_extra_key": {
195182
jsonData: `{"chainId": 1, "extra": 1}`,
196183
extra: &testExtra{},
@@ -206,19 +193,6 @@ func TestUnmarshalChainConfigJSON(t *testing.T) {
206193
wantExtra: &testExtra{},
207194
wantErrRegex: `^decoding JSON into \*.+\.testExtra: .+`,
208195
},
209-
"extra_success_at_extra_key": {
210-
jsonData: `{"chainId": 1, "extra": {"field":"value"}}`,
211-
extra: &testExtra{},
212-
wantConfig: ChainConfig{ChainID: big.NewInt(1)},
213-
wantExtra: &testExtra{Field: "value"},
214-
},
215-
"extra_success_at_root_depth": {
216-
jsonData: `{"chainId": 1, "field":"value"}`,
217-
extra: &testExtra{},
218-
reuseJSONRoot: true,
219-
wantConfig: ChainConfig{ChainID: big.NewInt(1)},
220-
wantExtra: &testExtra{Field: "value"},
221-
},
222196
}
223197

224198
for name, testCase := range testCases {
@@ -241,7 +215,7 @@ func TestUnmarshalChainConfigJSON(t *testing.T) {
241215
}
242216
}
243217

244-
func TestMarshalChainConfigJSON(t *testing.T) {
218+
func TestMarshalChainConfigJSON_Errors(t *testing.T) {
245219
t.Parallel()
246220

247221
testCases := map[string]struct {
@@ -260,12 +234,6 @@ func TestMarshalChainConfigJSON(t *testing.T) {
260234
"nil_extra_at_extra_key": {
261235
wantJSONData: `{"chainId":null}`,
262236
},
263-
"extra_at_extra_key": {
264-
extra: struct {
265-
Field string `json:"field"`
266-
}{Field: "value"},
267-
wantJSONData: `{"chainId":null,"extra":{"field":"value"}}`,
268-
},
269237
"invalid_extra_at_root_depth": {
270238
extra: struct {
271239
Field chan struct{} `json:"field"`
@@ -280,18 +248,6 @@ func TestMarshalChainConfigJSON(t *testing.T) {
280248
reuseJSONRoot: true,
281249
wantErrRegex: `^duplicate JSON key "chainId" in ChainConfig and extra struct .+$`,
282250
},
283-
"nil_extra_at_root_depth": {
284-
extra: nil,
285-
reuseJSONRoot: true,
286-
wantJSONData: `{"chainId":null}`,
287-
},
288-
"extra_at_root_depth": {
289-
extra: struct {
290-
Field string `json:"field"`
291-
}{},
292-
reuseJSONRoot: true,
293-
wantJSONData: `{"chainId":null,"field":""}`,
294-
},
295251
}
296252

297253
for name, testCase := range testCases {

0 commit comments

Comments
 (0)