-
Notifications
You must be signed in to change notification settings - Fork 370
Add spent addresses export test #1561
base: dev
Are you sure you want to change the base?
Conversation
return Response.create({ | ||
amount: hashes.length, | ||
fileName: fileName, | ||
sizeInMb: new java.lang.Integer(file.length() / (1024 * 1024)), |
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.
Issue found: 'java' is not defined. (no-undef)
} | ||
|
||
return { | ||
amount: amount |
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.
Issue found: Expected property shorthand. (object-shorthand)
:param node: The node that the spent addresses will be merged into | ||
""" | ||
args = step.hashes | ||
for x in range(len(args)): |
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.
writer.write(hashes.length.toString() + separator); | ||
|
||
// Write spent addresses | ||
for (var i=0; i<hashes.length; i++){ |
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.
Issue found: 'i' is already defined. (no-redeclare)
var digest = java.security.MessageDigest.getInstance("SHA-256"); | ||
for (var i=0; i<hashes.length; i++){ | ||
// Update with hash bytes | ||
digest.update(hashes[i].bytes()); |
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.
|
||
var spentAddressProvider = IOTA.spentAddressesProvider | ||
|
||
var iri = com.iota.iri; |
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.
Issue found: 'com' is not defined. (no-undef)
}); | ||
} | ||
|
||
API.put("generateSpentAddressesFile", new Callable({ call: generate })) |
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.
Issue found: Missing semicolon. (semi)
|
||
// Write spent addresses | ||
for (var i=0; i<hashes.length; i++){ | ||
var hash = hashes[i].toString(); |
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.
@@ -0,0 +1,147 @@ | |||
var System = java.lang.System; |
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.
Issue found: 'java' is not defined. (no-undef)
} | ||
} else if (line.length() !== 64) { | ||
// This must be the amount | ||
amount = Number(line); |
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.
Issue found: 'line' is not defined. (no-undef)
} | ||
} | ||
} else { | ||
log.error("File {} did not exist on disk.. ignoring!", fileName) |
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.
Issue found: Missing semicolon. (semi)
}); | ||
} | ||
|
||
API.put("generateSpentAddressesFile", new Callable({ call: generate })) |
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.
Issue found: 'API' is not defined. (no-undef)
|
||
log.error("Caught error during read: {}", error); | ||
return { | ||
error: error |
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.
Issue found: Expected property shorthand. (object-shorthand)
var checksum; | ||
try { | ||
// False for always overwriting | ||
writer = new java.io.FileWriter(file, false); |
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.
Issue found: 'java' is not defined. (no-undef)
}); | ||
} | ||
|
||
API.put("mergeSpentAddresses", new Callable({ call: generate })) |
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.
Issue found: Missing semicolon. (semi)
var defaultSpentFileName = "spentAddresses.txt"; | ||
|
||
// Log using logger of the ixi class | ||
var log = org.slf4j.LoggerFactory.getLogger(iri.IXI.class); |
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.
Issue found: 'org' is not defined. (no-undef)
@@ -0,0 +1,147 @@ | |||
var System = java.lang.System; | |||
|
|||
var spentAddressProvider = IOTA.spentAddressesProvider |
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.
Issue found: 'IOTA' is not defined. (no-undef)
return false; | ||
} | ||
|
||
return expectedChecksum !== checksumFromBytes(digest.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.
@@ -0,0 +1,79 @@ | |||
var System = java.lang.System; |
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.
Issue found: 'java' is not defined. (no-undef)
amount: hashes.length, | ||
fileName: fileName, | ||
sizeInMb: new java.lang.Integer(file.length() / (1024 * 1024)), | ||
checksum: checksum |
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.
Issue found: Expected property shorthand. (object-shorthand)
while (line = targetReader.readLine()){ | ||
if (firstLine){ | ||
firstLine = false; | ||
} else if (line.length() === 64){ |
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.
Issue found: 'line' is not defined. (no-undef)
for (var i=0; i<files.length; i++){ | ||
var fileName = files[i]; | ||
|
||
var file = new java.io.File(fileName); |
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.
Issue found: 'java' is not defined. (no-undef)
@@ -0,0 +1,79 @@ | |||
var System = java.lang.System; | |||
|
|||
var spentAddressProvider = IOTA.spentAddressesProvider |
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.
Issue found: 'IOTA' is not defined. (no-undef)
var digest = java.security.MessageDigest.getInstance("SHA-256"); | ||
for (var i=0; i<hashes.length; i++){ | ||
// Update with hash bytes | ||
digest.update(hashes[i].bytes()); |
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.
@@ -0,0 +1,79 @@ | |||
var System = java.lang.System; | |||
|
|||
var spentAddressProvider = IOTA.spentAddressesProvider |
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.
Issue found: Missing semicolon. (semi)
Description
Adds a regression test for exporting and importing spentAddresses.txt files using the export-spent and merge-spent iri-extension tools. The tests export the spent addresses of one node into a file and checks to ensure that they have been exported correctly. It then imports the same addresses into an empty node and checks that the addresses were added as spent addresses.
**Note: This test currently only tests with one spent address db to test and is an incomplete PR until further notice. It should not be merged until the additional test has been added, but needs to be tested in the build pipeline to ensure it is working correctly.
Fixes #1468
Type of change
How Has This Been Tested?
Checklist: