Skip to content

Commit

Permalink
fix encoding to string
Browse files Browse the repository at this point in the history
  • Loading branch information
jordipainan committed Nov 28, 2023
1 parent 05b72b8 commit 48c1e06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/elections.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ func (a *API) nextElectionIDHandler(msg *apirest.APIdata, ctx *httprouter.HTTPCo
}

data, err := json.Marshal(struct {
ElectionID []byte `json:"electionID"`
ElectionID string `json:"electionID"`
}{
ElectionID: pid.Marshal(),
ElectionID: hex.EncodeToString(pid.Marshal()),
})
if err != nil {
return ErrMarshalingServerJSONFailed.WithErr(err)
Expand Down
4 changes: 2 additions & 2 deletions test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func TestAPINextElectionID(t *testing.T) {
qt.Assert(t, code, qt.Equals, 200, qt.Commentf("response: %s", resp))

nextElectionID := struct {
ElectionID []byte `json:"electionID"`
ElectionID string `json:"electionID"`
}{}
err := json.Unmarshal(resp, &nextElectionID)
qt.Assert(t, err, qt.IsNil)
Expand All @@ -718,5 +718,5 @@ func TestAPINextElectionID(t *testing.T) {
waitUntilHeight(t, c, 4)

// check next election id is the same as the election id created
qt.Assert(t, hex.EncodeToString(nextElectionID.ElectionID), qt.Equals, electionId.String())
qt.Assert(t, nextElectionID.ElectionID, qt.Equals, electionId.String())
}

0 comments on commit 48c1e06

Please sign in to comment.