Files
zeekay 9ba0c204b3 refactor: remove all SubnetEVM references
- Rename --subnet-evm-path flag to --evm-path
- Rename subnetEvmPath variable to evmPath
- Rename subnet-evm-genesis.json to evm-genesis.json
- Change VmName from "subnetevm" to "evm"
- Update all test configurations
2025-12-21 11:12:41 -08:00

45 lines
1.6 KiB
Go

// Copyright (C) 2021-2025, Lux Industries Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
package utils
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func TestSetJSONKey(t *testing.T) {
b := `{
"network-peer-list-gossip-frequency":"250ms",
"network-max-reconnect-delay":"1s",
"public-ip":"127.0.0.1",
"health-check-frequency":"2s",
"api-admin-enabled":true,
"api-ipcs-enabled":true,
"index-enabled":true,
"log-display-level":"INFO",
"log-level":"INFO",
"log-dir":"INFO",
"db-dir":"INFO",
"track-chains":"a,b,c",
"plugin-dir":"INFO"
}`
s, err := SetJSONKey(b, "track-chains", "d,e,f")
require.NoError(t, err)
require.Contains(t, s, `"track-chains":"d,e,f"`)
// now check it's actual correct JSON
var m map[string]interface{}
err = json.Unmarshal([]byte(s), &m)
require.NoError(t, err)
// check if one-liner also works
bb := `{"api-admin-enabled":true,"api-ipcs-enabled":true,"db-dir":"/tmp/network-runner-root-data3856302950/node5/db-dir","health-check-frequency":"2s","index-enabled":true,"log-dir":"/tmp/network-runner-root-data3856302950/node5/log","log-display-level":"INFO","log-level":"INFO","network-max-reconnect-delay":"1s","network-peer-list-gossip-frequency":"250ms","plugin-dir":"/home/fabio/go/src/github.com/luxfi/node/build/plugins","public-ip":"127.0.0.1","track-chains":""}`
ss, err := SetJSONKey(bb, "track-chains", "d,e,f")
require.NoError(t, err)
require.Contains(t, s, `"track-chains":"d,e,f"`)
// also check here it's correct JSON
err = json.Unmarshal([]byte(ss), &m)
require.NoError(t, err)
}