Skip to content

Commit

Permalink
fix Authentication MarshalJSON recursion (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk authored Dec 10, 2024
1 parent 008f6f1 commit 2ed935a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion verifiable/did_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (a *Authentication) MarshalJSON() ([]byte, error) {
if a.did == "" {
return json.Marshal(a.CommonVerificationMethod)
} else {
return json.Marshal(a)
return json.Marshal(a.did)
}
}

Expand Down
12 changes: 12 additions & 0 deletions verifiable/did_doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,15 @@ func TestGistInfoProof_JSON_Unmarshal_Marshal(t *testing.T) {
require.NoError(t, err)
require.JSONEq(t, in, string(marshaled))
}

func TestAuthenticationMarshalUnmarshal(t *testing.T) {
in := "\"did:pkh:eip155:80002:0xE9D7fCDf32dF4772A7EF7C24c76aB40E4A42274a\""

var authentication Authentication
err := authentication.UnmarshalJSON([]byte(in))
require.NoError(t, err)

marshaled, err := authentication.MarshalJSON()
require.NoError(t, err)
require.JSONEq(t, in, string(marshaled))
}

0 comments on commit 2ed935a

Please sign in to comment.