Skip to content

Commit f05443e

Browse files
committed
Fix merge issues
1 parent c4f5eb8 commit f05443e

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

x/pki/handler_add_noc_cert_test.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ func TestHandler_AddNocX509Cert_SenderNotVendor(t *testing.T) {
1919
addNocX509Cert := types.NewMsgAddNocX509Cert(setup.Trustee1.String(), testconstants.NocCert1)
2020
_, err := setup.Handler(setup.Ctx, addNocX509Cert)
2121

22-
require.Error(t, err)
23-
require.True(t, sdkerrors.ErrUnauthorized.Is(err))
22+
require.ErrorIs(t, err, sdkerrors.ErrUnauthorized)
2423
}
2524

2625
func TestHandler_AddNocX509Cert_AddNew(t *testing.T) {
@@ -160,8 +159,7 @@ func TestHandler_AddNocX509Cert_Root_VID_Does_Not_Equal_To_AccountVID(t *testing
160159
// try to add NOC certificate
161160
nocX509Cert := types.NewMsgAddNocX509Cert(newAccAddress.String(), testconstants.NocCert1)
162161
_, err := setup.Handler(setup.Ctx, nocX509Cert)
163-
require.Error(t, err)
164-
require.True(t, pkitypes.ErrCertVidNotEqualAccountVid.Is(err))
162+
require.ErrorIs(t, err, pkitypes.ErrCertVidNotEqualAccountVid)
165163
}
166164

167165
func TestHandler_AddNocX509Cert_ForInvalidCertificate(t *testing.T) {
@@ -174,8 +172,7 @@ func TestHandler_AddNocX509Cert_ForInvalidCertificate(t *testing.T) {
174172
// add x509 certificate
175173
addX509Cert := types.NewMsgAddNocX509Cert(accAddress.String(), testconstants.StubCertPem)
176174
_, err := setup.Handler(setup.Ctx, addX509Cert)
177-
require.Error(t, err)
178-
require.True(t, pkitypes.ErrInvalidCertificate.Is(err))
175+
require.ErrorIs(t, err, pkitypes.ErrInvalidCertificate)
179176
}
180177

181178
func TestHandler_AddXNoc509Cert_ForNocRootCertificate(t *testing.T) {
@@ -188,8 +185,7 @@ func TestHandler_AddXNoc509Cert_ForNocRootCertificate(t *testing.T) {
188185
// try to add root certificate x509 certificate
189186
addX509Cert := types.NewMsgAddX509Cert(accAddress.String(), testconstants.NocRootCert1)
190187
_, err := setup.Handler(setup.Ctx, addX509Cert)
191-
require.Error(t, err)
192-
require.True(t, pkitypes.ErrInappropriateCertificateType.Is(err))
188+
require.ErrorIs(t, err, pkitypes.ErrNonRootCertificateSelfSigned)
193189
}
194190

195191
func TestHandler_AddXNoc509Cert_ForRootNonNocCertificate(t *testing.T) {
@@ -212,7 +208,6 @@ func TestHandler_AddXNoc509Cert_ForRootNonNocCertificate(t *testing.T) {
212208
// try to add root certificate x509 certificate
213209
addX509Cert := types.NewMsgAddNocX509Cert(accAddress.String(), testconstants.IntermediateCertWithVid1)
214210
_, err := setup.Handler(setup.Ctx, addX509Cert)
215-
require.Error(t, err)
216211
require.ErrorIs(t, err, pkitypes.ErrInappropriateCertificateType)
217212
}
218213

@@ -333,7 +328,7 @@ func TestHandler_AddNocX509Cert_CertificateExist(t *testing.T) {
333328
Vid: testconstants.VendorID1,
334329
},
335330
nocCert: testconstants.NocCert1,
336-
err: pkitypes.ErrCertVidNotEqualAccountVid,
331+
err: sdkerrors.ErrUnauthorized,
337332
},
338333
}
339334

x/pki/keeper/msg_server_add_noc_x_509_cert.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (k msgServer) AddNocX509Cert(goCtx context.Context, msg *types.MsgAddNocX50
6262

6363
// signer VID must be same as VID of existing certificates
6464
if accountVid != existingCertificate.Vid {
65-
return nil, pkitypes.NewErrExistingCertVidNotEqualAccountVid(
65+
return nil, pkitypes.NewErrUnauthorizedCertVendor(
6666
x509Certificate.Subject,
6767
x509Certificate.SubjectKeyID,
6868
existingCertificate.Vid,
@@ -86,7 +86,7 @@ func (k msgServer) AddNocX509Cert(goCtx context.Context, msg *types.MsgAddNocX50
8686
}
8787
// Check VID scoping
8888
if nocRootCert.Vid != accountVid {
89-
return nil, pkitypes.NewErrAccountVidNotEqualToCertVid(accountVid, nocRootCert.Vid)
89+
return nil, pkitypes.NewErrRootCertVidNotEqualToAccountVid(accountVid, nocRootCert.Vid)
9090
}
9191

9292
// create new certificate

0 commit comments

Comments
 (0)