mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-21 22:36:42 +00:00

* add p2p v5 which is currently identical to v4 * set all internal imports to v5 * wip * set default version to 5 * protobuf gen for new ibd chain locator * wire for new ibd chain locator types * new ibd shared block algo -- only basic test passing * address the case where pruning points disagree, now both IBD tests pass * protobuf gen for new past diff request message * wire for new request past diff message * handle and flow for new request past diff message - logic unimplemented yet * implement ibd sync past diff of relay and selected tip * go fmt * remove unused methods * missed one err check * addressing simple comments * apply the traversal limit logic and sort headers * rename pastdiff -> anticone * apply Don't relay blocks in virtual anticone #1970 to v5 * go fmt * Fixed minor comments * Limit the number of chain negotiation restarts
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package testing
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/app/protocol/flows/v5/addressexchange"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
peerpkg "github.com/kaspanet/kaspad/app/protocol/peer"
|
|
"github.com/kaspanet/kaspad/domain/consensus"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/testutils"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/addressmanager"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
)
|
|
|
|
type fakeReceiveAddressesContext struct{}
|
|
|
|
func (f fakeReceiveAddressesContext) AddressManager() *addressmanager.AddressManager {
|
|
return nil
|
|
}
|
|
|
|
func TestReceiveAddressesErrors(t *testing.T) {
|
|
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
|
|
incomingRoute := router.NewRoute("incoming")
|
|
outgoingRoute := router.NewRoute("outgoing")
|
|
peer := peerpkg.New(nil)
|
|
errChan := make(chan error)
|
|
go func() {
|
|
errChan <- addressexchange.ReceiveAddresses(fakeReceiveAddressesContext{}, incomingRoute, outgoingRoute, peer)
|
|
}()
|
|
|
|
_, err := outgoingRoute.DequeueWithTimeout(time.Second)
|
|
if err != nil {
|
|
t.Fatalf("DequeueWithTimeout: %+v", err)
|
|
}
|
|
|
|
// Sending addressmanager.GetAddressesMax+1 addresses should trigger a ban
|
|
err = incomingRoute.Enqueue(appmessage.NewMsgAddresses(make([]*appmessage.NetAddress,
|
|
addressmanager.GetAddressesMax+1)))
|
|
if err != nil {
|
|
t.Fatalf("Enqueue: %+v", err)
|
|
}
|
|
|
|
select {
|
|
case err := <-errChan:
|
|
checkFlowError(t, err, true, true, "address count exceeded")
|
|
case <-time.After(time.Second):
|
|
t.Fatalf("timed out after %s", time.Second)
|
|
}
|
|
})
|
|
}
|