@@ -2,6 +2,7 @@ package utils
22
33import (
44 "context"
5+ "slices"
56 "testing"
67
78 "github.com/bsv-blockchain/go-sdk/auth/certificates"
@@ -37,6 +38,8 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
3738 require .NoError (t , err )
3839 differentSubjectKey := differentSubject .PubKey ()
3940
41+ anyCertifier := wallet .PubKey (tu .GetByte33FromString ("any" ))
42+
4043 var requestedType [32 ]byte
4144 copy (requestedType [:], "requested_type" )
4245 var anotherType [32 ]byte
@@ -92,34 +95,36 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
9295 t .Run ("throws an error for unrequested certifier" , func (t * testing.T ) {
9396 // Create certificate request with different certifier
9497 certificatesRequested := & RequestedCertificateSet {
95- Certifiers : []wallet.Bytes33Hex {tu .GetByte33FromString ("another_certifier" )}, // Different from certifierHex
98+ Certifiers : []wallet.PubKey {tu .GetByte33FromString ("another_certifier" )}, // Different from certifierHex
9699 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
97100 requestedType : []string {"field1" },
98101 },
99102 }
100103
101104 // Check certifier match logic
102- assert .False (t , wallet .BytesInHex33Slice (certificatesRequested .Certifiers , validCertifierKey .ToDER ()))
105+ var certifierKey wallet.PubKey
106+ copy (certifierKey [:], validCertifierKey .ToDER ())
107+ assert .False (t , slices .Contains (certificatesRequested .Certifiers , certifierKey ))
103108 // The logic in ValidateCertificates would have raised an error here
104109 })
105110
106111 t .Run ("accepts 'any' as a certifier match" , func (t * testing.T ) {
107112 // Create certificate request with "any" certifier
108113 certificatesRequested := & RequestedCertificateSet {
109- Certifiers : []wallet.Bytes33Hex { tu . GetByte33FromString ( "any" ) },
114+ Certifiers : []wallet.PubKey { anyCertifier },
110115 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
111116 requestedType : []string {"field1" },
112117 },
113118 }
114119
115120 // "any" should match any certifier value
116- assert .True (t , wallet . BytesInHex33Slice (certificatesRequested .Certifiers , [] byte ( "any" ) ))
121+ assert .True (t , slices . Contains (certificatesRequested .Certifiers , anyCertifier ))
117122 })
118123
119124 t .Run ("throws an error for unrequested certificate type" , func (t * testing.T ) {
120125 // Create certificate request with different type
121126 certificatesRequested := & RequestedCertificateSet {
122- Certifiers : []wallet.Bytes33Hex { tu . GetByte33FromString ( "any" ) },
127+ Certifiers : []wallet.PubKey { anyCertifier },
123128 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
124129 anotherType : []string {"field1" }, // Different from "requested_type"
125130 },
@@ -133,7 +138,7 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
133138 t .Run ("validate certificates request set validation" , func (t * testing.T ) {
134139 // Test empty certifiers
135140 req := & RequestedCertificateSet {
136- Certifiers : []wallet.Bytes33Hex {},
141+ Certifiers : []wallet.PubKey {},
137142 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
138143 type1 : []string {"field1" },
139144 },
@@ -144,7 +149,7 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
144149
145150 // Test empty types
146151 req = & RequestedCertificateSet {
147- Certifiers : []wallet.Bytes33Hex {tu .GetByte33FromString ("certifier1" )},
152+ Certifiers : []wallet.PubKey {tu .GetByte33FromString ("certifier1" )},
148153 CertificateTypes : RequestedCertificateTypeIDAndFieldList {},
149154 }
150155 err = ValidateRequestedCertificateSet (req )
@@ -153,7 +158,7 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
153158
154159 // Test empty type name
155160 req = & RequestedCertificateSet {
156- Certifiers : []wallet.Bytes33Hex {tu .GetByte33FromString ("certifier1" )},
161+ Certifiers : []wallet.PubKey {tu .GetByte33FromString ("certifier1" )},
157162 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
158163 [32 ]byte {}: []string {"field1" },
159164 },
@@ -164,7 +169,7 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
164169
165170 // Test empty fields
166171 req = & RequestedCertificateSet {
167- Certifiers : []wallet.Bytes33Hex {tu .GetByte33FromString ("certifier1" )},
172+ Certifiers : []wallet.PubKey {tu .GetByte33FromString ("certifier1" )},
168173 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
169174 type1 : []string {},
170175 },
@@ -175,7 +180,7 @@ func TestValidateCertificatesFunctionality(t *testing.T) {
175180
176181 // Test valid request
177182 req = & RequestedCertificateSet {
178- Certifiers : []wallet.Bytes33Hex {tu .GetByte33FromString ("certifier1" )},
183+ Certifiers : []wallet.PubKey {tu .GetByte33FromString ("certifier1" )},
179184 CertificateTypes : RequestedCertificateTypeIDAndFieldList {
180185 type1 : []string {"field1" },
181186 },
0 commit comments