-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ATL-3693 DID Update operation causes operations counter blew up in PR…
…ISM Node (#810)
- Loading branch information
Shota Jolbordi
authored
Mar 17, 2023
1 parent
ba7b3e3
commit a801d7f
Showing
3 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...-backend/node/src/test/scala/io/iohk/atala/prism/node/metrics/OperationsCounterSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.iohk.atala.prism.node.metrics | ||
|
||
import io.iohk.atala.prism.crypto.EC.{INSTANCE => EC} | ||
import org.scalatest.wordspec.AnyWordSpec | ||
import io.iohk.atala.prism.node.services.BlockProcessingServiceSpec | ||
import io.iohk.atala.prism.protos.node_models.{AtalaOperation, SignedAtalaOperation} | ||
import org.scalatest.EitherValues._ | ||
import org.scalatest.matchers.must.Matchers | ||
|
||
import io.iohk.atala.prism.node.operations.{ | ||
CreateDIDOperationSpec, | ||
UpdateDIDOperationSpec, | ||
IssueCredentialBatchOperationSpec, | ||
RevokeCredentialsOperationSpec, | ||
ProtocolVersionUpdateOperationSpec, | ||
DeactivateDIDOperationSpec | ||
} | ||
|
||
class OperationsCounterSpec extends AnyWordSpec with Matchers { | ||
"countReceivedAtalaOperations" should { | ||
"count all types of operations" in { | ||
val signingKeyId = "master" | ||
val signingKey = EC.generateKeyPair().getPrivateKey | ||
def sign(op: AtalaOperation): SignedAtalaOperation = BlockProcessingServiceSpec.signOperation( | ||
op, | ||
signingKeyId, | ||
signingKey | ||
) | ||
|
||
val createDidOperation = sign(CreateDIDOperationSpec.exampleOperation) | ||
|
||
// Includes all type of update actions | ||
val updateDidOperation = sign(UpdateDIDOperationSpec.exampleAllActionsOperation) | ||
val issueCredentialBatchOperation = sign(IssueCredentialBatchOperationSpec.exampleOperation) | ||
val revokeCredentialsOperation = sign(RevokeCredentialsOperationSpec.revokeFullBatchOperation) | ||
val protocolVersionUpdateOperation = sign( | ||
ProtocolVersionUpdateOperationSpec.protocolUpdateOperation( | ||
ProtocolVersionUpdateOperationSpec.protocolVersionInfo1 | ||
) | ||
) | ||
val deactivateDIDOperation = sign(DeactivateDIDOperationSpec.exampleOperation) | ||
|
||
val operations = List( | ||
createDidOperation, | ||
updateDidOperation, | ||
issueCredentialBatchOperation, | ||
revokeCredentialsOperation, | ||
protocolVersionUpdateOperation, | ||
deactivateDIDOperation | ||
) | ||
|
||
OperationsCounters.countReceivedAtalaOperations(operations).value mustBe () | ||
|
||
} | ||
} | ||
} |