From 5a6f752127c815a26566f3b91be4c32faf325955 Mon Sep 17 00:00:00 2001 From: Nick Angelou Date: Mon, 30 Sep 2024 20:22:59 +0800 Subject: [PATCH] fix tests --- MODULE.bazel | 9 +-------- WORKSPACE | 4 ++++ private_set_intersection/c/integration_test.cpp | 2 +- private_set_intersection/cpp/BUILD | 3 +-- private_set_intersection/cpp/psi_client_test.cpp | 2 +- private_set_intersection/cpp/psi_server_test.cpp | 2 +- private_set_intersection/go/integration_test.go | 3 ++- .../javascript/scripts/build-proto.sh | 2 +- .../javascript/scripts/build-psi-wasm.sh | 2 +- private_set_intersection/python/requirements/BUILD | 1 + private_set_intersection/rust/tests/integration_test.rs | 3 ++- 11 files changed, 16 insertions(+), 17 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index bee5db08..5c84d5f5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -32,14 +32,7 @@ bazel_dep(name = "rules_python", version = "0.36.0") bazel_dep(name = "rules_python_gazelle_plugin", version = "0.36.0") bazel_dep(name = "rules_rust", version = "0.51.0") -# Grpc -grpc_deps = use_extension( - "//bazel:grpc_deps.bzl", - "grpc_extension", -) -grpc_deps.load_dependencies() -use_repo(grpc_deps) - +## PCJ http_archive( name = "private_join_and_compute", sha256 = "9702d5e1e4deeb111e235952e1e831dc9d9f0127ed8a1a30112b235d11f3e937", diff --git a/WORKSPACE b/WORKSPACE index 56a1d08f..3ae2c18a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,3 +1,7 @@ +workspace( + name = "org_openmined_psi", +) + # Emsdk load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") diff --git a/private_set_intersection/c/integration_test.cpp b/private_set_intersection/c/integration_test.cpp index 8b655293..2f16d630 100644 --- a/private_set_intersection/c/integration_test.cpp +++ b/private_set_intersection/c/integration_test.cpp @@ -225,7 +225,7 @@ TEST_P(Correctness, intersection) { // Test if size is approximately as expected (up to 10%). EXPECT_GE(intersection_size, num_client_inputs / 2); - EXPECT_LT((double)intersection_size, + EXPECT_LE((double)intersection_size, ceil((double(num_client_inputs) / 2.0) * 1.1)); } free(server_setup); diff --git a/private_set_intersection/cpp/BUILD b/private_set_intersection/cpp/BUILD index f710edf0..a1fd843c 100644 --- a/private_set_intersection/cpp/BUILD +++ b/private_set_intersection/cpp/BUILD @@ -1,5 +1,3 @@ -load("//tools:common.bzl", "template_rule") - # # Copyright 2020 the authors listed in CONTRIBUTORS.md # @@ -15,6 +13,7 @@ load("//tools:common.bzl", "template_rule") # See the License for the specific language governing permissions and # limitations under the License. # +load("//tools:common.bzl", "template_rule") load("//tools:package.bzl", "VERSION_LABEL") package(default_visibility = ["//visibility:public"]) diff --git a/private_set_intersection/cpp/psi_client_test.cpp b/private_set_intersection/cpp/psi_client_test.cpp index 60ed4877..2f58c0b6 100644 --- a/private_set_intersection/cpp/psi_client_test.cpp +++ b/private_set_intersection/cpp/psi_client_test.cpp @@ -224,7 +224,7 @@ TEST_F(PsiClientTest, TestCorrectnessIntersectionSize) { // Test if size is approximately as expected (up to 10%). EXPECT_GE(intersection_size, num_client_elements / 2); - EXPECT_LT((double)intersection_size, + EXPECT_LE((double)intersection_size, ceil(((double)num_client_elements / 2.0) * 1.1)); } diff --git a/private_set_intersection/cpp/psi_server_test.cpp b/private_set_intersection/cpp/psi_server_test.cpp index dbd81295..91b8c8a3 100644 --- a/private_set_intersection/cpp/psi_server_test.cpp +++ b/private_set_intersection/cpp/psi_server_test.cpp @@ -142,7 +142,7 @@ TEST_F(PsiServerTest, TestCorrectnessIntersectionSize) { // Test if size is approximately as expected (up to 10%). EXPECT_GE(intersection_size, num_client_elements / 2); - EXPECT_LT((double)intersection_size, + EXPECT_LE((double)intersection_size, ceil(((double)num_client_elements / 2.0) * 1.1)); } diff --git a/private_set_intersection/go/integration_test.go b/private_set_intersection/go/integration_test.go index 3d33874d..ce51b1ff 100644 --- a/private_set_intersection/go/integration_test.go +++ b/private_set_intersection/go/integration_test.go @@ -180,6 +180,7 @@ func TestIntegrationIntersection(t *testing.T) { intersectionSet := generateSet(intersection) for idx := 0; idx < numClientInputs; idx++ { _, ok := intersectionSet[idx] + // Can fail due to false positives if ok != (idx%2 == 0) { t.Errorf("Invalid intersection for item %v %v", idx, ok) } @@ -194,7 +195,7 @@ func TestIntegrationIntersection(t *testing.T) { t.Errorf("Invalid intersection. expected lower bound %v. got %v", int64(numClientInputs/2), intersectionCnt) } - if float64(intersectionCnt) >= math.Ceil(float64(numClientInputs)/2.0*1.1) { + if float64(intersectionCnt) > math.Ceil(float64(numClientInputs)/2.0*1.1) { t.Errorf("Invalid intersection. expected upper bound %v. got %v", math.Ceil(float64(numClientInputs)/2.0*1.1), intersectionCnt) } diff --git a/private_set_intersection/javascript/scripts/build-proto.sh b/private_set_intersection/javascript/scripts/build-proto.sh index 67855542..0cae3755 100755 --- a/private_set_intersection/javascript/scripts/build-proto.sh +++ b/private_set_intersection/javascript/scripts/build-proto.sh @@ -19,5 +19,5 @@ PROTOC_BINARY="./bazel-bin/external/protobuf~/protoc" --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \ --proto_path="${PROTO_DIR}" \ --js_out="import_style=commonjs,binary:${OUT_DIR_JS}" \ - --ts_out="service=grpc-web:${OUT_DIR_TS}" \ + --ts_out="${OUT_DIR_TS}" \ psi.proto diff --git a/private_set_intersection/javascript/scripts/build-psi-wasm.sh b/private_set_intersection/javascript/scripts/build-psi-wasm.sh index a326b7bd..62d70b63 100755 --- a/private_set_intersection/javascript/scripts/build-psi-wasm.sh +++ b/private_set_intersection/javascript/scripts/build-psi-wasm.sh @@ -6,4 +6,4 @@ bazel build --config=wasm -c opt //private_set_intersection/javascript/cpp:psi_w bazel build --config=wasm -c opt //private_set_intersection/javascript/cpp:psi_wasm_worker.js # Build the protobuf compiler. -bazel build -c opt --platforms="@local_config_platform//:host" @protobuf//:protoc \ No newline at end of file +bazel build -c opt --platforms="@local_config_platform//:host" @protobuf//:protoc diff --git a/private_set_intersection/python/requirements/BUILD b/private_set_intersection/python/requirements/BUILD index fa504007..43352221 100644 --- a/private_set_intersection/python/requirements/BUILD +++ b/private_set_intersection/python/requirements/BUILD @@ -33,3 +33,4 @@ compile_pip_requirements_3_12( src = "requirements.in", requirements_txt = "requirements_lock_3_12.txt", ) + diff --git a/private_set_intersection/rust/tests/integration_test.rs b/private_set_intersection/rust/tests/integration_test.rs index 34a64e1d..4d32bd6b 100644 --- a/private_set_intersection/rust/tests/integration_test.rs +++ b/private_set_intersection/rust/tests/integration_test.rs @@ -65,6 +65,7 @@ fn integration_test() { let set: HashSet = HashSet::from_iter(intersection.into_iter()); for i in 0..NUM_CLIENT_ELEMENTS as i64 { + // Can fail due to false positives. assert_eq!(set.contains(&i), i % 2 == 0); } } else { @@ -72,7 +73,7 @@ fn integration_test() { assert!(intersection_size >= (NUM_CLIENT_ELEMENTS / 2)); assert!( - (intersection_size as f64) < ((NUM_CLIENT_ELEMENTS as f64) / 2.0 * 1.1).ceil() + (intersection_size as f64) <= ((NUM_CLIENT_ELEMENTS as f64) / 2.0 * 1.1).ceil() ); } }