2021-05-13 09:01:58 +00:00
|
|
|
import
|
|
|
|
std/[os],
|
|
|
|
unittest2, eth/common, nimcrypto/hash,
|
|
|
|
../nimbus/[genesis, config, chain_config]
|
2018-08-01 12:50:44 +00:00
|
|
|
|
2021-05-13 09:01:58 +00:00
|
|
|
const dataFolder = "tests" / "customgenesis"
|
|
|
|
|
|
|
|
proc genesisTest() =
|
2019-09-21 05:45:23 +00:00
|
|
|
suite "Genesis":
|
|
|
|
test "Correct mainnet hash":
|
|
|
|
let g = defaultGenesisBlockForNetwork(MainNet)
|
|
|
|
let b = g.toBlock
|
|
|
|
check(b.blockHash == "D4E56740F876AEF8C010B86A40D5F56745A118D0906A34E69AEC8C0DB1CB8FA3".toDigest)
|
2020-04-09 10:06:08 +00:00
|
|
|
|
|
|
|
test "Correct ropstennet hash":
|
|
|
|
let g = defaultGenesisBlockForNetwork(RopstenNet)
|
|
|
|
let b = g.toBlock
|
|
|
|
check(b.blockHash == "41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d".toDigest)
|
|
|
|
|
|
|
|
test "Correct rinkebynet hash":
|
|
|
|
let g = defaultGenesisBlockForNetwork(RinkebyNet)
|
|
|
|
let b = g.toBlock
|
|
|
|
check(b.blockHash == "6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177".toDigest)
|
|
|
|
|
|
|
|
test "Correct goerlinet hash":
|
|
|
|
let g = defaultGenesisBlockForNetwork(GoerliNet)
|
|
|
|
let b = g.toBlock
|
|
|
|
check(b.blockHash == "bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a".toDigest)
|
|
|
|
|
2021-05-13 09:01:58 +00:00
|
|
|
proc customGenesisTest() =
|
|
|
|
suite "Custom Genesis":
|
|
|
|
test "loadCustomGenesis":
|
|
|
|
var cga, cgb, cgc: CustomGenesis
|
|
|
|
check loadCustomGenesis(dataFolder / "berlin2000.json", cga)
|
|
|
|
check loadCustomGenesis(dataFolder / "chainid7.json", cgb)
|
|
|
|
check loadCustomGenesis(dataFolder / "noconfig.json", cgc)
|
2021-08-05 05:12:45 +00:00
|
|
|
check cga.config.poaEngine == false
|
|
|
|
check cgb.config.poaEngine == false
|
|
|
|
check cgc.config.poaEngine == false
|
|
|
|
|
|
|
|
test "calaveras.json":
|
|
|
|
var cg: CustomGenesis
|
|
|
|
check loadCustomGenesis(dataFolder / "calaveras.json", cg)
|
|
|
|
let h = toBlock(cg.genesis, nil)
|
|
|
|
let stateRoot = "664c93de37eb4a72953ea42b8c046cdb64c9f0b0bca5505ade8d970d49ebdb8c".toDigest
|
|
|
|
let genesisHash = "eb9233d066c275efcdfed8037f4fc082770176aefdbcb7691c71da412a5670f2".toDigest
|
|
|
|
check h.stateRoot == stateRoot
|
|
|
|
check h.blockHash == genesisHash
|
|
|
|
check cg.config.poaEngine == true
|
|
|
|
check cg.config.cliquePeriod == 30
|
|
|
|
check cg.config.cliqueEpoch == 30000
|
2021-05-13 09:01:58 +00:00
|
|
|
|
|
|
|
proc genesisMain*() =
|
|
|
|
genesisTest()
|
|
|
|
customGenesisTest()
|
|
|
|
|
2020-04-09 10:06:08 +00:00
|
|
|
when isMainModule:
|
|
|
|
genesisMain()
|