From ee200d998fb42e23462569745c53c800fbdc6891 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 15 May 2017 02:46:28 +0200 Subject: [PATCH] Fix unwrap for proper json format --- encode_test.go | 4 ++-- pub_key.go | 3 +-- pubkeyinner_holder.go | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/encode_test.go b/encode_test.go index 6c5d03a1d..1b70d88ec 100644 --- a/encode_test.go +++ b/encode_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - data "github.com/tendermint/go-wire/data" wire "github.com/tendermint/go-wire" + data "github.com/tendermint/go-wire/data" ) type byter interface { @@ -58,7 +58,7 @@ func checkWireJSON(t *testing.T, in interface{}, reader interface{}, typ byte) { var err error js := wire.JSONBytes(in) btyp := fmt.Sprintf("[%d,", typ) - assert.True(t, strings.HasPrefix(string(js), btyp), string(js)) + assert.True(t, strings.HasPrefix(string(js), btyp), string(js), btyp) wire.ReadJSON(reader, js, &err) require.Nil(t, err, "%+v", err) diff --git a/pub_key.go b/pub_key.go index a4da59d2f..7483ff93a 100644 --- a/pub_key.go +++ b/pub_key.go @@ -22,8 +22,7 @@ func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) { // DO NOT USE THIS INTERFACE. // You probably want to use PubKey - -// +gen holder:"PubKey,Impl[PubKeyEd25519,PubKeySecp256k1]" +// +gen holder:"PubKey,Impl[PubKeyEd25519,PubKeySecp256k1],ed25519,secp256k1" type PubKeyInner interface { AssertIsPubKeyInner() Address() []byte diff --git a/pubkeyinner_holder.go b/pubkeyinner_holder.go index 16bfcf8a8..ee0ca9f00 100644 --- a/pubkeyinner_holder.go +++ b/pubkeyinner_holder.go @@ -13,7 +13,7 @@ import ( // Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com) type PubKey struct { - PubKeyInner + PubKeyInner "json:\"unwrap\"" } var PubKeyMapper = data.NewMapper(PubKey{}) @@ -46,7 +46,7 @@ func (h PubKey) Empty() bool { /*** below are bindings for each implementation ***/ func init() { - PubKeyMapper.RegisterImplementation(PubKeyEd25519{}, "pubkeyed25519", 0x1) + PubKeyMapper.RegisterImplementation(PubKeyEd25519{}, "ed25519", 0x1) } func (hi PubKeyEd25519) Wrap() PubKey { @@ -54,7 +54,7 @@ func (hi PubKeyEd25519) Wrap() PubKey { } func init() { - PubKeyMapper.RegisterImplementation(PubKeySecp256k1{}, "pubkeysecp256k1", 0x2) + PubKeyMapper.RegisterImplementation(PubKeySecp256k1{}, "secp256k1", 0x2) } func (hi PubKeySecp256k1) Wrap() PubKey {