Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type Policy struct {
Type string `json:"@type"`
Context any `json:"@context,omitempty"`
From string `json:"from,omitempty"`
For string `json:"for,omitempty"`
FromAgent string `json:"fromAgent,omitempty"`
FromRole string `json:"fromRole,omitempty"`
AboutParty string `json:"aboutParty,omitempty"`
Expand Down
22 changes: 22 additions & 0 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,28 @@ func TestPolicy_FromFieldRoundTrip(t *testing.T) {
}
}

func TestPolicy_ForFieldRoundTrip(t *testing.T) {
in := Policy{
Type: "RequireRelationshipConfirmation",
From: "did:pkh:eip155:1:0xabc",
For: "did:web:originator.vasp.example",
}
data, err := json.Marshal(in)
if err != nil {
t.Fatalf("marshal: %v", err)
}
if !bytes.Contains(data, []byte(`"for":"did:web:originator.vasp.example"`)) {
t.Fatalf("missing for in JSON: %s", string(data))
}
var out Policy
if err := json.Unmarshal(data, &out); err != nil {
t.Fatalf("unmarshal: %v", err)
}
if out.For != in.For {
t.Errorf("For = %q, want %q", out.For, in.For)
}
}

func TestTransactionConstraints_JSONRoundTrip(t *testing.T) {
tc := TransactionConstraints{
Purposes: []string{"BEXP", "SUPP"},
Expand Down