Skip to content

Commit ebc5f4a

Browse files
committed
test(cmd): add edge-case and precedence tests for resolveNodeMode
1 parent 98be0b4 commit ebc5f4a

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ linters:
7373
- linters:
7474
- staticcheck
7575
text: "SA5008: malformed `json` tag: invalid trailing ',' character"
76+
- linters:
77+
- staticcheck
78+
path: cmd/bee/cmd
79+
text: "(this comparison is always true|never returns a nil interface value|the lhs of the comparison)"
7680
paths:
7781
- third_party$
7882
- builtin$

cmd/bee/cmd/resolve_node_mode_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,54 @@ func TestResolveNodeMode(t *testing.T) {
216216
},
217217
wantMode: node.UltraLightMode,
218218
},
219+
{
220+
name: "node-mode takes precedence over legacy full-node with warning",
221+
config: map[string]any{
222+
optionNameNodeMode: "light",
223+
optionNameFullNode: true,
224+
configKeyBlockchainRpcEndpoint: "http://localhost:8545",
225+
},
226+
wantMode: node.LightMode,
227+
},
228+
{
229+
name: "ultra-light with rpc endpoint ignores rpc and succeeds",
230+
config: map[string]any{
231+
optionNameNodeMode: "ultra-light",
232+
configKeyBlockchainRpcEndpoint: "http://localhost:8545",
233+
},
234+
wantMode: node.UltraLightMode,
235+
},
236+
{
237+
name: "light mode with rpc, swap and chequebook succeeds",
238+
config: map[string]any{
239+
optionNameNodeMode: "light",
240+
configKeyBlockchainRpcEndpoint: "http://localhost:8545",
241+
optionNameSwapEnable: true,
242+
optionNameChequebookEnable: true,
243+
},
244+
wantMode: node.LightMode,
245+
},
246+
{
247+
name: "empty node-mode string fails validation",
248+
config: map[string]any{
249+
optionNameNodeMode: "",
250+
},
251+
wantErr: "invalid node-mode",
252+
},
253+
{
254+
name: "uppercase node-mode string fails validation",
255+
config: map[string]any{
256+
optionNameNodeMode: "FULL",
257+
},
258+
wantErr: "invalid node-mode",
259+
},
260+
{
261+
name: "whitespace node-mode string fails validation",
262+
config: map[string]any{
263+
optionNameNodeMode: " full ",
264+
},
265+
wantErr: "invalid node-mode",
266+
},
219267
}
220268

221269
for _, tt := range tests {

0 commit comments

Comments
 (0)