makes sure we are having Nat set to None for the tests

This commit is contained in:
Marcin Czenko 2025-11-10 12:06:02 +01:00
parent f69939fdae
commit 7e3b855103
No known key found for this signature in database
GPG Key ID: A0449219BDBA98AE
3 changed files with 17 additions and 1 deletions

View File

@ -21,7 +21,7 @@ update: | submodules
libcodex: libcodex:
@echo "Building libcodex..." @echo "Building libcodex..."
@$(MAKE) -C $(NIM_CODEX_DIR) libcodex @$(MAKE) -C $(NIM_CODEX_DIR) libcodex CODEX_LIB_PARAMS="-d:codex_enable_api_debug_peers"
build: build:
@echo "Building Codex Go Bindings..." @echo "Building Codex Go Bindings..."
@ -31,6 +31,14 @@ test:
@echo "Running tests..." @echo "Running tests..."
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOTESTFLAGS="-timeout=2m" go test ./... CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOTESTFLAGS="-timeout=2m" go test ./...
test2:
@echo "Running tests..."
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOTESTFLAGS="-timeout=2m" gotestsum --packages="./..." -f testname -- -count 1 -run TestConnectWithAddress
test3:
@echo "Running tests..."
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOTESTFLAGS="-timeout=2m" gotestsum --packages="./..." -f testname -- -count 1
clean: clean:
@echo "Cleaning up..." @echo "Cleaning up..."
@git submodule deinit -f $(NIM_CODEX_DIR) @git submodule deinit -f $(NIM_CODEX_DIR)

View File

@ -36,6 +36,7 @@ func TestConnectWithAddress(t *testing.T) {
LogFormat: LogFormatNoColors, LogFormat: LogFormatNoColors,
MetricsEnabled: false, MetricsEnabled: false,
DiscoveryPort: 8090, DiscoveryPort: 8090,
Nat: "none",
}) })
if err != nil { if err != nil {
t.Fatalf("Failed to create codex1: %v", err) t.Fatalf("Failed to create codex1: %v", err)
@ -50,6 +51,7 @@ func TestConnectWithAddress(t *testing.T) {
LogFormat: LogFormatNoColors, LogFormat: LogFormatNoColors,
MetricsEnabled: false, MetricsEnabled: false,
DiscoveryPort: 8091, DiscoveryPort: 8091,
Nat: "none",
}) })
if err != nil { if err != nil {
t.Fatalf("Failed to create codex2: %v", err) t.Fatalf("Failed to create codex2: %v", err)

View File

@ -15,6 +15,7 @@ func defaultConfigHelper(t *testing.T) Config {
MetricsEnabled: false, MetricsEnabled: false,
BlockRetries: 3000, BlockRetries: 3000,
LogLevel: "ERROR", LogLevel: "ERROR",
Nat: "none",
} }
} }
@ -43,6 +44,11 @@ func newCodexNode(t *testing.T, opts ...Config) *CodexNode {
if c.DiscoveryPort != 0 { if c.DiscoveryPort != 0 {
config.DiscoveryPort = c.DiscoveryPort config.DiscoveryPort = c.DiscoveryPort
} }
// in case someone wants to change the config.Nat default value
if c.Nat != "" {
config.Nat = c.Nat
}
} }
node, err := New(config) node, err := New(config)