mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-17 15:11:21 +00:00
Fix unwrap for proper json format
This commit is contained in:
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
data "github.com/tendermint/go-wire/data"
|
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
|
data "github.com/tendermint/go-wire/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
type byter interface {
|
type byter interface {
|
||||||
@ -58,7 +58,7 @@ func checkWireJSON(t *testing.T, in interface{}, reader interface{}, typ byte) {
|
|||||||
var err error
|
var err error
|
||||||
js := wire.JSONBytes(in)
|
js := wire.JSONBytes(in)
|
||||||
btyp := fmt.Sprintf("[%d,", typ)
|
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)
|
wire.ReadJSON(reader, js, &err)
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
|
@ -22,8 +22,7 @@ func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) {
|
|||||||
|
|
||||||
// DO NOT USE THIS INTERFACE.
|
// DO NOT USE THIS INTERFACE.
|
||||||
// You probably want to use PubKey
|
// You probably want to use PubKey
|
||||||
|
// +gen holder:"PubKey,Impl[PubKeyEd25519,PubKeySecp256k1],ed25519,secp256k1"
|
||||||
// +gen holder:"PubKey,Impl[PubKeyEd25519,PubKeySecp256k1]"
|
|
||||||
type PubKeyInner interface {
|
type PubKeyInner interface {
|
||||||
AssertIsPubKeyInner()
|
AssertIsPubKeyInner()
|
||||||
Address() []byte
|
Address() []byte
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
// Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
|
// Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
|
||||||
|
|
||||||
type PubKey struct {
|
type PubKey struct {
|
||||||
PubKeyInner
|
PubKeyInner "json:\"unwrap\""
|
||||||
}
|
}
|
||||||
|
|
||||||
var PubKeyMapper = data.NewMapper(PubKey{})
|
var PubKeyMapper = data.NewMapper(PubKey{})
|
||||||
@ -46,7 +46,7 @@ func (h PubKey) Empty() bool {
|
|||||||
/*** below are bindings for each implementation ***/
|
/*** below are bindings for each implementation ***/
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
PubKeyMapper.RegisterImplementation(PubKeyEd25519{}, "pubkeyed25519", 0x1)
|
PubKeyMapper.RegisterImplementation(PubKeyEd25519{}, "ed25519", 0x1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hi PubKeyEd25519) Wrap() PubKey {
|
func (hi PubKeyEd25519) Wrap() PubKey {
|
||||||
@ -54,7 +54,7 @@ func (hi PubKeyEd25519) Wrap() PubKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
PubKeyMapper.RegisterImplementation(PubKeySecp256k1{}, "pubkeysecp256k1", 0x2)
|
PubKeyMapper.RegisterImplementation(PubKeySecp256k1{}, "secp256k1", 0x2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hi PubKeySecp256k1) Wrap() PubKey {
|
func (hi PubKeySecp256k1) Wrap() PubKey {
|
||||||
|
Reference in New Issue
Block a user