cmd/devp2p: add eth protocol test suite (#21598)
This change adds a test framework for the "eth" protocol and some basic tests. The tests can be run using the './devp2p rlpx eth-test' command.
This commit is contained in:
@ -60,7 +60,8 @@ func (eth *Ethereum) startEthEntryUpdate(ln *enode.LocalNode) {
|
||||
}
|
||||
|
||||
func (eth *Ethereum) currentEthEntry() *ethEntry {
|
||||
return ðEntry{ForkID: forkid.NewID(eth.blockchain)}
|
||||
return ðEntry{ForkID: forkid.NewID(eth.blockchain.Config(), eth.blockchain.Genesis().Hash(),
|
||||
eth.blockchain.CurrentHeader().Number.Uint64())}
|
||||
}
|
||||
|
||||
// setupDiscovery creates the node discovery source for the eth protocol.
|
||||
|
@ -319,7 +319,8 @@ func (pm *ProtocolManager) handle(p *peer) error {
|
||||
number = head.Number.Uint64()
|
||||
td = pm.blockchain.GetTd(hash, number)
|
||||
)
|
||||
if err := p.Handshake(pm.networkID, td, hash, genesis.Hash(), forkid.NewID(pm.blockchain), pm.forkFilter); err != nil {
|
||||
forkID := forkid.NewID(pm.blockchain.Config(), pm.blockchain.Genesis().Hash(), pm.blockchain.CurrentHeader().Number.Uint64())
|
||||
if err := p.Handshake(pm.networkID, td, hash, genesis.Hash(), forkID, pm.forkFilter); err != nil {
|
||||
p.Log().Debug("Ethereum handshake failed", "err", err)
|
||||
return err
|
||||
}
|
||||
|
@ -185,7 +185,8 @@ func newTestPeer(name string, version int, pm *ProtocolManager, shake bool) (*te
|
||||
head = pm.blockchain.CurrentHeader()
|
||||
td = pm.blockchain.GetTd(head.Hash(), head.Number.Uint64())
|
||||
)
|
||||
tp.handshake(nil, td, head.Hash(), genesis.Hash(), forkid.NewID(pm.blockchain), forkid.NewFilter(pm.blockchain))
|
||||
forkID := forkid.NewID(pm.blockchain.Config(), pm.blockchain.Genesis().Hash(), pm.blockchain.CurrentHeader().Number.Uint64())
|
||||
tp.handshake(nil, td, head.Hash(), genesis.Hash(), forkID, forkid.NewFilter(pm.blockchain))
|
||||
}
|
||||
return tp, errc
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func TestStatusMsgErrors64(t *testing.T) {
|
||||
genesis = pm.blockchain.Genesis()
|
||||
head = pm.blockchain.CurrentHeader()
|
||||
td = pm.blockchain.GetTd(head.Hash(), head.Number.Uint64())
|
||||
forkID = forkid.NewID(pm.blockchain)
|
||||
forkID = forkid.NewID(pm.blockchain.Config(), pm.blockchain.Genesis().Hash(), pm.blockchain.CurrentHeader().Number.Uint64())
|
||||
)
|
||||
defer pm.Stop()
|
||||
|
||||
|
Reference in New Issue
Block a user