Skip to content

Commit

Permalink
test: fixing broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f committed Oct 24, 2023
1 parent d2d19b7 commit e1441d0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
43 changes: 18 additions & 25 deletions config/example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@
# `network` contains configuration options for the network module, which manages communication between nodes.
[network]

# `network_key` specifies the private key filename to use for node authentication and encryption in the p2p protocol.
## network_key = "network_key"

# `listens` specifies the addresses and ports where the node will listen for incoming connections from other nodes.
## listens = ["/ip4/0.0.0.0/tcp/21888", "/ip6/::/tcp/21888", "/ip4/0.0.0.0/udp/21888/quic-v1", "/ip6/::/udp/21888/quic-v1"]

# `network_key` specifies the private key filename to use for node authentication and encryption in the p2p protocol.
## network_key = "network_key"
# `relay_addresses` provides the necessary relay addresses. These should be specified if 'enable_relay' is 'true'.
# Note: this parameter will be ignored if 'enable_relay' is 'false'.
## relay_addresses = []

# `addresses` is a list of peer addresses needed for peer discovery.
# These addresses are used by the Pactus node to discover and connect to other peers on the network.
## bootstrap_addresses = []

# `min_connections` is the minimum number of connections that the Pactus node should maintain.
# Default is 8
## min_connections = 8

# `max_connections` is the maximum number of connections that the Pactus node should maintain.
# Default is 16
## max_connections = 16

# `enable_nat` indicates whether NAT service should be enabled or not.
# NAT service allows many machines to share a single public address.
Expand All @@ -37,10 +53,6 @@
# Default is true.
## enable_relay = false

# `relay_addresses` provides the necessary relay addresses. These should be specified if 'enable_relay' is 'true'.
# Note: this parameter will be ignored if 'enable_relay' is 'false'.
## relay_addresses = []

# `enable_mdns` indicates whether MDNS should be enabled or not.
# MDNS is a protocol to discover local peers quickly and efficiently.
# Default is false.
Expand All @@ -54,25 +66,6 @@
# Default is false.
## bootstrapper = false

# `network.bootstrap` contains configuration for bootstrapping the node.
[network.bootstrap]

# `addresses` is a list of peer addresses needed for peer discovery.
# These addresses are used by the Pactus node to discover and connect to other peers on the network.
## addresses = ["/ip4/172.104.46.145/tcp/21777/p2p/12D3KooWNYD4bB82YZRXv6oNyYPwc5ozabx2epv75ATV3D8VD3Mq"]

# `min_threshold` is the minimum number of connections that the Pactus node should maintain.
# Default is 8
## min_threshold = 8

# `max_threshold` is the maximum number of connections that the Pactus node should maintain.
# Default is 16
## max_threshold = 16

# `period` periodically checks to see if the threshold is maintained.
# Default is 1 minute
## period = "1m0s"

# `sync` contains configuration of sync module.
[sync]

Expand Down
20 changes: 10 additions & 10 deletions network/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
)

type dhtService struct {
ctx context.Context
host lp2phost.Host
kademlia *lp2pdht.IpfsDHT
peerMgr *peerMgr
logger *logger.SubLogger
ctx context.Context
host lp2phost.Host
kademlia *lp2pdht.IpfsDHT
peerMgr *peerMgr
logger *logger.SubLogger
}

func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore.ProtocolID,
Expand Down Expand Up @@ -48,11 +48,11 @@ func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore.
bootsrapAddrs, conf.MinConns, conf.MaxConns, logger)

return &dhtService{
ctx: ctx,
host: host,
kademlia: kademlia,
peerMgr: bootstrap,
logger: logger,
ctx: ctx,
host: host,
kademlia: kademlia,
peerMgr: bootstrap,
logger: logger,
}
}

Expand Down
2 changes: 1 addition & 1 deletion network/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MakeAddressInfo(addr string) (*lp2ppeer.AddrInfo, error) {

func ConnectAsync(ctx context.Context, h lp2phost.Host, addrInfo lp2ppeer.AddrInfo, logger *logger.SubLogger) {
go func() {
err := h.Connect(lp2pnetwork.WithDialPeerTimeout(ctx, 10*time.Second), addrInfo)
err := h.Connect(lp2pnetwork.WithDialPeerTimeout(ctx, 30*time.Second), addrInfo)
if err != nil {
if logger != nil {
logger.Warn("connection failed", "addr", addrInfo.Addrs, "err", err)
Expand Down
5 changes: 2 additions & 3 deletions tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ func TestMain(m *testing.M) {
tConfigs[i].Network.Bootstrapper = true
tConfigs[i].Network.NetworkKey = util.TempFilePath()
tConfigs[i].Network.Listens = []string{"/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/udp/0/quic-v1"}
tConfigs[i].Network.Bootstrap.Addresses = []string{}
tConfigs[i].Network.Bootstrap.Period = 10 * time.Second
tConfigs[i].Network.Bootstrap.MinThreshold = 3
tConfigs[i].Network.BootstrapAddrs = []string{}
tConfigs[i].Network.MinConns = 3
tConfigs[i].HTTP.Enable = false
tConfigs[i].GRPC.Enable = false

Expand Down

0 comments on commit e1441d0

Please sign in to comment.