Chains config refactoring (#311)

Generate code from chains config
This commit is contained in:
Vyacheslav
2023-09-29 13:36:34 +03:00
committed by GitHub
parent a2c5743fb2
commit ef6af898e0
80 changed files with 1527 additions and 1321 deletions

View File

@@ -0,0 +1,44 @@
package org.drpc.chainsconfig
import io.emeraldpay.dshackle.config.ChainsConfigReader
import io.emeraldpay.dshackle.foundation.ChainOptionsReader
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
internal class ChainsConfigReaderTest {
@Test
fun `read standard config without custom`() {
val reader = ChainsConfigReader(ChainOptionsReader())
val config = reader.read(null)
val arb = config.resolve("arbitrum-goerli")
assertEquals(arb.chainId, "0x66eed")
assertEquals(arb.expectedBlockTime.seconds, 1L)
assertEquals(arb.options.validatePeers, false)
assertEquals(arb.id, "goerli")
val ethc = config.resolve("ethereum-classic")
assertEquals(ethc.chainId, "0x3d")
assertEquals(ethc.netVersion, 1)
assertEquals(ethc.code, "ETC")
assertEquals(ethc.grpcId, 101)
assertEquals(ethc.expectedBlockTime.seconds, 12)
assertEquals(ethc.laggingLagSize, 1)
assertEquals(ethc.syncingLagSize, 6)
assertEquals(ethc.id, "mainnet")
}
@Test
fun `read standard config with custom one`() {
val reader = ChainsConfigReader(ChainOptionsReader())
val chains = reader.read(this.javaClass.classLoader.getResourceAsStream("configs/chains-basic.yaml")!!)!!
val config = chains.resolve("fantom")
assertEquals(config.expectedBlockTime.seconds, 10)
assertEquals(config.chainId, "0xfb")
assertEquals(config.syncingLagSize, 11)
assertEquals(config.laggingLagSize, 4)
assertEquals(config.code, "FTA")
assertEquals(config.grpcId, 102)
assertEquals(config.netVersion, 251)
}
}