Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Status List Updates #95

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Small Status List Updates #95

wants to merge 3 commits into from

Conversation

nitro-neal
Copy link
Contributor

Small updates to cred status list impl

@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Merging #95 (f73f4e1) into main (6ceafc5) will increase coverage by 1.05%.
The diff coverage is 57.69%.

@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
+ Coverage   69.92%   70.97%   +1.05%     
==========================================
  Files          21       21              
  Lines        1197     1199       +2     
  Branches      135      135              
==========================================
+ Hits          837      851      +14     
+ Misses        292      281      -11     
+ Partials       68       67       -1     
Components Coverage Δ
credentials 71.42% <57.69%> (+4.30%) ⬆️
crypto 33.33% <ø> (ø)
dids 92.81% <ø> (ø)
common 60.83% <ø> (ø)

if (response.status.isSuccess()) {
val body = response.bodyAsText()
return VerifiableCredential.parseJwt(body)
} else {
throw ClientRequestException(response, "Failed to retrieve VerifiableCredentialType from $url")
throw ClientRequestException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing inside a try block seems like a code smell to me. Is that intentional?

@nitro-neal nitro-neal changed the title Cred status list impl Small Status List Updates Oct 25, 2023
@@ -361,7 +395,7 @@ class StatusListCredentialTest {
}

@Test
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() = runBlocking {
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain the "asynchronously" here @nitro-neal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has to make an http GET to download the status list credential (vs passing in the status list credential object)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also confused by this. Asynchronously, to me, means that you would need to explicitly wait until the http GET downloads the credential. That doesn't seem to be what the test is doing. Furthermore, that implementation has a runBlocking bit, which actually makes the async call be blocking.

My suggestion is to rename to should validate if a credential is in the status list using a mock HTTP client

Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. There's a number of lines that aren't covered by tests. Would it make sense to expand the tests so that they're covered?

}

require(response.status.isSuccess()) {
"Failed to retrieve VerifiableCredentialType from $url with status ${response.status}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws an IllegalArgumentException. Is that what you intended?

"Failed to retrieve VerifiableCredentialType from $url with status ${response.status}"
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this try/catch block could be removed to simplify the code.


if (!duplicateSet.add(statusListEntry.statusListIndex)) {
throw IllegalArgumentException("duplicate entry found with index: ${statusListEntry.statusListIndex}")
throw IllegalArgumentException("Duplicate entry found with index: ${statusListEntry.statusListIndex}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw IllegalArgumentException("Duplicate entry found with index: ${statusListEntry.statusListIndex}")
"Duplicate entry found with index: ${statusListEntry.statusListIndex}"

@@ -361,7 +395,7 @@ class StatusListCredentialTest {
}

@Test
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() = runBlocking {
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also confused by this. Asynchronously, to me, means that you would need to explicitly wait until the http GET downloads the credential. That doesn't seem to be what the test is doing. Furthermore, that implementation has a runBlocking bit, which actually makes the async call be blocking.

My suggestion is to rename to should validate if a credential is in the status list using a mock HTTP client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants