mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 14:03:46 +00:00
fix:fix hive test bug
Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
parent
3a5754f43a
commit
3c5dbf1fd8
5 changed files with 12 additions and 13 deletions
|
|
@ -408,7 +408,7 @@ func (p *PortalAPI) HistoryOffer(enr string, contentKey string, contentValue str
|
||||||
}
|
}
|
||||||
|
|
||||||
offerReq := &OfferRequest{
|
offerReq := &OfferRequest{
|
||||||
Kind: portalwire.OfferRequestDirect,
|
Kind: TransientOfferRequestKind,
|
||||||
Request: transientOfferRequest,
|
Request: transientOfferRequest,
|
||||||
}
|
}
|
||||||
accept, err := p.portalProtocol.offer(n, offerReq)
|
accept, err := p.portalProtocol.offer(n, offerReq)
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ func (p *PortalProtocol) pingInner(node *enode.Node) (*portalwire.Pong, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.log.Trace("Reveice ping response", "source", p.Self().ID(), "target", node.ID(), "res", talkResp)
|
p.log.Trace("Received ping response", "source", p.Self().ID(), "target", node.ID(), "res", talkResp)
|
||||||
|
|
||||||
return p.processPong(node, talkResp)
|
return p.processPong(node, talkResp)
|
||||||
}
|
}
|
||||||
|
|
@ -528,7 +528,7 @@ func (p *PortalProtocol) processOffer(target *enode.Node, resp []byte, request *
|
||||||
}
|
}
|
||||||
|
|
||||||
contentKeyBitlist := bitfield.Bitlist(accept.ContentKeys)
|
contentKeyBitlist := bitfield.Bitlist(accept.ContentKeys)
|
||||||
if int(contentKeyBitlist.Count()) != contentKeyLen {
|
if contentKeyBitlist.Len() != uint64(contentKeyLen) {
|
||||||
return nil, fmt.Errorf("accepted content key bitlist has invalid size, expected %d, got %d", contentKeyLen, contentKeyBitlist.Len())
|
return nil, fmt.Errorf("accepted content key bitlist has invalid size, expected %d, got %d", contentKeyLen, contentKeyBitlist.Len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,7 +1100,7 @@ func (p *PortalProtocol) handleOffer(id enode.ID, addr *net.UDPAddr, request *po
|
||||||
if len(p.contentQueue) >= cap(p.contentQueue) {
|
if len(p.contentQueue) >= cap(p.contentQueue) {
|
||||||
acceptMsg := &portalwire.Accept{
|
acceptMsg := &portalwire.Accept{
|
||||||
ConnectionId: []byte{0, 0},
|
ConnectionId: []byte{0, 0},
|
||||||
ContentKeys: []byte(contentKeyBitlist),
|
ContentKeys: contentKeyBitlist,
|
||||||
}
|
}
|
||||||
|
|
||||||
p.log.Trace("Sending accept response", "protocol", p.protocolId, "source", addr, "accept", acceptMsg)
|
p.log.Trace("Sending accept response", "protocol", p.protocolId, "source", addr, "accept", acceptMsg)
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,8 @@ func TestPortalWireProtocol(t *testing.T) {
|
||||||
|
|
||||||
testGossipContentKeys := [][]byte{[]byte("test_gossip_content_keys"), []byte("test_gossip_content_keys2")}
|
testGossipContentKeys := [][]byte{[]byte("test_gossip_content_keys"), []byte("test_gossip_content_keys2")}
|
||||||
testGossipContent := [][]byte{[]byte("test_gossip_content"), []byte("test_gossip_content2")}
|
testGossipContent := [][]byte{[]byte("test_gossip_content"), []byte("test_gossip_content2")}
|
||||||
gossip, err := node1.NeighborhoodGossip(nil, testGossipContentKeys, testGossipContent)
|
id := node1.Self().ID()
|
||||||
|
gossip, err := node1.NeighborhoodGossip(&id, testGossipContentKeys, testGossipContent)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 2, gossip)
|
assert.Equal(t, 2, gossip)
|
||||||
|
|
||||||
|
|
@ -331,7 +332,7 @@ func TestPortalWireProtocol(t *testing.T) {
|
||||||
|
|
||||||
testRandGossipContentKeys := [][]byte{[]byte("test_rand_gossip_content_keys"), []byte("test_rand_gossip_content_keys2")}
|
testRandGossipContentKeys := [][]byte{[]byte("test_rand_gossip_content_keys"), []byte("test_rand_gossip_content_keys2")}
|
||||||
testRandGossipContent := [][]byte{[]byte("test_rand_gossip_content"), []byte("test_rand_gossip_content2")}
|
testRandGossipContent := [][]byte{[]byte("test_rand_gossip_content"), []byte("test_rand_gossip_content2")}
|
||||||
randGossip, err := node1.RandomGossip(nil, testRandGossipContentKeys, testRandGossipContent)
|
randGossip, err := node1.RandomGossip(&id, testRandGossipContentKeys, testRandGossipContent)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 2, randGossip)
|
assert.Equal(t, 2, randGossip)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,6 @@ const (
|
||||||
ContentEnrsSelector byte = 0x02
|
ContentEnrsSelector byte = 0x02
|
||||||
)
|
)
|
||||||
|
|
||||||
// Offer request types for the portal protocol.
|
|
||||||
const (
|
|
||||||
OfferRequestDirect byte = 0x00
|
|
||||||
OfferRequestDatabase byte = 0x01
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ContentKeysLimit = 64
|
ContentKeysLimit = 64
|
||||||
// OfferMessageOverhead overhead of content message is a result of 1byte for kind enum, and
|
// OfferMessageOverhead overhead of content message is a result of 1byte for kind enum, and
|
||||||
|
|
|
||||||
|
|
@ -201,9 +201,13 @@ func TestOfferAndAcceptMessage(t *testing.T) {
|
||||||
contentKeyBitlist.SetBitAt(0, true)
|
contentKeyBitlist.SetBitAt(0, true)
|
||||||
accept := &Accept{
|
accept := &Accept{
|
||||||
ConnectionId: []byte{0x01, 0x02},
|
ConnectionId: []byte{0x01, 0x02},
|
||||||
ContentKeys: []byte(contentKeyBitlist),
|
ContentKeys: contentKeyBitlist,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentKeyBitlist1 := bitfield.Bitlist([]byte{0x02})
|
||||||
|
fmt.Println(contentKeyBitlist1.Count())
|
||||||
|
fmt.Println(contentKeyBitlist1.Len())
|
||||||
|
|
||||||
expected = "0x0102060000000101"
|
expected = "0x0102060000000101"
|
||||||
|
|
||||||
data, err = accept.MarshalSSZ()
|
data, err = accept.MarshalSSZ()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue