mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
/eth/v1/config/deposit_contract return string instead of uint (#12952)
* Convert uint to string * Add test * Rename test
This commit is contained in:
@@ -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,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user