Skip to content
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

Correct uniqueness lookup for nil location #1433

Merged
merged 4 commits into from
Jan 12, 2024
Merged

Conversation

peterbroadhurst
Copy link
Contributor

@peterbroadhurst peterbroadhurst commented Dec 14, 2023

It's extremely hard for an external client calling the AddContractListener REST API to determine whether the listener already exists, because the details are a factor of a complex FFI payload.

For this reason FireFly provides a uniqueness check for the:

  • namespace
  • topic - allows multiple listeners to the same event, for different apps
  • location - can be nil, or a blockchain-specific location
  • signature - generated by FireFly in a protocol specific way from the supplied FFI signature

However, the code doing a lookup in the DB was not working for the nil check, due to a .ToString()

Annoyingly there's a weirdness with fftypes.JSONAny.Value() in the nil case, and for some reason passing a (*fftypes.JSONAny)(nil) into fb.Eq() is not generating an IS NULL SQL query.

So instead this code passes actual nil in the nil case, and this works.

This is really an underlying issue in firefly-common for a ffapi.JSONField case, but that's too risky a change to do in isolation

@peterbroadhurst peterbroadhurst requested a review from a team as a code owner December 14, 2023 00:56
@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4645f28) 99.99% compared to head (a1c2760) 99.99%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1433   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         321      321           
  Lines       23092    23095    +3     
=======================================
+ Hits        23090    23093    +3     
  Misses          1        1           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterbroadhurst peterbroadhurst marked this pull request as draft December 14, 2023 02:20
@peterbroadhurst peterbroadhurst marked this pull request as ready for review December 14, 2023 02:33
@nguyer nguyer merged commit c55da26 into main Jan 12, 2024
14 checks passed
@nguyer nguyer deleted the correct-unique-check branch January 12, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants