diff --git a/.editorconfig b/.editorconfig index 3e168951..70deff0b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,12 @@ ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL ij_kotlin_name_count_to_use_star_import = 2147483647 ij_kotlin_name_count_to_use_star_import_for_members = 2147483647 ij_kotlin_packages_to_use_import_on_demand = unset +ij_any_line_comment_at_first_column = false +ij_any_add_a_space_at_line_comment_start = true + +[*.{gradle}] +ij_any_line_comment_at_first_column = false +ij_any_add_a_space_at_line_comment_start = true [*.go] indent_style = tab diff --git a/coordinator/ethereum/message-anchoring/build.gradle b/coordinator/ethereum/message-anchoring/build.gradle index e39da198..64aec479 100644 --- a/coordinator/ethereum/message-anchoring/build.gradle +++ b/coordinator/ethereum/message-anchoring/build.gradle @@ -3,19 +3,12 @@ plugins { } dependencies { - // TODO: review dependencies - implementation "io.vertx:vertx-core" implementation project(':jvm-libs:generic:vertx-helper') implementation project(':jvm-libs:generic:extensions:futures') - implementation project(':jvm-libs:linea:web3j-extensions') - implementation project(':coordinator:utilities') implementation project(':coordinator:core') implementation project(':coordinator:clients:smart-contract-client') implementation project(':coordinator:ethereum:common') - implementation project(':coordinator:ethereum:models-helper') - implementation project(':coordinator:clients:web3signer-client') - testImplementation "io.vertx:vertx-junit5" testImplementation project(':coordinator:ethereum:test-utils') } diff --git a/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/jvm/ResourcesUtil.kt b/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/jvm/ResourcesUtil.kt deleted file mode 100644 index c0ae1749..00000000 --- a/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/jvm/ResourcesUtil.kt +++ /dev/null @@ -1,24 +0,0 @@ -package build.linea.jvm - -import java.nio.file.Path - -object ResourcesUtil { - - /** - * Moves jar resource files to a temporary directory. - * @param resourcePath The path to the resource file inside the jar - * @param classLoader to use to find the resource. It's recommended to use SomeClass::class.java.classLoader - * where SomeClass is a class in the same jar as the resource file, otherwise the resource might not be found. - * @param tmpDirPrefix The prefix to use for the temporary directory. - */ - @JvmStatic - fun copyResourceToTmpDir( - resourcePath: String, - classLoader: ClassLoader, - tmpDirPrefix: String = "linea-resources-" - ): Path { - // WARNING: this is to keep backwards compatibility with package location - // otherwise, the we may get error at runtime: java.lang.NoClassDefFoundError: build/linea/jvm/ResourcesUtil - return linea.jvm.ResourcesUtil.copyResourceToTmpDir(resourcePath, classLoader, tmpDirPrefix) - } -} diff --git a/jvm-libs/linea/core/domain-models/src/main/kotlin/linea/domain/EthLog.kt b/jvm-libs/linea/core/domain-models/src/main/kotlin/linea/domain/EthLog.kt index 457ea437..9cf81b39 100644 --- a/jvm-libs/linea/core/domain-models/src/main/kotlin/linea/domain/EthLog.kt +++ b/jvm-libs/linea/core/domain-models/src/main/kotlin/linea/domain/EthLog.kt @@ -27,7 +27,7 @@ data class EthLog( if (blockNumber != other.blockNumber) return false if (!address.contentEquals(other.address)) return false if (!data.contentEquals(other.data)) return false - if (topics != other.topics) return false + if (topics.size != other.topics.size || !topics.zip(other.topics).all { (a, b) -> a.contentEquals(b) }) return false return true } @@ -41,7 +41,7 @@ data class EthLog( result = 31 * result + blockNumber.hashCode() result = 31 * result + address.contentHashCode() result = 31 * result + data.contentHashCode() - result = 31 * result + topics.hashCode() + result = 31 * result + topics.fold(1) { acc, topic -> 31 * acc + topic.contentHashCode() } return result } @@ -55,7 +55,7 @@ data class EthLog( "blockNumber=$blockNumber, " + "address=${address.encodeHex()}, " + "data=${data.encodeHex()}, " + - "topics=$topics)" + "topics=${topics.map { it.encodeHex() }})" } } diff --git a/jvm-libs/linea/core/domain-models/src/test/kotlin/linea/domain/EthLogTest.kt b/jvm-libs/linea/core/domain-models/src/test/kotlin/linea/domain/EthLogTest.kt new file mode 100644 index 00000000..7a3aacdc --- /dev/null +++ b/jvm-libs/linea/core/domain-models/src/test/kotlin/linea/domain/EthLogTest.kt @@ -0,0 +1,46 @@ +package linea.domain + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class EthLogTest { + val ethLog1 = EthLog( + removed = false, + logIndex = 2UL, + transactionIndex = 1UL, + transactionHash = byteArrayOf(1, 2, 3), + blockHash = byteArrayOf(4, 5, 6), + blockNumber = 123UL, + address = byteArrayOf(7, 8, 9), + data = byteArrayOf(10, 11, 12), + topics = listOf(byteArrayOf(13, 14), byteArrayOf(15, 16)) + ) + + @Test + fun `equals should return true for identical objects`() { + val ethLog2 = ethLog1.copy(topics = listOf(byteArrayOf(13, 14), byteArrayOf(15, 16))) + + assertThat(ethLog1).isEqualTo(ethLog2) + } + + @Test + fun `equals should return false for different objects`() { + val ethLog2 = ethLog1.copy(topics = listOf(byteArrayOf(13, 99), byteArrayOf(15, 16))) + + assertThat(ethLog1).isNotEqualTo(ethLog2) + } + + @Test + fun `hashCode should return the same value for identical objects`() { + val ethLog2 = ethLog1.copy(topics = listOf(byteArrayOf(13, 14), byteArrayOf(15, 16))) + + assertThat(ethLog1.hashCode()).isEqualTo(ethLog2.hashCode()) + } + + @Test + fun `hashCode should return different values for different objects`() { + val ethLog2 = ethLog1.copy(topics = listOf(byteArrayOf(13, 99), byteArrayOf(15, 16))) + + assertThat(ethLog1.hashCode()).isNotEqualTo(ethLog2.hashCode()) + } +}