Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
s0l0ist committed Sep 30, 2024
1 parent b4df2ed commit 5a6f752
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 17 deletions.
9 changes: 1 addition & 8 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
workspace(
name = "org_openmined_psi",
)

# Emsdk
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

Expand Down
2 changes: 1 addition & 1 deletion private_set_intersection/c/integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions private_set_intersection/cpp/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("//tools:common.bzl", "template_rule")

#
# Copyright 2020 the authors listed in CONTRIBUTORS.md
#
Expand All @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion private_set_intersection/cpp/psi_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion private_set_intersection/cpp/psi_server_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
3 changes: 2 additions & 1 deletion private_set_intersection/go/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion private_set_intersection/javascript/scripts/build-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
bazel build -c opt --platforms="@local_config_platform//:host" @protobuf//:protoc
1 change: 1 addition & 0 deletions private_set_intersection/python/requirements/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ compile_pip_requirements_3_12(
src = "requirements.in",
requirements_txt = "requirements_lock_3_12.txt",
)

3 changes: 2 additions & 1 deletion private_set_intersection/rust/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ fn integration_test() {
let set: HashSet<i64> = 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 {
let intersection_size = client.get_intersection_size(&setup, &response).unwrap();

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()
);
}
}
Expand Down

0 comments on commit 5a6f752

Please sign in to comment.