mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-07 03:23:49 -05:00
Message anchoring v2 part1 (#854)
* coordinator: clean unnecessary dependcies and update .editorcofig to match spotless rules
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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() }})"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user