mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-29 16:52:15 +00:00
parent
7689c15413
commit
904a3115a6
@ -25,15 +25,18 @@ BUG FIXES:
|
|||||||
- Graceful handling/recovery for apps that have non-determinism or fail to halt
|
- Graceful handling/recovery for apps that have non-determinism or fail to halt
|
||||||
- Graceful handling/recovery for violations of safety, or liveness
|
- Graceful handling/recovery for violations of safety, or liveness
|
||||||
|
|
||||||
## 0.17.2 (TBD)
|
## 0.18.0 (TBD)
|
||||||
|
|
||||||
BUG FIXES:
|
BREAKING:
|
||||||
- [rpc] fix subscribing using an abci.ResponseDeliverTx tag
|
- [p2p] require all addresses come with an ID no matter what
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
- [rpc] `/tx` and `/tx_search` responses now include the transaction hash
|
- [rpc] `/tx` and `/tx_search` responses now include the transaction hash
|
||||||
- [rpc] include validator power in `/status`
|
- [rpc] include validator power in `/status`
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
- [rpc] fix subscribing using an abci.ResponseDeliverTx tag
|
||||||
|
|
||||||
## 0.17.1 (March 27th, 2018)
|
## 0.17.1 (March 27th, 2018)
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
@ -72,7 +72,7 @@ func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log
|
|||||||
|
|
||||||
// Determine internal address...
|
// Determine internal address...
|
||||||
var intAddr *NetAddress
|
var intAddr *NetAddress
|
||||||
intAddr, err = NewNetAddressString(lAddr)
|
intAddr, err = NewNetAddressStringWithOptionalID(lAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -49,33 +49,45 @@ func NewNetAddress(id ID, addr net.Addr) *NetAddress {
|
|||||||
}
|
}
|
||||||
ip := tcpAddr.IP
|
ip := tcpAddr.IP
|
||||||
port := uint16(tcpAddr.Port)
|
port := uint16(tcpAddr.Port)
|
||||||
netAddr := NewNetAddressIPPort(ip, port)
|
na := NewNetAddressIPPort(ip, port)
|
||||||
netAddr.ID = id
|
na.ID = id
|
||||||
return netAddr
|
return na
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNetAddressString returns a new NetAddress using the provided
|
// NewNetAddressString returns a new NetAddress using the provided address in
|
||||||
// address in the form of "ID@IP:Port", where the ID is optional.
|
// the form of "ID@IP:Port".
|
||||||
// Also resolves the host if host is not an IP.
|
// Also resolves the host if host is not an IP.
|
||||||
func NewNetAddressString(addr string) (*NetAddress, error) {
|
func NewNetAddressString(addr string) (*NetAddress, error) {
|
||||||
addr = removeProtocolIfDefined(addr)
|
spl := strings.Split(addr, "@")
|
||||||
|
if len(spl) < 2 {
|
||||||
|
return nil, fmt.Errorf("Address (%s) does not contain ID", addr)
|
||||||
|
}
|
||||||
|
return NewNetAddressStringWithOptionalID(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNetAddressStringWithOptionalID returns a new NetAddress using the
|
||||||
|
// provided address in the form of "ID@IP:Port", where the ID is optional.
|
||||||
|
// Also resolves the host if host is not an IP.
|
||||||
|
func NewNetAddressStringWithOptionalID(addr string) (*NetAddress, error) {
|
||||||
|
addrWithoutProtocol := removeProtocolIfDefined(addr)
|
||||||
|
|
||||||
var id ID
|
var id ID
|
||||||
spl := strings.Split(addr, "@")
|
spl := strings.Split(addrWithoutProtocol, "@")
|
||||||
if len(spl) == 2 {
|
if len(spl) == 2 {
|
||||||
idStr := spl[0]
|
idStr := spl[0]
|
||||||
idBytes, err := hex.DecodeString(idStr)
|
idBytes, err := hex.DecodeString(idStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, fmt.Sprintf("Address (%s) contains invalid ID", addr))
|
return nil, errors.Wrapf(err, "Address (%s) contains invalid ID", addrWithoutProtocol)
|
||||||
}
|
}
|
||||||
if len(idBytes) != IDByteLength {
|
if len(idBytes) != IDByteLength {
|
||||||
return nil, fmt.Errorf("Address (%s) contains ID of invalid length (%d). Should be %d hex-encoded bytes",
|
return nil, fmt.Errorf("Address (%s) contains ID of invalid length (%d). Should be %d hex-encoded bytes",
|
||||||
addr, len(idBytes), IDByteLength)
|
addrWithoutProtocol, len(idBytes), IDByteLength)
|
||||||
}
|
|
||||||
id, addr = ID(idStr), spl[1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
host, portStr, err := net.SplitHostPort(addr)
|
id, addrWithoutProtocol = ID(idStr), spl[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
host, portStr, err := net.SplitHostPort(addrWithoutProtocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -120,11 +132,10 @@ func NewNetAddressStrings(addrs []string) ([]*NetAddress, []error) {
|
|||||||
// NewNetAddressIPPort returns a new NetAddress using the provided IP
|
// NewNetAddressIPPort returns a new NetAddress using the provided IP
|
||||||
// and port number.
|
// and port number.
|
||||||
func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress {
|
func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress {
|
||||||
na := &NetAddress{
|
return &NetAddress{
|
||||||
IP: ip,
|
IP: ip,
|
||||||
Port: port,
|
Port: port,
|
||||||
}
|
}
|
||||||
return na
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equals reports whether na and other are the same addresses,
|
// Equals reports whether na and other are the same addresses,
|
||||||
|
@ -9,20 +9,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewNetAddress(t *testing.T) {
|
func TestNewNetAddress(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
tcpAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:8080")
|
tcpAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:8080")
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
addr := NewNetAddress("", tcpAddr)
|
addr := NewNetAddress("", tcpAddr)
|
||||||
|
|
||||||
assert.Equal("127.0.0.1:8080", addr.String())
|
assert.Equal(t, "127.0.0.1:8080", addr.String())
|
||||||
|
|
||||||
assert.NotPanics(func() {
|
assert.NotPanics(t, func() {
|
||||||
NewNetAddress("", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8000})
|
NewNetAddress("", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8000})
|
||||||
}, "Calling NewNetAddress with UDPAddr should not panic in testing")
|
}, "Calling NewNetAddress with UDPAddr should not panic in testing")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewNetAddressString(t *testing.T) {
|
func TestNewNetAddressStringWithOptionalID(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
addr string
|
addr string
|
||||||
expected string
|
expected string
|
||||||
@ -57,6 +55,28 @@ func TestNewNetAddressString(t *testing.T) {
|
|||||||
{" @ ", "", false},
|
{" @ ", "", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
addr, err := NewNetAddressStringWithOptionalID(tc.addr)
|
||||||
|
if tc.correct {
|
||||||
|
if assert.Nil(t, err, tc.addr) {
|
||||||
|
assert.Equal(t, tc.expected, addr.String())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NotNil(t, err, tc.addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewNetAddressString(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
addr string
|
||||||
|
expected string
|
||||||
|
correct bool
|
||||||
|
}{
|
||||||
|
{"127.0.0.1:8080", "127.0.0.1:8080", false},
|
||||||
|
{"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef@127.0.0.1:8080", "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef@127.0.0.1:8080", true},
|
||||||
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
addr, err := NewNetAddressString(tc.addr)
|
addr, err := NewNetAddressString(tc.addr)
|
||||||
if tc.correct {
|
if tc.correct {
|
||||||
@ -70,23 +90,22 @@ func TestNewNetAddressString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewNetAddressStrings(t *testing.T) {
|
func TestNewNetAddressStrings(t *testing.T) {
|
||||||
addrs, errs := NewNetAddressStrings([]string{"127.0.0.1:8080", "127.0.0.2:8080"})
|
addrs, errs := NewNetAddressStrings([]string{
|
||||||
assert.Len(t, errs, 0)
|
"127.0.0.1:8080",
|
||||||
|
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef@127.0.0.1:8080",
|
||||||
|
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeed@127.0.0.2:8080"})
|
||||||
|
assert.Len(t, errs, 1)
|
||||||
assert.Equal(t, 2, len(addrs))
|
assert.Equal(t, 2, len(addrs))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewNetAddressIPPort(t *testing.T) {
|
func TestNewNetAddressIPPort(t *testing.T) {
|
||||||
assert := assert.New(t)
|
|
||||||
addr := NewNetAddressIPPort(net.ParseIP("127.0.0.1"), 8080)
|
addr := NewNetAddressIPPort(net.ParseIP("127.0.0.1"), 8080)
|
||||||
|
assert.Equal(t, "127.0.0.1:8080", addr.String())
|
||||||
assert.Equal("127.0.0.1:8080", addr.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetAddressProperties(t *testing.T) {
|
func TestNetAddressProperties(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
// TODO add more test cases
|
// TODO add more test cases
|
||||||
tests := []struct {
|
testCases := []struct {
|
||||||
addr string
|
addr string
|
||||||
valid bool
|
valid bool
|
||||||
local bool
|
local bool
|
||||||
@ -96,21 +115,19 @@ func TestNetAddressProperties(t *testing.T) {
|
|||||||
{"ya.ru:80", true, false, true},
|
{"ya.ru:80", true, false, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range tests {
|
for _, tc := range testCases {
|
||||||
addr, err := NewNetAddressString(t.addr)
|
addr, err := NewNetAddressStringWithOptionalID(tc.addr)
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t.valid, addr.Valid())
|
assert.Equal(t, tc.valid, addr.Valid())
|
||||||
assert.Equal(t.local, addr.Local())
|
assert.Equal(t, tc.local, addr.Local())
|
||||||
assert.Equal(t.routable, addr.Routable())
|
assert.Equal(t, tc.routable, addr.Routable())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetAddressReachabilityTo(t *testing.T) {
|
func TestNetAddressReachabilityTo(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
// TODO add more test cases
|
// TODO add more test cases
|
||||||
tests := []struct {
|
testCases := []struct {
|
||||||
addr string
|
addr string
|
||||||
other string
|
other string
|
||||||
reachability int
|
reachability int
|
||||||
@ -119,13 +136,13 @@ func TestNetAddressReachabilityTo(t *testing.T) {
|
|||||||
{"ya.ru:80", "127.0.0.1:8080", 1},
|
{"ya.ru:80", "127.0.0.1:8080", 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range tests {
|
for _, tc := range testCases {
|
||||||
addr, err := NewNetAddressString(t.addr)
|
addr, err := NewNetAddressStringWithOptionalID(tc.addr)
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
other, err := NewNetAddressString(t.other)
|
other, err := NewNetAddressStringWithOptionalID(tc.other)
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t.reachability, addr.ReachabilityTo(other))
|
assert.Equal(t, tc.reachability, addr.ReachabilityTo(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user