-
Notifications
You must be signed in to change notification settings - Fork 370
Enable validation of milestones with additional hash modes and security levels #1041
Conversation
eadfb46
to
bd3c30d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the naming convention I want to start treating codacy-bot
like a human reviewer.
When it puts a comment either:
- Do the change
- Comment that the request is out of scope (like for the Npath complexity of an existing method)
- Argue that the pmd rule should be removed (I deleted some comments and I shall fix the pmd promptly)
} | ||
|
||
@Test | ||
public void milestoneValidationCURLP27() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stick with test naming conventions. Append ore prepend the word "test" (with proper capitalization).
Reason:
We currently use an old version of the maven surefire plugin that only runs tests that follow convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure? afaik this is only for the test file name.
from a local mvn test
run:
[INFO] Running com.iota.iri.MilestoneTrackerTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.276 s - in com.iota.iri.MilestoneTrackerTest
from travis: (https://travis-ci.org/iotaledger/iri/jobs/438230685#L995-L999)
[INFO] Running com.iota.iri.MilestoneTrackerTest
10/07 10:53:11.658 [main] INFO c.i.i.s.r.RocksDBPersistenceProvider - Initializing Database Backend...
10/07 10:53:11.717 [main] INFO c.i.i.s.r.RocksDBPersistenceProvider - RocksDB persistence provider initialized.
10/07 10:53:12.396 [main] INFO com.iota.iri.storage.Tangle - Shutting down Tangle Persistence Providers...
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.742 s - in com.iota.iri.MilestoneTrackerTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
} | ||
|
||
@Test | ||
public void milestoneValidationKERL() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} | ||
|
||
@Test | ||
public void milestoneValidationCURLP27SecLvl3() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} | ||
|
||
@Test | ||
public void milestoneValidationKERLSecLvl3() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly style comments
@@ -198,23 +197,29 @@ private Validity validateMilestone(SpongeFactory.Mode mode, TransactionViewModel | |||
else { | |||
for (final List<TransactionViewModel> bundleTransactionViewModels : bundleTransactions) { | |||
|
|||
//if (Arrays.equals(bundleTransactionViewModels.get(0).getHash(),transactionViewModel.getHash())) { | |||
if (bundleTransactionViewModels.get(0).getHash().equals(transactionViewModel.getHash())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to have bundleTransactionViewModels.get(0).getHash() be stored as a local variable outside the loop.
It can even be final because the loop opened a new scope.
if (bundleTransactionViewModels.get(0).getHash().equals(transactionViewModel.getHash())) { | ||
//the signed transaction - which references the confirmed transactions and contains the Merkle tree siblings. | ||
final TransactionViewModel siblingsTx = bundleTransactionViewModels.get(securityLevel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you change the line you can always remove the final
bb.put(digest); | ||
} | ||
|
||
final byte[] digests = bb.array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locally scoped final
byte[] address = ISS.address(mode, digests); | ||
|
||
//validate Merkle path | ||
final byte[] merkleRoot = ISS.getMerkleRoot(mode, address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locally scoped final
} | ||
|
||
@Test | ||
public void milestoneValidationCURLP27() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -4,8 +4,7 @@ | |||
import com.iota.iri.controllers.AddressViewModel; | |||
import com.iota.iri.controllers.MilestoneViewModel; | |||
import com.iota.iri.controllers.TransactionViewModel; | |||
import com.iota.iri.hash.ISS; | |||
import com.iota.iri.hash.SpongeFactory; | |||
import com.iota.iri.hash.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into it and apparently it is hard for static code analysis tools to handle stars. I will test later if it works better with checkstyle but currently I think it will be the same problem...
signatureFragmentTrits)), | ||
transactionViewModel2.trits(), 0, index, numOfKeysInMilestone); | ||
for (int i = 0; i < securityLevel; i++) { | ||
ISSInPlace.digest(mode, signedHash, ISS.NUMBER_OF_FRAGMENT_CHUNKS * i, bundleTransactionViewModels.get(i).getSignature(), 0, digest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on checkstyle will fail this becuase the line is too long
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While changing this remove all those whitespaces.
I usually don't mind them too much but you went overboard here.
…/milestonesSecLvl # Conflicts: # src/test/java/com/iota/iri/MilestoneTrackerTest.java
expand imports remove blank lines break lines
Description
Enable validation of milestones with additional hash modes (
CURLP27, CURLP81, KERL
) and security levels (1, 2, 3
)Type of change
How Has This Been Tested?
Checklist:
Please delete items that are not relevant.