diff --git a/Makefile b/Makefile index e670b844..b2e5709e 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,8 @@ build_race: go build -race -o build/logjack github.com/tendermint/tendermint/cmd/logjack test: build + -rm -rf ~/.tendermint_test_bak + mv ~/.tendermint_test ~/.tendermint_test_bak go test github.com/tendermint/tendermint/... draw_deps: diff --git a/account/pub_key.go b/account/pub_key.go index 157b1aa3..a75c688e 100644 --- a/account/pub_key.go +++ b/account/pub_key.go @@ -2,7 +2,6 @@ package account import ( "bytes" - "errors" "github.com/tendermint/tendermint/Godeps/_workspace/src/github.com/tendermint/ed25519" "github.com/tendermint/tendermint/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519" @@ -12,7 +11,6 @@ import ( // PubKey is part of Account and Validator. type PubKey interface { - IsNil() bool Address() []byte VerifyBytes(msg []byte, sig Signature) bool } @@ -33,8 +31,6 @@ var _ = binary.RegisterInterface( // Implements PubKey type PubKeyEd25519 [32]byte -func (pubKey PubKeyEd25519) IsNil() bool { return false } - // TODO: Or should this just be BinaryRipemd160(key)? (The difference is the TypeByte.) func (pubKey PubKeyEd25519) Address() []byte { return binary.BinaryRipemd160(pubKey[:]) } @@ -60,14 +56,6 @@ func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte { return keyCurve25519 } -// redundant: compiler does it for us -func (pubKey PubKeyEd25519) ValidateBasic() error { - if len(pubKey) != ed25519.PublicKeySize { - return errors.New("Invalid PubKeyEd25519 key size") - } - return nil -} - func (pubKey PubKeyEd25519) String() string { return Fmt("PubKeyEd25519{%X}", pubKey[:]) } diff --git a/account/signature.go b/account/signature.go index b48023e7..ab4d1175 100644 --- a/account/signature.go +++ b/account/signature.go @@ -27,8 +27,6 @@ var _ = binary.RegisterInterface( // Implements Signature type SignatureEd25519 [64]byte -func (sig SignatureEd25519) IsNil() bool { return false } - func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } diff --git a/binary/reflect.go b/binary/reflect.go index fd4bb6bf..c54116af 100644 --- a/binary/reflect.go +++ b/binary/reflect.go @@ -670,7 +670,6 @@ func readReflectJSON(rv reflect.Value, rt reflect.Type, o interface{}, err *erro return } log.Debug("Read bytearray", "bytes", buf) - reflect.Copy(rv, reflect.ValueOf(buf)) } else { oSlice, ok := o.([]interface{}) diff --git a/binary/reflect_test.go b/binary/reflect_test.go index 563d7a15..b2a37c6b 100644 --- a/binary/reflect_test.go +++ b/binary/reflect_test.go @@ -16,40 +16,6 @@ type SimpleStruct struct { Time time.Time } -type SimpleArray [5]byte - -func TestSimpleArray(t *testing.T) { - var foo SimpleArray - - // Type of pointer to array - rt := reflect.TypeOf(&foo) - fmt.Printf("rt: %v\n", rt) - - // Type of array itself. - // NOTE: normally this is acquired through other means - // like introspecting on method signatures, or struct fields. - rte := rt.Elem() - fmt.Printf("rte: %v\n", rte) - - // Get a new pointer to the array - // NOTE: calling .Interface() is to get the actual value, - // instead of reflection values. - ptr := reflect.New(rte).Interface() - fmt.Printf("ptr: %v", ptr) - - // Make a simple int aray - fooArray := SimpleArray([5]byte{1, 10, 50, 100, 200}) - fooBytes := BinaryBytes(fooArray) - fooReader := bytes.NewReader(fooBytes) - - // Now you can read it. - n, err := new(int64), new(error) - it := ReadBinary(foo, fooReader, n, err) - fmt.Println(it, reflect.TypeOf(it)) -} - -//------------------------------------- - type Animal interface{} const ( @@ -502,3 +468,40 @@ func TestBadAlloc(t *testing.T) { res := ReadBinary(instance, b, n, err) fmt.Println(res, *err) } + +//------------------------------------------------------------------------------ + +type SimpleArray [5]byte + +func TestSimpleArray(t *testing.T) { + var foo SimpleArray + + // Type of pointer to array + rt := reflect.TypeOf(&foo) + fmt.Printf("rt: %v\n", rt) // *binary.SimpleArray + + // Type of array itself. + // NOTE: normally this is acquired through other means + // like introspecting on method signatures, or struct fields. + rte := rt.Elem() + fmt.Printf("rte: %v\n", rte) // binary.SimpleArray + + // Get a new pointer to the array + // NOTE: calling .Interface() is to get the actual value, + // instead of reflection values. + ptr := reflect.New(rte).Interface() + fmt.Printf("ptr: %v\n", ptr) // &[0 0 0 0 0] + + // Make a simple int aray + fooArray := SimpleArray([5]byte{1, 10, 50, 100, 200}) + fooBytes := BinaryBytes(fooArray) + fooReader := bytes.NewReader(fooBytes) + + // Now you can read it. + n, err := new(int64), new(error) + it := ReadBinary(foo, fooReader, n, err).(SimpleArray) + + if !bytes.Equal(it[:], fooArray[:]) { + t.Errorf("Expected %v but got %v", fooArray, it) + } +} diff --git a/state/execution.go b/state/execution.go index a2990559..24e45c8e 100644 --- a/state/execution.go +++ b/state/execution.go @@ -666,9 +666,6 @@ func ExecTx(blockCache *BlockCache, tx types.Tx, runCall bool, evc events.Fireab if err != nil { return err } - if err := tx.PubKey.ValidateBasic(); err != nil { - return err - } if !tx.PubKey.VerifyBytes(signBytes, tx.Signature) { return types.ErrTxInvalidSignature }