cmd/puppeth: update chain spec of parity (#20241)

This commit is contained in:
gary rong
2019-11-20 18:46:35 +08:00
committed by Péter Szilágyi
parent 9b59c75405
commit b7ba944e88
3 changed files with 148 additions and 62 deletions

View File

@ -17,6 +17,7 @@
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"reflect"
@ -80,29 +81,15 @@ func TestParitySturebyConverter(t *testing.T) {
if err != nil {
t.Fatalf("failed creating chainspec: %v", err)
}
enc, err := json.MarshalIndent(spec, "", " ")
if err != nil {
t.Fatalf("failed encoding chainspec: %v", err)
}
expBlob, err := ioutil.ReadFile("testdata/stureby_parity.json")
if err != nil {
t.Fatalf("could not read file: %v", err)
}
expspec := &parityChainSpec{}
if err := json.Unmarshal(expBlob, expspec); err != nil {
t.Fatalf("failed parsing genesis: %v", err)
}
expspec.Nodes = []string{}
if !reflect.DeepEqual(expspec, spec) {
t.Errorf("chainspec mismatch")
c := spew.ConfigState{
DisablePointerAddresses: true,
SortKeys: true,
}
exp := strings.Split(c.Sdump(expspec), "\n")
got := strings.Split(c.Sdump(spec), "\n")
for i := 0; i < len(exp) && i < len(got); i++ {
if exp[i] != got[i] {
t.Logf("got: %v\nexp: %v\n", exp[i], got[i])
}
}
if !bytes.Equal(expBlob, enc) {
t.Fatalf("chainspec mismatch")
}
}