diff --git a/runtime/fdlimits/BUILD.bazel b/runtime/fdlimits/BUILD.bazel index 0ba640777291..87350dde1581 100644 --- a/runtime/fdlimits/BUILD.bazel +++ b/runtime/fdlimits/BUILD.bazel @@ -17,5 +17,6 @@ go_test( deps = [ ":go_default_library", "//testing/assert:go_default_library", + "@com_github_ethereum_go_ethereum//common/fdlimit:go_default_library", ], ) diff --git a/runtime/fdlimits/fdlimits_test.go b/runtime/fdlimits/fdlimits_test.go index b7223586b4b4..d608a0d81823 100644 --- a/runtime/fdlimits/fdlimits_test.go +++ b/runtime/fdlimits/fdlimits_test.go @@ -1,31 +1,22 @@ package fdlimits_test import ( - "syscall" "testing" + gethLimit "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/prysmaticlabs/prysm/runtime/fdlimits" "github.com/prysmaticlabs/prysm/testing/assert" ) func TestSetMaxFdLimits(t *testing.T) { - var limit syscall.Rlimit - assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)) - wantedMax := limit.Max + assert.NoError(t, fdlimits.SetMaxFdLimits()) - // Set it to a low value. - limit.Cur = 2000 - assert.NoError(t, syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit)) - limit = syscall.Rlimit{} + curr, err := gethLimit.Current() + assert.NoError(t, err) - // Double check it works - assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)) - assert.Equal(t, uint64(2000), limit.Cur) + max, err := gethLimit.Maximum() + assert.NoError(t, err) - assert.NoError(t, fdlimits.SetMaxFdLimits()) - // Retrieve fd limit again. - assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)) + assert.Equal(t, max, curr, "current and maximum file descriptor limits do not match up.") - assert.Equal(t, wantedMax, limit.Cur) - assert.NotEqual(t, 2000, limit.Cur) }