p2p/discover/v4wire: use optional RLP field for EIP-868 seq (#22842)

This changes the definitions of Ping and Pong, adding an optional field
for the sequence number. This field was previously encoded/decoded using
the "tail" struct tag, but using "optional" is much nicer.
This commit is contained in:
Felix Lange
2021-05-18 11:48:41 +02:00
committed by GitHub
parent 32c1ed8a9c
commit 3e6f46caec
4 changed files with 17 additions and 47 deletions

View File

@ -470,13 +470,13 @@ func TestUDPv4_EIP868(t *testing.T) {
// Perform endpoint proof and check for sequence number in packet tail.
test.packetIn(nil, &v4wire.Ping{Expiration: futureExp})
test.waitPacketOut(func(p *v4wire.Pong, addr *net.UDPAddr, hash []byte) {
if p.ENRSeq() != wantNode.Seq() {
t.Errorf("wrong sequence number in pong: %d, want %d", p.ENRSeq(), wantNode.Seq())
if p.ENRSeq != wantNode.Seq() {
t.Errorf("wrong sequence number in pong: %d, want %d", p.ENRSeq, wantNode.Seq())
}
})
test.waitPacketOut(func(p *v4wire.Ping, addr *net.UDPAddr, hash []byte) {
if p.ENRSeq() != wantNode.Seq() {
t.Errorf("wrong sequence number in ping: %d, want %d", p.ENRSeq(), wantNode.Seq())
if p.ENRSeq != wantNode.Seq() {
t.Errorf("wrong sequence number in ping: %d, want %d", p.ENRSeq, wantNode.Seq())
}
test.packetIn(nil, &v4wire.Pong{Expiration: futureExp, ReplyTok: hash})
})