swarm/network: HandoverProof should not be nil

This commit is contained in:
Balint Gabor 2018-01-15 18:33:24 +01:00
parent 40cfae13ef
commit d075df7159
2 changed files with 16 additions and 11 deletions

View file

@ -82,11 +82,11 @@ type SubscribeMsg struct {
// OfferedHashesMsg is the protocol msg for offering to hand over a // OfferedHashesMsg is the protocol msg for offering to hand over a
// stream section // stream section
type OfferedHashesMsg struct { type OfferedHashesMsg struct {
Stream string // name of Stream Stream string // name of Stream
Key []byte // subtype or key Key []byte // subtype or key
From, To uint64 // peer and db-specific entry count From, To uint64 // peer and db-specific entry count
Hashes []byte // stream of hashes (128) Hashes []byte // stream of hashes (128)
*HandoverProof `rlp:"nil"` // HandoverProof *HandoverProof // HandoverProof
} }
// String pretty prints OfferedHashesMsg // String pretty prints OfferedHashesMsg

View file

@ -136,7 +136,10 @@ func (self *testIncomingStreamer) BatchDone(string, uint64, []byte, []byte) func
} }
func (self *testOutgoingStreamer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) { func (self *testOutgoingStreamer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) {
return make([]byte, HashSize), from + 1, to + 1, nil, nil proof := &HandoverProof{
Handover: &Handover{},
}
return make([]byte, HashSize), from + 1, to + 1, proof, nil
} }
func (self *testOutgoingStreamer) GetData([]byte) []byte { func (self *testOutgoingStreamer) GetData([]byte) []byte {
@ -221,11 +224,13 @@ func TestStreamerUpstreamSubscribeMsgExchange(t *testing.T) {
p2ptest.Expect{ p2ptest.Expect{
Code: 1, Code: 1,
Msg: &OfferedHashesMsg{ Msg: &OfferedHashesMsg{
Stream: "foo", Stream: "foo",
HandoverProof: nil, HandoverProof: &HandoverProof{
Hashes: make([]byte, HashSize), Handover: &Handover{},
From: 6, },
To: 9, Hashes: make([]byte, HashSize),
From: 6,
To: 9,
}, },
Peer: peerID, Peer: peerID,
}, },