MCPcopy Create free account
hub / github.com/akash-network/node / TestCertHandlerRevoke

Function TestCertHandlerRevoke

x/cert/handler/handler_test.go:181–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestCertHandlerRevoke(t *testing.T) {
182 suite := setupTestSuite(t)
183
184 owner := testutil.AccAddress(t)
185 cert := testutil.Certificate(t, owner)
186
187 msgCreate := &types.MsgCreateCertificate{
188 Owner: owner.String(),
189 Cert: cert.PEM.Cert,
190 Pubkey: cert.PEM.Pub,
191 }
192
193 res, err := suite.handler(suite.ctx, msgCreate)
194 require.NoError(t, err)
195 require.NotNil(t, res)
196
197 resp, exists := suite.keeper.GetCertificateByID(suite.ctx, types.CertID{
198 Owner: owner,
199 Serial: cert.Serial,
200 })
201 require.True(t, exists)
202 testutil.CertificateRequireEqualResponse(t, cert, resp, types.CertificateValid)
203
204 msgRevoke := &types.MsgRevokeCertificate{
205 ID: types.ID{
206 Owner: owner.String(),
207 Serial: cert.Serial.String(),
208 },
209 }
210
211 res, err = suite.handler(suite.ctx, msgRevoke)
212 require.NoError(t, err)
213 require.NotNil(t, res)
214
215 resp, exists = suite.keeper.GetCertificateByID(suite.ctx, types.CertID{
216 Owner: owner,
217 Serial: cert.Serial,
218 })
219 require.True(t, exists)
220 testutil.CertificateRequireEqualResponse(t, cert, resp, types.CertificateRevoked)
221
222 res, err = suite.handler(suite.ctx, msgRevoke)
223 require.Error(t, err, types.ErrCertificateAlreadyRevoked.Error())
224 require.Nil(t, res)
225}
226
227func TestCertHandlerRevokeCreateRevoked(t *testing.T) {
228 suite := setupTestSuite(t)

Callers

nothing calls this directly

Calls 5

setupTestSuiteFunction · 0.70
GetCertificateByIDMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45
handlerMethod · 0.45

Tested by

no test coverage detected