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

CORE-18879: Ensure verifying notary implementation #5425

Merged

Conversation

jennyang-r3
Copy link
Contributor

@jennyang-r3 jennyang-r3 commented Jan 12, 2024

In this PR, I added more unit test cases for verifying notary, and checking any missing checks, and refactored the test.

added tests:

  • Contract verifying notary should successfully notarise if a signed tx verifies signatory signatures
  • Contract verifying notary should respond with error if contract verification failed
  • Contract verifying notary should respond with error if a signed transaction failed to signatory signature verification
  • Contract verifying notary should respond with error if either current or filtered tx is invalid
  • Contract verifying notary should respond with error if dependency is invalid
  • Contract verifying notary should respond with error if dependency reference is missing
  • Contract verifying notary should respond with error if dependency input is missing

@corda-jenkins-ci02
Copy link
Contributor

corda-jenkins-ci02 bot commented Jan 12, 2024

Jenkins build for PR 5425 build 8

Build Successful:
Jar artifact version produced by this PR: 5.2.0.0-alpha-1705398326782
Helm chart version produced by this PR: 5.2.0-alpha.1705398326782
Helm chart pushed to: oci://corda-os-docker-dev.software.r3.com/helm-charts/pr-5425/corda

@jennyang-r3 jennyang-r3 force-pushed the jennyang/CORE-17807-ensure-verifying-notary-impl branch from 30e4468 to 25eb26d Compare January 15, 2024 09:57
@jennyang-r3 jennyang-r3 marked this pull request as ready for review January 15, 2024 10:46
@jennyang-r3 jennyang-r3 requested a review from a team as a code owner January 15, 2024 10:46
Copy link
Contributor

@blsemo blsemo left a comment

Choose a reason for hiding this comment

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

I have few questions/remarks about the tests in this PR, see the comments inline, also:

  • Why is the ordering of the tests required? Does it make a difference in which order the tests are run? If yes, that is a bad code smell, if no, can we get rid of it?
  • A lot of these tests just check that exceptions thrown by other services are converted correctly - they do not check that the real thing would behave as expected on wrong or malicious inputs, so I think we still need to test most of these things as e2e tests. This is especially true for any test where you set a mock API to throw.

@@ -299,8 +401,13 @@ class ContractVerifyingNotaryServerFlowImplTest {
}

@Test
@Order(10)
fun `Contract verifying notary plugin server should respond with error if transaction verification fails`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

That title is wrong - it suggests that the transaction verification (i.e. of the initital transaction) fails - but it really is the Merkle proof verification of the dependencies that fails here.


@Test
@Order(16)
fun `Contract verifying notary should respond with error if either current or filtered tx is invalid`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the test case - in the real world, the initial transaction cannot be a dependency of itself, as it's not a valid, notarized transaction at this point yet.
If anything, this should complain that there is a circular dependency.

}

@Test
@Order(Integer.MAX_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this test need to be run last?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ordered test sorted out

@jennyang-r3 jennyang-r3 force-pushed the jennyang/CORE-17807-ensure-verifying-notary-impl branch from 53bdbd1 to 1910567 Compare January 15, 2024 17:21
@jennyang-r3 jennyang-r3 requested a review from blsemo January 16, 2024 09:34
@jennyang-r3 jennyang-r3 force-pushed the jennyang/CORE-17807-ensure-verifying-notary-impl branch from 1910567 to 429cdd4 Compare January 16, 2024 09:44
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@blsemo blsemo left a comment

Choose a reason for hiding this comment

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

LGTM

@jennyang-r3 jennyang-r3 changed the title CORE-17807: Ensure verifying notary implementation CORE-18879: Ensure verifying notary implementation Jan 16, 2024
@jennyang-r3 jennyang-r3 merged commit 96354b0 into release/os/5.2 Jan 16, 2024
5 checks passed
@jennyang-r3 jennyang-r3 deleted the jennyang/CORE-17807-ensure-verifying-notary-impl branch January 16, 2024 12:14
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.

2 participants