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

Unit test that sign_for returns a correct hash (RIPD-1583) #2333

Closed
wants to merge 1 commit into from

Conversation

scottschurr
Copy link
Collaborator

There was some discussion with one of our partners regarding the hash returned by sign_for and submit_multisigned. When I did manual testing I managed to get myself confused. So I figured that adding an automated unit test that exercises the hash returned by these two RPC commands would be time well spent.

@ripplelabs-jenkins
Copy link
Collaborator

Jenkins Build Summary

Built from this commit

Built at 20180115 - 17:40:32

Test Results

Build Type Result Status
clang.debug.unity 970 cases, 0 failed, t: 385s PASS ✅
coverage 970 cases, 0 failed, t: 608s PASS ✅
clang.debug.nounity 968 cases, 0 failed, t: 293s PASS ✅
gcc.debug.nounity 968 cases, 0 failed, t: 316s PASS ✅
gcc.debug.unity 970 cases, 0 failed, t: 430s PASS ✅
clang.release.unity 969 cases, 0 failed, t: 468s PASS ✅
gcc.release.unity 969 cases, 0 failed, t: 474s PASS ✅

@@ -1134,6 +1134,80 @@ class MultiSign_test : public beast::unit_test::suite
env.close();
}

void test_signForHash()
{
// Make sure that the "hash" field returned by the "sign_for" RPC
Copy link
Contributor

Choose a reason for hiding this comment

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

Only the last sign_for before submitting returns the "right" hash huh? In general, each signer doesn't know the hash to look out for though right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. Each added signature changes the hash. But if the transaction with those signatures is submitted, either as a blob through submit or as text through submit_multisigned, then the hash does not change.

As a use model, it is probably smartest to rely on the hash returned when the transaction is submitted. But since we are returning a hash value on signing, the value we return should be correct.

@sublimator
Copy link
Contributor

sublimator commented Jan 16, 2018 via email

Copy link
Contributor

@mellery451 mellery451 left a comment

Choose a reason for hiding this comment

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

👍

// Add the next signature and sign again.
jvSig2[jss::result][jss::account] = ghost.human();
jvSig2[jss::result][jss::secret] = ghost.name();
Json::Value jvSubmit = env.rpc (
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Json::Value jvSubmit might be better named Json::Value jvSig3.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually used jvSig3 initially. I changed the name because the JSON in jvSubmit is what we'll submit to the network (yeah, it's a unit test, so it's a network of one) on line 1190. So that's my justification for the variable name...

jvSig2[jss::result][jss::status].asString() == "success");

// Save the hash with one signature for use later.
std::string const hash1 =
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth checking any of the hash characteristics here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Possibly? To me the important characteristic of the hash is it that it allows me to look up the transaction in the ledger. So the various hash checks I'm doing throughout the test show three things:

  1. Adding the first signature provides us a hash. When we add the second signature, that also provides a hash. Those two hashes should be different. It would be easy to say, well of course they are different. But the ripple-online-tool had a bug where they were not different. So it's worth checking.
  2. If we submit the transaction with two signatures, the hash that comes back from that submission should be the same as the hash that we got back when we signed the second time.
  3. The hash returned when we submitted the transaction (which is the same as the hash returned when we signed the second time) should be able to locate the transaction in the ledger.

Are there other characteristics I should be testing for? Thanks.

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

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

👍 Left some minor comments, not holding back.

@scottschurr scottschurr added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Jan 25, 2018
@seelabs
Copy link
Collaborator

seelabs commented Jan 30, 2018

In 0.90.0-b5

@seelabs seelabs closed this Jan 30, 2018
@scottschurr scottschurr deleted the multisign-test-hash branch February 17, 2018 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants