Skip to content

Commit

Permalink
update test vectors (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
decentralgabe authored May 1, 2024
1 parent b66231a commit 06d5688
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
9 changes: 5 additions & 4 deletions impl/internal/did/did_vectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package did
import (
"crypto/ed25519"
"fmt"
"strconv"
"strings"
"testing"

Expand All @@ -19,7 +20,7 @@ func TestVectors(t *testing.T) {
type testVectorDNSRecord struct {
Name string `json:"name"`
RecordType string `json:"type"`
TTL string `json:"ttl"`
TTL int `json:"ttl"`
Record []string `json:"rdata"`
}

Expand Down Expand Up @@ -65,7 +66,7 @@ func TestVectors(t *testing.T) {
if record.Header().Name == expectedRecord.Name {
s := record.String()
if strings.Contains(s, expectedRecord.RecordType) &&
strings.Contains(s, expectedRecord.TTL) &&
strings.Contains(s, strconv.Itoa(expectedRecord.TTL)) &&
strings.Contains(s, strings.Join(expectedRecord.Record, "")) {
matchedRecords[i] = true // Mark as matched
break
Expand Down Expand Up @@ -158,7 +159,7 @@ func TestVectors(t *testing.T) {
if record.Header().Name == expectedRecord.Name {
s := record.String()
if strings.Contains(s, expectedRecord.RecordType) &&
strings.Contains(s, expectedRecord.TTL) &&
strings.Contains(s, strconv.Itoa(expectedRecord.TTL)) &&
strings.Contains(s, strings.Join(expectedRecord.Record, "")) {
matchedRecords[i] = true // Mark as matched
break
Expand Down Expand Up @@ -254,7 +255,7 @@ func TestVectors(t *testing.T) {
if record.Header().Name == expectedRecord.Name {
s := record.String()
if strings.Contains(s, expectedRecord.RecordType) &&
strings.Contains(s, expectedRecord.TTL) {
strings.Contains(s, strconv.Itoa(expectedRecord.TTL)) {
// make sure all parts of the record are contained within s
for _, r := range expectedRecord.Record {
if !strings.Contains(s, r) {
Expand Down
4 changes: 2 additions & 2 deletions impl/internal/did/testdata/vector-1-dns-records.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
"name": "_did.cyuoqaf7itop8ohww4yn5ojg13qaq83r9zihgqntc5i9zwrfdfoo.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["v=0;vm=k0;auth=k0;asm=k0;inv=k0;del=k0"]
},
{
"name": "_k0._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=0;t=0;k=YCcHYL2sYNPDlKaALcEmll2HHyT968M4UWbr-9CFGWE"]
}
]
18 changes: 9 additions & 9 deletions impl/internal/did/testdata/vector-2-dns-records.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@
{
"name": "_did.cyuoqaf7itop8ohww4yn5ojg13qaq83r9zihgqntc5i9zwrfdfoo.",
"type": "NS",
"ttl": "7200",
"ttl": 7200,
"rdata": ["gateway1.example-did-dht-gateway.com."]
},
{
"name": "_did.cyuoqaf7itop8ohww4yn5ojg13qaq83r9zihgqntc5i9zwrfdfoo.",
"type": "NS",
"ttl": "7200",
"ttl": 7200,
"rdata": ["gateway2.example-did-dht-gateway.com."]
},
{
"name": "_did.cyuoqaf7itop8ohww4yn5ojg13qaq83r9zihgqntc5i9zwrfdfoo.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["v=0;vm=k0,k1;auth=k0;asm=k0,k1;inv=k0,k1;del=k0;svc=s0"]
},
{
"name": "_cnt._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["did:example:abcd"]
},
{
"name": "_aka._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["did:example:efgh,did:example:ijkl"]
},
{
"name": "_k0._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=0;t=0;k=YCcHYL2sYNPDlKaALcEmll2HHyT968M4UWbr-9CFGWE"]
},
{
"name": "_k1._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["t=1;k=Atf6NCChxjWpnrfPt1WDVE4ipYVSvi4pXCq4SUjx0jT9"]
},
{
"name": "_s0._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=service-1;t=TestService;se=https://test-service.com/1,https://test-service.com/2"]
},
{
"name": "_typ._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=1,2,3"]
}
]
16 changes: 8 additions & 8 deletions impl/internal/did/testdata/vector-3-dns-records.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
{
"name": "_prv._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=did:dht:x3heus3ke8fhgb5pbecday9wtbfynd6m19q4pm6gcf5j356qhjzo;s=Tt9DRT6J32v7O2lzbfasW63_FfagiMHTHxtaEOD7p85zHE0r_EfiNleyL6BZGyB1P-oQ5p6_7KONaHAjr2K6Bw"]
},
{
"name": "_did.sr6jgmcc84xig18ix66qbiwnzeiumocaaybh13f5w97bfzus4pcy.",
"type": "NS",
"ttl": "7200",
"ttl": 7200,
"rdata": ["gateway1.example-did-dht-gateway.com."]
},
{
"name": "_did.sr6jgmcc84xig18ix66qbiwnzeiumocaaybh13f5w97bfzus4pcy.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["v=0;vm=k0,k1;auth=k0;asm=k0;agm=k1;inv=k0;del=k0;svc=s0"]
},
{
"name": "_k0._did.",
"type": "TXT",
"ttl": "7200",
"ttl": 7200,
"rdata": ["id=0;t=0;k=sTyTLYw-n1NI9X-84NaCuis1wZjAA8lku6f6Et5201g"]
},
{
"name": "_k1._did.",
"type": "TXT",
"ttl": "7200",
"rdata": ["id=service-1;t=TestLongService;se=https://test-lllllllllllllllllllllllllllllllllllooooooooooooooooooooonnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssseeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrvvvvvvvvvvvvvvvvvvvviiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiccccccccccccccccccccccccccccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.com/1"]
"ttl": 7200,
"rdata": ["id=0;t=0;k=0"]
},
{
"name": "_s0._did.",
"type": "TXT",
"ttl": "7200",
"rdata": ["id=0;t=0;k=0"]
"ttl": 7200,
"rdata": ["id=service-1;t=TestLongService;se=https://test-lllllllllllllllllllllllllllllllllllooooooooooooooooooooonnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssseeeeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrvvvvvvvvvvvvvvvvvvvviiiiiiiiiiiiiiii", "iiiiiiiiiiiiiiiccccccccccccccccccccccccccccccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.com/1"]
}
]
6 changes: 4 additions & 2 deletions spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The DID DHT Method Specification 1.0

**Draft Created:** October 20, 2023

**Last Updated:** April 29, 2024
**Last Updated:** April 30, 2024

**Editors:**
~ [Gabe Cohen](https://github.com/decentralgabe)
Expand Down Expand Up @@ -1389,7 +1389,9 @@ what is specified in the registry. The DID also has two gateway records and a se

**Gateways:** `gateway1.example-did-dht-gateway.com.`, `gateway2.example-did-dht-gateway.com.`.

**Previous DID:** `did:dht:pxoem5sfzxxxrnrwfgiu5i5wc7epouy1jk9zb7ad159dsxbxy8io`.
**Previous DID:**
- ID: `did:dht:pxoem5sfzxxxrnrwfgiu5i5wc7epouy1jk9zb7ad159dsxbxy8io`.
- Signature: `Tt9DRT6J32v7O2lzbfasW63_FfagiMHTHxtaEOD7p85zHE0r_EfiNleyL6BZGyB1P-oQ5p6_7KONaHAjr2K6Bw`.

**DID Document:**

Expand Down

0 comments on commit 06d5688

Please sign in to comment.