Skip to content

Implement listbanned method and test #225

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GideonBature
Copy link
Contributor

The JSON-RPC method listbanned does return a type. We want to test this to catch any changes in behavior in future Core versions.

This PR adds a client function that errors if the return value is anything other than the type it returns, along with an integration test that calls this function.

Ref: #116

@tcharding
Copy link
Member

There are a few problems with this one. Primarily the integration test does not test anything because the vector in ListBanned is always empty so the Banned struct is never tested.

Can you fix that up and we'll go from there?

Also:

  • the client macro needs underscore in the name
  • the last patch should be part of the first

Thanks

@GideonBature
Copy link
Contributor Author

oh my... Let me fix them up.

@GideonBature GideonBature force-pushed the listbanned branch 6 times, most recently from a303ca2 to 66875fb Compare June 3, 2025 16:58
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better man.

@GideonBature GideonBature force-pushed the listbanned branch 2 times, most recently from 12c00a4 to afba694 Compare June 5, 2025 09:02
@tcharding
Copy link
Member

I think something is still wrong here. If I comment out the fields in Banned and run the tests it still passes?

@GideonBature
Copy link
Contributor Author

GideonBature commented Jun 6, 2025

Woaw... Let check what is wrong.

@GideonBature
Copy link
Contributor Author

I think something is still wrong here. If I comment out the fields in Banned and run the tests it still passes?

Thank you for pointing this out. seems the test was only checking if there is at least an element inside of the ListBanned, which would be the Banned entry, but not verifying whether the Banned struct itself contains valid field data. I added an assertion for the address field since it is present across all versions. Still thinking of a more robust way to handle this.

@tcharding
Copy link
Member

tcharding commented Jun 6, 2025

The fact that the list is not empty should imply that at least one Banned struct was deresrialized. That is why I thought it strange that removing fields didn't make the test fail. I'm not 100% sure I'm not misunderstanding something though. Perhaps leave it with me and I'll investigate.

@GideonBature
Copy link
Contributor Author

True, I was surprised with the behaviour too. No problem. Thank you...

@tcharding
Copy link
Member

Needs rebase. Can you post when you force push with what changed please. I'm still confused by this PR.

@GideonBature
Copy link
Contributor Author

Before now what I did was to improve the test to check for the address field if it correctly returns the address that is being banned.

Let me rebase now...

@GideonBature GideonBature force-pushed the listbanned branch 2 times, most recently from 25e8f27 to 656ad41 Compare June 9, 2025 08:12
Copy link
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now, just a couple of minor suggestions.

The test works now as far as I can tell, but would be improved with the previously suggested change.

@GideonBature
Copy link
Contributor Author

This looks good now, just a couple of minor suggestions.

The test works now as far as I can tell, but would be improved with the previously suggested change.

Thank you for your review, suggestions have been effected.

@GideonBature GideonBature force-pushed the listbanned branch 2 times, most recently from 52896c8 to 257d74b Compare June 11, 2025 09:11
@tcharding
Copy link
Member

In v17 listbanned returns null so I'd expect to see that verified in the client macro. Then in the v17 types docs I expected to see 'returns nothing'. Then in what ever version introduces the result I'd expect to see an additional client macro for that version and have it used for subsequent versions. Then the test would probably have to handle the difference macro calls also.

@jamillambert
Copy link
Collaborator

I think something is still wrong here. If I comment out the fields in Banned and run the tests it still passes?

This seems to be a bigger issue with the tests in general and not just localized to this PR. See issue #241

@GideonBature
Copy link
Contributor Author

In v17 listbanned returns null so I'd expect to see that verified in the client macro. Then in the v17 types docs I expected to see 'returns nothing'. Then in what ever version introduces the result I'd expect to see an additional client macro for that version and have it used for subsequent versions. Then the test would probably have to handle the difference macro calls also.

Alright, in the docs, for v17 not much was said about the listbanned including what it is returning, so I decided to check the core, and found out listbanned is returning a json-array. Then for subsequent versions there are some changes made to the fields of this json.

@jamillambert
Copy link
Collaborator

In v17 listbanned returns null so I'd expect to see that verified in the client macro. Then in the v17 types docs I expected to see 'returns nothing'. Then in what ever version introduces the result I'd expect to see an additional client macro for that version and have it used for subsequent versions. Then the test would probably have to handle the difference macro calls also.

Alright, in the docs, for v17 not much was said about the listbanned including what it is returning, so I decided to check the core, and found out listbanned is returning a json-array. Then for subsequent versions there are some changes made to the fields of this json.

I can confirm that v17 does return all of the fields in Banned and it is just the core v17 help that is incomplete/unhelpful.

@tcharding
Copy link
Member

Sorry mate, needs rebase again. I'll try get this one in next.

@GideonBature GideonBature force-pushed the listbanned branch 3 times, most recently from ded3243 to 5469b7c Compare June 14, 2025 02:43
Copy link
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK f76918a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants