From ff8c648c2375f2d28c320495dbf8935a48ae0d8f Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 2 Mar 2018 09:26:37 -0500 Subject: [PATCH] types: uncomment some tests --- types/genesis_test.go | 4 ---- types/heartbeat_test.go | 2 -- types/priv_validator_test.go | 11 +++++++---- types/validator_set.go | 1 - 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/types/genesis_test.go b/types/genesis_test.go index 3cbe8e28..aa713289 100644 --- a/types/genesis_test.go +++ b/types/genesis_test.go @@ -28,14 +28,10 @@ func TestGenesis(t *testing.T) { assert.Error(t, err, "expected error for empty genDoc json") } - /* TODO WIRE enable json ... // test a good one by raw json genDocBytes := []byte(`{"genesis_time":"0001-01-01T00:00:00Z","chain_id":"test-chain-QDKdJr","consensus_params":null,"validators":[{"pub_key":{"type":"ed25519","data":"961EAB8752E51A03618502F55C2B6E09C38C65635C64CCF3173ED452CF86C957"},"power":10,"name":""}],"app_hash":"","app_state":{"account_owner": "Bob"}}`) _, err := GenesisDocFromJSON(genDocBytes) assert.NoError(t, err, "expected no error for good genDoc json") - */ - var genDocBytes []byte - var err error // create a base gendoc from struct baseGenDoc := &GenesisDoc{ diff --git a/types/heartbeat_test.go b/types/heartbeat_test.go index 055f26f7..20663616 100644 --- a/types/heartbeat_test.go +++ b/types/heartbeat_test.go @@ -32,7 +32,6 @@ func TestHeartbeatString(t *testing.T) { require.Equal(t, hb.String(), "Heartbeat{1:000000000000 11/02 (0) {/FF41E371B9BF.../}}") } -/* TODO WIRE make json work func TestHeartbeatWriteSignBytes(t *testing.T) { hb := &Heartbeat{ValidatorIndex: 1, Height: 10, Round: 1} @@ -49,4 +48,3 @@ func TestHeartbeatWriteSignBytes(t *testing.T) { require.Equal(t, string(bz), "null") }) } -*/ diff --git a/types/priv_validator_test.go b/types/priv_validator_test.go index fba6f10e..edfcdf58 100644 --- a/types/priv_validator_test.go +++ b/types/priv_validator_test.go @@ -1,15 +1,19 @@ package types import ( + "encoding/hex" + "encoding/json" + "fmt" + "os" "testing" "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" crypto "github.com/tendermint/go-crypto" cmn "github.com/tendermint/tmlibs/common" ) -/* TODO WIRE make json work ... func TestGenLoadValidator(t *testing.T) { assert := assert.New(t) @@ -73,7 +77,7 @@ func TestUnmarshalValidator(t *testing.T) { }`, addrStr, pubStr, privStr) val := PrivValidatorFS{} - err = wire.UnmarshalJSON([]byte(serialized), &val) + err = json.Unmarshal([]byte(serialized), &val) require.Nil(err, "%+v", err) // make sure the values match @@ -82,11 +86,10 @@ func TestUnmarshalValidator(t *testing.T) { assert.EqualValues(privKey, val.PrivKey) // export it and make sure it is the same - out, err := wire.MarshalJSON(val) + out, err := json.Marshal(val) require.Nil(err, "%+v", err) assert.JSONEq(serialized, string(out)) } -*/ func TestSignVote(t *testing.T) { assert := assert.New(t) diff --git a/types/validator_set.go b/types/validator_set.go index 714f47e7..83d066ec 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -252,7 +252,6 @@ func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height return fmt.Errorf("Invalid commit -- not precommit @ index %v", idx) } _, val := valSet.GetByIndex(idx) - fmt.Println("IDX", idx, val) // Validate signature precommitSignBytes := precommit.SignBytes(chainID) if !val.PubKey.VerifyBytes(precommitSignBytes, precommit.Signature) {