New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify testing with dummy arithmetic #327
Conversation
Can be used to simplify unit tests; no need to create a subclass of TestThreadFactory for each test.
Incidentally fixes that some tests were not running because they were missing from the TestDummyArithmeticProtocolSuite.
Closing and opening to trigger a rebuild in Travis. |
Codecov Report
@@ Coverage Diff @@
## master #327 +/- ##
========================================
Coverage 100% 100%
- Complexity 3312 3440 +128
========================================
Files 369 373 +4
Lines 9178 9626 +448
Branches 689 752 +63
========================================
+ Hits 9178 9626 +448
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement. We should consider how to reuse tests across protocols, it is not clear to me that this is achievable with this PR
return run(application, 1); | ||
} | ||
|
||
static public <T> T run(Application<T, ProtocolBuilderNumeric> application, int numberOfParties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion. Change run to:
run(
Supplier input,
Function<InputT, Application test,
Consumer verifier
)
This will make the tests stepwise present lambdas with different purposes
I like this simplification, and I am thinking it can go towards #198. However, you also loose some generality. The focus on the old way of writing the tests (as in the old Would there be some way to achieve the same generality with this simpler method? |
core/src/test/java/dk/alexandra/fresco/lib/real/LinearAlgebraTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/dk/alexandra/fresco/lib/real/LinearAlgebraTest.java
Outdated
Show resolved
Hide resolved
dbf642b
to
af691ca
Compare
Thanks for mentioning the reuse of test code, @pffrandsen & @GuutBoy. Personally, I would be inclined to separate out those tests that test computations (such as the linear algebra ones) from the ones that test protocol suites (such as spdz). I would prefer to have tests fail for a single reason only. However, if you really want to reuse test logic, then you can do this with the Runner concept as well. Most tests look like this: void myTest() {
// Define input
// Create application
run(application)
// Check result
} You could run them with different runners like this: void myTestDummy() {
app = createMyTestApp()
result = DummyArithmeticRunner.run(app)
checkMyTestResult(result)
}
void myTestSpdz() {
app = createMyTestApp()
result = SpdzRunner.run(app)
checkMyTestResult(result)
}
Application<> createMyTestApp() {
// Define input
// Create application
}
void checkMyTestResult(result) {
// Check result
} |
Closing and opening to trigger a rebuild in Travis. |
Closing due to inactivity. |
This introduces a DummyArithmeticRunner. It has a static run() method to run an application with dummy arithmetic.
We use this to remove about 200 lines of boilerplate code from the LinearAlgebraTests.