mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 09:41:38 +00:00
remove go-wire and go-crypto deps
This commit is contained in:
@ -2,14 +2,13 @@ package dummy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RandVal creates one random validator, with a key derived
|
// RandVal creates one random validator, with a key derived
|
||||||
// from the input value
|
// from the input value
|
||||||
func RandVal(i int) types.Validator {
|
func RandVal(i int) types.Validator {
|
||||||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(cmn.Fmt("test%d", i))).PubKey().Bytes()
|
pubkey := cmn.RandBytes(33)
|
||||||
power := cmn.RandUint16() + 1
|
power := cmn.RandUint16() + 1
|
||||||
return types.Validator{pubkey, int64(power)}
|
return types.Validator{pubkey, int64(power)}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/abci/example/code"
|
"github.com/tendermint/abci/example/code"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
dbm "github.com/tendermint/tmlibs/db"
|
dbm "github.com/tendermint/tmlibs/db"
|
||||||
"github.com/tendermint/tmlibs/log"
|
"github.com/tendermint/tmlibs/log"
|
||||||
@ -158,12 +157,12 @@ func (app *PersistentDummyApplication) execValidatorTx(tx []byte) types.Response
|
|||||||
Code: code.CodeTypeEncodingError,
|
Code: code.CodeTypeEncodingError,
|
||||||
Log: fmt.Sprintf("Pubkey (%s) is invalid hex", pubkeyS)}
|
Log: fmt.Sprintf("Pubkey (%s) is invalid hex", pubkeyS)}
|
||||||
}
|
}
|
||||||
_, err = crypto.PubKeyFromBytes(pubkey)
|
/*_, err = crypto.PubKeyFromBytes(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ResponseDeliverTx{
|
return types.ResponseDeliverTx{
|
||||||
Code: code.CodeTypeEncodingError,
|
Code: code.CodeTypeEncodingError,
|
||||||
Log: fmt.Sprintf("Pubkey (%X) is invalid go-crypto encoded", pubkey)}
|
Log: fmt.Sprintf("Pubkey (%X) is invalid go-crypto encoded", pubkey)}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// decode the power
|
// decode the power
|
||||||
power, err := strconv.ParseInt(powerS, 10, 64)
|
power, err := strconv.ParseInt(powerS, 10, 64)
|
||||||
|
34
glide.lock
generated
34
glide.lock
generated
@ -1,14 +1,6 @@
|
|||||||
hash: 68167c37a0b261e0adc172c3d92d943da89ff41112043d59ac60844ef8edd882
|
hash: 304088ee640b9e5897ece75503d07f800aabba0618bd668bf1144f478809b646
|
||||||
updated: 2018-02-03T02:00:50.200133389-05:00
|
updated: 2018-02-03T02:38:14.152640307-05:00
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/btcsuite/btcd
|
|
||||||
version: 2e60448ffcc6bf78332d1fe590260095f554dd78
|
|
||||||
subpackages:
|
|
||||||
- btcec
|
|
||||||
- name: github.com/davecgh/go-spew
|
|
||||||
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
|
||||||
subpackages:
|
|
||||||
- spew
|
|
||||||
- name: github.com/go-kit/kit
|
- name: github.com/go-kit/kit
|
||||||
version: 4dc7be5d2d12881735283bcab7352178e190fc71
|
version: 4dc7be5d2d12881735283bcab7352178e190fc71
|
||||||
subpackages:
|
subpackages:
|
||||||
@ -65,15 +57,6 @@ imports:
|
|||||||
- leveldb/storage
|
- leveldb/storage
|
||||||
- leveldb/table
|
- leveldb/table
|
||||||
- leveldb/util
|
- leveldb/util
|
||||||
- name: github.com/tendermint/ed25519
|
|
||||||
version: d8387025d2b9d158cf4efb07e7ebf814bcce2057
|
|
||||||
subpackages:
|
|
||||||
- edwards25519
|
|
||||||
- extra25519
|
|
||||||
- name: github.com/tendermint/go-crypto
|
|
||||||
version: 4fc3055dbd17aa1203d0abc64b9293f378da22ec
|
|
||||||
- name: github.com/tendermint/go-wire
|
|
||||||
version: dec83f641903b22f039da3974607859715d0377e
|
|
||||||
- name: github.com/tendermint/tmlibs
|
- name: github.com/tendermint/tmlibs
|
||||||
version: deaaf014d8b8d1095054380a38b1b00e293f725f
|
version: deaaf014d8b8d1095054380a38b1b00e293f725f
|
||||||
subpackages:
|
subpackages:
|
||||||
@ -81,15 +64,6 @@ imports:
|
|||||||
- db
|
- db
|
||||||
- log
|
- log
|
||||||
- process
|
- process
|
||||||
- name: golang.org/x/crypto
|
|
||||||
version: edd5e9b0879d13ee6970a50153d85b8fec9f7686
|
|
||||||
subpackages:
|
|
||||||
- nacl/secretbox
|
|
||||||
- openpgp/armor
|
|
||||||
- openpgp/errors
|
|
||||||
- poly1305
|
|
||||||
- ripemd160
|
|
||||||
- salsa20/salsa
|
|
||||||
- name: golang.org/x/net
|
- name: golang.org/x/net
|
||||||
version: d866cfc389cec985d6fda2859936a575a55a3ab6
|
version: d866cfc389cec985d6fda2859936a575a55a3ab6
|
||||||
subpackages:
|
subpackages:
|
||||||
@ -131,6 +105,10 @@ imports:
|
|||||||
- tap
|
- tap
|
||||||
- transport
|
- transport
|
||||||
testImports:
|
testImports:
|
||||||
|
- name: github.com/davecgh/go-spew
|
||||||
|
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
||||||
|
subpackages:
|
||||||
|
- spew
|
||||||
- name: github.com/pmezard/go-difflib
|
- name: github.com/pmezard/go-difflib
|
||||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -8,10 +8,6 @@ import:
|
|||||||
version: v0.8.0
|
version: v0.8.0
|
||||||
- package: github.com/spf13/cobra
|
- package: github.com/spf13/cobra
|
||||||
version: v0.0.1
|
version: v0.0.1
|
||||||
- package: github.com/tendermint/go-crypto
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/go-wire
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/tmlibs
|
- package: github.com/tendermint/tmlibs
|
||||||
version: develop
|
version: develop
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
abcicli "github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ func InitChain(client abcicli.Client) error {
|
|||||||
total := 10
|
total := 10
|
||||||
vals := make([]types.Validator, total)
|
vals := make([]types.Validator, total)
|
||||||
for i := 0; i < total; i++ {
|
for i := 0; i < total; i++ {
|
||||||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(cmn.Fmt("test%d", i))).PubKey().Bytes()
|
pubkey := cmn.RandBytes(33)
|
||||||
power := cmn.RandInt()
|
power := cmn.RandInt()
|
||||||
vals[i] = types.Validator{pubkey, int64(power)}
|
vals[i] = types.Validator{pubkey, int64(power)}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
wire "github.com/tendermint/go-wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -19,7 +18,7 @@ func WriteMessage(msg proto.Message, w io.Writer) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return wire.EncodeByteSlice(w, bz)
|
return encodeByteSlice(w, bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadMessage reads a varint length-delimited protobuf message.
|
// ReadMessage reads a varint length-delimited protobuf message.
|
||||||
@ -48,6 +47,26 @@ func readProtoMsg(r io.Reader, msg proto.Message, maxSize int) error {
|
|||||||
return proto.Unmarshal(buf, msg)
|
return proto.Unmarshal(buf, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// NOTE: we copied wire.EncodeByteSlice from go-wire rather than keep
|
||||||
|
// go-wire as a dep
|
||||||
|
|
||||||
|
func encodeByteSlice(w io.Writer, bz []byte) (err error) {
|
||||||
|
err = encodeVarint(w, int64(len(bz)))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = w.Write(bz)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarint(w io.Writer, i int64) (err error) {
|
||||||
|
var buf [10]byte
|
||||||
|
n := binary.PutVarint(buf[:], i)
|
||||||
|
_, err = w.Write(buf[0:n])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
func ToRequestEcho(message string) *Request {
|
func ToRequestEcho(message string) *Request {
|
||||||
|
@ -72,3 +72,31 @@ func TestWriteReadMessage(t *testing.T) {
|
|||||||
assert.Equal(t, c, msg)
|
assert.Equal(t, c, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteReadMessage2(t *testing.T) {
|
||||||
|
phrase := "hello-world"
|
||||||
|
cases := []proto.Message{
|
||||||
|
&ResponseCheckTx{
|
||||||
|
Data: []byte(phrase),
|
||||||
|
Log: phrase,
|
||||||
|
GasWanted: 10,
|
||||||
|
Tags: []cmn.KVPair{
|
||||||
|
cmn.KVPair{[]byte("abc"), []byte("def")},
|
||||||
|
},
|
||||||
|
// Fee: cmn.KI64Pair{
|
||||||
|
},
|
||||||
|
// TODO: add the rest
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range cases {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
err := WriteMessage(c, buf)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
msg := new(ResponseCheckTx)
|
||||||
|
err = ReadMessage(buf, msg)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, c, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user