mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
fixing config string parsing regression (#15773)
* adding string parsing and test * gaz
This commit is contained in:
@@ -27,5 +27,7 @@ go_test(
|
|||||||
"//testing/require:go_default_library",
|
"//testing/require:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||||
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
|
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ func convertValueForJSON(v reflect.Value, tag string) interface{} {
|
|||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
// ===== String =====
|
||||||
|
case reflect.String:
|
||||||
|
return v.String()
|
||||||
|
|
||||||
// ===== Default =====
|
// ===== Default =====
|
||||||
default:
|
default:
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/OffchainLabs/prysm/v6/api/server/structs"
|
"github.com/OffchainLabs/prysm/v6/api/server/structs"
|
||||||
@@ -17,6 +18,8 @@ import (
|
|||||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetDepositContract(t *testing.T) {
|
func TestGetDepositContract(t *testing.T) {
|
||||||
@@ -715,3 +718,35 @@ func TestGetSpec_BlobSchedule_NotFulu(t *testing.T) {
|
|||||||
_, exists := data["BLOB_SCHEDULE"]
|
_, exists := data["BLOB_SCHEDULE"]
|
||||||
require.Equal(t, false, exists)
|
require.Equal(t, false, exists)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertValueForJSON_NoErrorLogsForStrings(t *testing.T) {
|
||||||
|
logHook := logTest.NewLocal(log.StandardLogger())
|
||||||
|
defer logHook.Reset()
|
||||||
|
|
||||||
|
stringTestCases := []struct {
|
||||||
|
tag string
|
||||||
|
value string
|
||||||
|
}{
|
||||||
|
{"CONFIG_NAME", "mainnet"},
|
||||||
|
{"PRESET_BASE", "mainnet"},
|
||||||
|
{"DEPOSIT_CONTRACT_ADDRESS", "0x00000000219ab540356cBB839Cbe05303d7705Fa"},
|
||||||
|
{"TERMINAL_TOTAL_DIFFICULTY", "58750000000000000000000"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range stringTestCases {
|
||||||
|
t.Run(tc.tag, func(t *testing.T) {
|
||||||
|
logHook.Reset()
|
||||||
|
|
||||||
|
// Convert the string value
|
||||||
|
v := reflect.ValueOf(tc.value)
|
||||||
|
result := convertValueForJSON(v, tc.tag)
|
||||||
|
|
||||||
|
// Verify the result is correct
|
||||||
|
require.Equal(t, tc.value, result)
|
||||||
|
|
||||||
|
// Verify NO error was logged about unsupported field kind
|
||||||
|
require.LogsDoNotContain(t, logHook, "Unsupported config field kind")
|
||||||
|
require.LogsDoNotContain(t, logHook, "kind=string")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
3
changelog/james-prysm_fix-config-parsing.md
Normal file
3
changelog/james-prysm_fix-config-parsing.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixing Unsupported config field kind; value forwarded verbatim errors for type string.
|
||||||
Reference in New Issue
Block a user