Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement the auditor-server application layer #193

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions application/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ func UnmarshalResponse(t int, msg []byte) *protocol.Response {
Error: res.Error,
}
if err := response.Validate(); err != nil {
return &protocol.Response{
Error: protocol.ErrMalformedMessage,
// we don't want to return an ErrMalformedMessage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@masomel masomel Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the problem is that this function was still returning an ErrMalformedMessage even if the error is in errors. In other words, because Validate() in message.go returns msg.Error, which gives err == nil after Validate() returns, the return &protocol.Response{Error: protocol.ErrMalformedMessage } statement was always being called, even when the msg.Error was in errors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I gave it a try in https://github.com/coniks-sys/coniks-go/compare/unmarshalling. If it's ok, feel free to merge to this branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes looks good to me. Thank you! I also like that you re-wrote the test cases. I'll merge this branch when I get a chance.

// if Error is in errors
if err == protocol.ErrMalformedMessage {
return &protocol.Response{
Error: protocol.ErrMalformedMessage,
}
}
}
return response
Expand Down
4 changes: 2 additions & 2 deletions application/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestUnmarshalMalformedSTRHistoryRange(t *testing.T) {
}

func TestUnmarshalSampleClientMessage(t *testing.T) {
d, _ := directory.NewTestDirectory(t, true)
d := directory.NewTestDirectory(t)
res := d.Register(&protocol.RegistrationRequest{
Username: "alice",
Key: []byte("key")})
Expand All @@ -75,7 +75,7 @@ func TestUnmarshalSampleClientMessage(t *testing.T) {
}

func TestUnmarshalSampleAuditorMessage(t *testing.T) {
d, _ := directory.NewTestDirectory(t, true)
d := directory.NewTestDirectory(t)
res := d.GetSTRHistory(&protocol.STRHistoryRequest{
StartEpoch: uint64(0),
EndEpoch: uint64(1)})
Expand Down