From 5f4ef4fda20513d182260f5ebc926ea0507b7860 Mon Sep 17 00:00:00 2001 From: Chris Purta Date: Sat, 7 Jul 2018 07:46:01 -0700 Subject: [PATCH] ethash: add isPrivateNetwork test --- consensus/ethash/consensus_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/consensus/ethash/consensus_test.go b/consensus/ethash/consensus_test.go index 438a99dd66..cdf0ea0858 100644 --- a/consensus/ethash/consensus_test.go +++ b/consensus/ethash/consensus_test.go @@ -84,3 +84,21 @@ func TestCalcDifficulty(t *testing.T) { } } } + +func TestIsPrivateNetwork(t *testing.T) { + tests := make(map[*big.Int]bool) + + tests[big.NewInt(314)] = true + tests[params.MainnetChainConfig.ChainID] = false + tests[params.TestChainConfig.ChainID] = false + tests[params.RinkebyChainConfig.ChainID] = false + + for chainID, expected := range tests { + config := ¶ms.ChainConfig{ChainID: chainID} + + isPrivate := isPrivateNetwork(config) + if isPrivate != expected { + t.Error("Private chain test failed. Expected", expected, "but determined", isPrivate) + } + } +}