zkopru-network / blind-find

A peer-to-peer network allowing private peer search proposed by Barry Whitehat and Kobi Gurkan.
https://ethresear.ch/t/blind-find-private-social-network-search/6988
13 stars 2 forks source link

Fix skipped test in `proofOfSMP.test.ts` #15

Closed mhchia closed 3 years ago

mhchia commented 3 years ago

Our tests began failing after we switch to hardhat. It seems proofOfSMP.test.ts conflicts with genProof.test.ts. ~I'm guessing it's related to circom or~ the different behavior between jest and mocha. Skip it for now since the logic inside is tested in genProof.test.ts. Error message is here

mhchia commented 3 years ago

This turns out to be my own fault due to the cache of the result from successfulSMPMessagesFactory. In every proofOfSMPInputsFactory call, keypairC.pubKey is generated randomly and is passed to successfulSMPMessagesFactory as the secret. However, I made the result from proofOfSMPInputsFactory as a singleton, and thus every successfulSMPMessagesFactory always returns the same result as the first call to the function. This is wrong because SMP messages should be calculated again whenever the secret is changed. Shout out to @NIC619 for discussing w/ me and giving me the direction of debugging.

However, the reason why it didn't fail when I used tsdx is still interesting. For example, in commit https://github.com/mhchia/blind-find/commit/c8b4573481c770ed761d25d99a058f64d211d44a the tests are run successfully. One guess is each test file is run independently and thus the cache is not used at all in tsdx. This should be investigated further.