/eth/v1/config/deposit_contract return string instead of uint (#12952)

* Convert uint to string

* Add test

* Rename test
This commit is contained in:
Sammy Rosso
2023-09-25 15:02:47 +02:00
committed by GitHub
parent 57a63f37f7
commit 90fb2325db
3 changed files with 23 additions and 3 deletions

View File

@@ -746,10 +746,10 @@ func (*Server) GetDepositContract(w http.ResponseWriter, r *http.Request) {
http2.WriteJson(w, &DepositContractResponse{
Data: &struct {
ChainId uint64 `json:"chain_id"`
ChainId string `json:"chain_id"`
Address string `json:"address"`
}{
ChainId: params.BeaconConfig().DepositChainID,
ChainId: strconv.FormatUint(params.BeaconConfig().DepositChainID, 10),
Address: params.BeaconConfig().DepositContractAddress,
},
})

View File

@@ -1654,3 +1654,23 @@ func TestGetGenesis(t *testing.T) {
assert.StringContains(t, "Chain genesis info is not yet known", e.Message)
})
}
func TestGetDepositContract(t *testing.T) {
params.SetupTestConfigCleanup(t)
config := params.BeaconConfig().Copy()
config.DepositChainID = uint64(10)
config.DepositContractAddress = "0x4242424242424242424242424242424242424242"
params.OverrideBeaconConfig(config)
request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil)
writer := httptest.NewRecorder()
writer.Body = &bytes.Buffer{}
s := &Server{}
s.GetDepositContract(writer, request)
assert.Equal(t, http.StatusOK, writer.Code)
response := DepositContractResponse{}
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &response))
assert.Equal(t, "10", response.Data.ChainId)
assert.Equal(t, "0x4242424242424242424242424242424242424242", response.Data.Address)
}

View File

@@ -20,7 +20,7 @@ type GetCommitteesResponse struct {
type DepositContractResponse struct {
Data *struct {
ChainId uint64 `json:"chain_id"`
ChainId string `json:"chain_id"`
Address string `json:"address"`
} `json:"data"`
}