aboutsummaryrefslogtreecommitdiffstats
path: root/params/config_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-23 23:36:38 +0800
committerGitHub <noreply@github.com>2017-03-23 23:36:38 +0800
commit8771c3061f340451d0966adcc547338a25f2231f (patch)
treec566cab81cf95a39f85fbe2c98a932af9495eb68 /params/config_test.go
parent11e7a712f469fb24ddb88ecebcefab6ed8880eb8 (diff)
parent37dd9086ec491900311fc39837f4a62ef5fd3a4a (diff)
downloaddexon-8771c3061f340451d0966adcc547338a25f2231f.tar
dexon-8771c3061f340451d0966adcc547338a25f2231f.tar.gz
dexon-8771c3061f340451d0966adcc547338a25f2231f.tar.bz2
dexon-8771c3061f340451d0966adcc547338a25f2231f.tar.lz
dexon-8771c3061f340451d0966adcc547338a25f2231f.tar.xz
dexon-8771c3061f340451d0966adcc547338a25f2231f.tar.zst
dexon-8771c3061f340451d0966adcc547338a25f2231f.zip
Merge pull request #3794 from fjl/core-genesis-refactor
core: refactor genesis handling
Diffstat (limited to 'params/config_test.go')
-rw-r--r--params/config_test.go81
1 files changed, 81 insertions, 0 deletions
diff --git a/params/config_test.go b/params/config_test.go
new file mode 100644
index 000000000..487dc380c
--- /dev/null
+++ b/params/config_test.go
@@ -0,0 +1,81 @@
+// Copyright 2017 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package params
+
+import (
+ "math/big"
+ "reflect"
+ "testing"
+)
+
+func TestCheckCompatible(t *testing.T) {
+ type test struct {
+ stored, new *ChainConfig
+ head uint64
+ wantErr *ConfigCompatError
+ }
+ tests := []test{
+ {stored: AllProtocolChanges, new: AllProtocolChanges, head: 0, wantErr: nil},
+ {stored: AllProtocolChanges, new: AllProtocolChanges, head: 100, wantErr: nil},
+ {
+ stored: &ChainConfig{EIP150Block: big.NewInt(10)},
+ new: &ChainConfig{EIP150Block: big.NewInt(20)},
+ head: 9,
+ wantErr: nil,
+ },
+ {
+ stored: AllProtocolChanges,
+ new: &ChainConfig{HomesteadBlock: nil},
+ head: 3,
+ wantErr: &ConfigCompatError{
+ What: "Homestead fork block",
+ StoredConfig: big.NewInt(0),
+ NewConfig: nil,
+ RewindTo: 0,
+ },
+ },
+ {
+ stored: AllProtocolChanges,
+ new: &ChainConfig{HomesteadBlock: big.NewInt(1)},
+ head: 3,
+ wantErr: &ConfigCompatError{
+ What: "Homestead fork block",
+ StoredConfig: big.NewInt(0),
+ NewConfig: big.NewInt(1),
+ RewindTo: 0,
+ },
+ },
+ {
+ stored: &ChainConfig{HomesteadBlock: big.NewInt(30), EIP150Block: big.NewInt(10)},
+ new: &ChainConfig{HomesteadBlock: big.NewInt(25), EIP150Block: big.NewInt(20)},
+ head: 25,
+ wantErr: &ConfigCompatError{
+ What: "EIP150 fork block",
+ StoredConfig: big.NewInt(10),
+ NewConfig: big.NewInt(20),
+ RewindTo: 9,
+ },
+ },
+ }
+
+ for _, test := range tests {
+ err := test.stored.CheckCompatible(test.new, test.head)
+ if !reflect.DeepEqual(err, test.wantErr) {
+ t.Errorf("error mismatch:\nstored: %v\nnew: %v\nhead: %v\nerr: %v\nwant: %v", test.stored, test.new, test.head, err, test.wantErr)
+ }
+ }
+}