Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro committed Jun 24, 2024
1 parent 545e569 commit bebb476
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.hyperledger.identus.connect.core.model.ConnectionRecord.*
import org.hyperledger.identus.mercury.model.DidId
import org.hyperledger.identus.mercury.protocol.connection.{ConnectionRequest, ConnectionResponse}
import org.hyperledger.identus.mercury.protocol.invitation.v2.Invitation
import org.hyperledger.identus.shared.models.*
import org.hyperledger.identus.shared.models.{WalletAccessContext, WalletId}
import zio.{Cause, Exit, ZIO, ZLayer}
import zio.test.*
Expand Down Expand Up @@ -341,7 +342,10 @@ object ConnectionRepositorySpecSuite {
aRecord = connectionRecord
_ <- repo.create(aRecord)
record <- repo.findById(aRecord.id)
count <- repo.updateAfterFail(aRecord.id, Some("Just to test")) // TEST
count <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("ConnectionRepositorySpecSuite", StatusCode(999), "Just to test"))
) // TEST
updatedRecord1 <- repo.findById(aRecord.id)
response = ConnectionResponse.makeResponseFromRequest(connectionRequest.makeMessage).toOption.get
_ <- repo.updateWithConnectionResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.hyperledger.identus.mercury.model.DidId
import org.hyperledger.identus.mercury.protocol.issuecredential.{IssueCredential, RequestCredential}
import org.hyperledger.identus.pollux.core.model.*
import org.hyperledger.identus.pollux.core.model.IssueCredentialRecord.*
import org.hyperledger.identus.shared.models.*
import org.hyperledger.identus.shared.models.{WalletAccessContext, WalletId}
import org.hyperledger.identus.shared.models.KeyId
import zio.{Exit, ZIO, ZLayer}
Expand Down Expand Up @@ -394,7 +395,10 @@ object CredentialRepositorySpecSuite {
repo <- ZIO.service[CredentialRepository]
_ <- repo.create(aRecord)
record0 <- repo.findById(aRecord.id)
_ <- repo.updateAfterFail(aRecord.id, Some("Just to test")) // TEST
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "Just to test"))
)
updatedRecord1 <- repo.findById(aRecord.id)
_ <- repo.updateProtocolState(aRecord.id, ProtocolState.OfferPending, ProtocolState.OfferSent)
updatedRecord2 <- repo.findById(aRecord.id)
Expand All @@ -417,12 +421,30 @@ object CredentialRepositorySpecSuite {
repo <- ZIO.service[CredentialRepository]
_ <- repo.create(aRecord)
record0 <- repo.findById(aRecord.id)
_ <- repo.updateAfterFail(aRecord.id, Some("1 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("2 - Just to test"))
- <- repo.updateAfterFail(aRecord.id, Some("3 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("4 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("5 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("6 - Just to test"))
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "1 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "2 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "3 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "4 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "5 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("CredentialRepositorySpecSuite", StatusCode(999), "6 - Just to test"))
)
// The 6 retry should not happen since the max retries is 5
// (but should also not have an effect other that update the error message)
updatedRecord1 <- repo.findById(aRecord.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.hyperledger.identus.mercury.protocol.presentproof.{Presentation, Prop
import org.hyperledger.identus.pollux.core.model.*
import org.hyperledger.identus.pollux.core.model.PresentationRecord.*
import org.hyperledger.identus.pollux.core.service.serdes.{AnoncredCredentialProofV1, AnoncredCredentialProofsV1}
import org.hyperledger.identus.shared.models.*
import org.hyperledger.identus.shared.models.{WalletAccessContext, WalletId}
import zio.{ZIO, ZLayer}
import zio.test.*
Expand Down Expand Up @@ -322,7 +323,10 @@ object PresentationRepositorySpecSuite {
repo <- ZIO.service[PresentationRepository]
tmp <- repo.createPresentationRecord(aRecord)
record0 <- repo.findPresentationRecord(aRecord.id)
_ <- repo.updateAfterFail(aRecord.id, Some("Just to test")) // TEST
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "Just to test"))
) // TEST
updatedRecord1 <- repo.findPresentationRecord(aRecord.id)
_ <- repo.updatePresentationRecordProtocolState(
aRecord.id,
Expand All @@ -348,12 +352,30 @@ object PresentationRepositorySpecSuite {
repo <- ZIO.service[PresentationRepository]
_ <- repo.createPresentationRecord(aRecord)
record0 <- repo.findPresentationRecord(aRecord.id)
_ <- repo.updateAfterFail(aRecord.id, Some("1 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("2 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("3 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("4 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("5 - Just to test"))
_ <- repo.updateAfterFail(aRecord.id, Some("6 - Just to test"))
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "1 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "2 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "3 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "4 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "5 - Just to test"))
)
_ <- repo.updateAfterFail(
aRecord.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "6 - Just to test"))
)
// The 6 retry should not happen since the max retries is 5
// (but should also not have an effect other that update the error message)
updatedRecord1 <- repo.findPresentationRecord(aRecord.id)
Expand Down Expand Up @@ -413,7 +435,13 @@ object PresentationRepositorySpecSuite {
record1 = presentationRecord
record2 = presentationRecord
_ <- repo.createPresentationRecord(record1).provide(wallet1)
exit <- repo.updateAfterFail(record2.id, Some("fail reason")).provide(wallet2).exit
exit <- repo
.updateAfterFail(
record2.id,
Some(FailureInfo("PresentationRepositorySpecSuite", StatusCode(999), "fail reason"))
)
.provide(wallet2)
.exit
} yield assert(exit)(dies(hasMessage(equalTo("Unexpected affected row count: 0"))))
},
test("unable to updatePresentationRecordProtocolState PresentationRecord outside of the wallet") {
Expand Down

0 comments on commit bebb476

Please sign in to comment.