Skip to content

Commit

Permalink
Implement coverage measurement - closes #25
Browse files Browse the repository at this point in the history
  • Loading branch information
ligi committed Jun 11, 2018
1 parent f446ce2 commit bd810d9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ task importFrom4ByteDirectory(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
}

task coverage(type: JavaExec) {
main = "org.ethereum.lists.methodsignatures.CoverageKt"
classpath = sourceSets.main.runtimeClasspath
}

task importFromSolidityDirectory(type: JavaExec) {
main = "org.ethereum.lists.methodsignatures.ImportSolidityDirectoryKt"
Expand Down
Binary file added signatures_sorted_counted.lst.gz
Binary file not shown.
32 changes: 32 additions & 0 deletions src/main/kotlin/org/ethereum/lists/methodsignatures/Coverage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.ethereum.lists.methodsignatures

import okhttp3.internal.io.FileSystem.SYSTEM
import okio.GzipSource
import okio.Okio.buffer
import org.kethereum.methodsignatures.FileBackedMethodSignatureStore
import java.io.File

fun main(args: Array<String>) {
val store = FileBackedMethodSignatureStore(signatureDirectory)

var found = 0
var missed = 0

val bufferedSource = buffer(GzipSource(SYSTEM.source(File("signatures_sorted_counted.lst.gz"))))
while (true) {
val line = bufferedSource.readUtf8Line()
if (line != null) {
val (count, signatureInfo) = line.trim().split(" ")
val (signature, calldataLength) = signatureInfo.split("-")
if (store.has(signature.replace("0x", ""))) {
found++
} else {
missed++
}
} else {
break
}

}
println("finished - found $found - missed $missed")
}

0 comments on commit bd810d9

Please sign in to comment.