Skip to content
Snippets Groups Projects
Commit 0ec397a0 authored by Wolfgang Welz's avatar Wolfgang Welz
Browse files

Fix tests by explicitly comparing the time.time field

parent 17a9b670
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ require ( ...@@ -9,7 +9,7 @@ require (
github.com/ethereum/go-ethereum v1.8.27 github.com/ethereum/go-ethereum v1.8.27
github.com/gdamore/tcell v1.1.2 github.com/gdamore/tcell v1.1.2
github.com/go-zeromq/zmq4 v0.4.0 github.com/go-zeromq/zmq4 v0.4.0
github.com/golang/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.3.1
github.com/google/open-location-code/go v0.0.0-20190603181809-cf814bded323 github.com/google/open-location-code/go v0.0.0-20190603181809-cf814bded323
github.com/iotaledger/iota.go v1.0.0-beta.6 github.com/iotaledger/iota.go v1.0.0-beta.6
github.com/labstack/echo v3.3.10+incompatible github.com/labstack/echo v3.3.10+incompatible
......
...@@ -20,12 +20,19 @@ func TestPeer_MarshalUnmarshal(t *testing.T) { ...@@ -20,12 +20,19 @@ func TestPeer_MarshalUnmarshal(t *testing.T) {
Salt: salt.New(30 * time.Second), Salt: salt.New(30 * time.Second),
} }
restoredPeer, _ := Unmarshal(peer.Marshal()) restoredPeer, err := Unmarshal(peer.Marshal())
if err != nil {
t.Error(err)
}
assert.Equal(t, peer.Address, restoredPeer.Address) assert.Equal(t, peer.Address, restoredPeer.Address)
assert.Equal(t, peer.Identity.StringIdentifier, restoredPeer.Identity.StringIdentifier) assert.Equal(t, peer.Identity.StringIdentifier, restoredPeer.Identity.StringIdentifier)
assert.Equal(t, peer.Identity.PublicKey, restoredPeer.Identity.PublicKey) assert.Equal(t, peer.Identity.PublicKey, restoredPeer.Identity.PublicKey)
assert.Equal(t, peer.GossipPort, restoredPeer.GossipPort) assert.Equal(t, peer.GossipPort, restoredPeer.GossipPort)
assert.Equal(t, peer.PeeringPort, restoredPeer.PeeringPort) assert.Equal(t, peer.PeeringPort, restoredPeer.PeeringPort)
assert.Equal(t, peer.Salt, restoredPeer.Salt) assert.Equal(t, peer.Salt.Bytes, restoredPeer.Salt.Bytes)
// time.time cannot be compared with reflect.DeepEqual, so we cannot use assert.Equal here
if !peer.Salt.ExpirationTime.Equal(restoredPeer.Salt.ExpirationTime) {
t.Errorf("got %v want %v", restoredPeer.Salt.ExpirationTime, peer.Salt.ExpirationTime)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment