-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
[ECS] Infra for comprehensive unit tests #198
Conversation
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.
If we are to move forward with my proposal in #199, here is what I think should happen (in no particular order):
- Move all of Valence's tokio code and initial login procedures into a separate crate, let's call it
valence_network
.valence
should no longer have a dependency on tokio. It is the responsibility ofvalence_network
to spawnClient
entities as connections are made to the server.valence_network
exposes a BevyPlugin
. TheOwnedSemaphorePermit
that is stored inClient
can be moved into a separate component defined invalence_network
.Client
's constructor now looks like this:pub fn new(info: NewClientInfo, stream: Box<dyn PacketStream>) -> Self { ... }
PacketStream
is a new trait that hastry_send
andtry_recv
methods similar to byte channels.
With those things done, setting up test infra should be easy. How much of that you want to address here or elsewhere is up to you.
This comment was marked as outdated.
This comment was marked as outdated.
This is necessary for #198 because otherwise `cargo test -p valence_new` fails to build.
Actually I just realized it would make more sense to put the semaphore permit in |
I've moved mostly everything related to accepting connections into
|
Let me lay down a few things just so we're on the same page.
Hopefully there aren't any major issues I'm overlooking. |
Just a thought: The ability to enable/disable plugins in a general way in the "stageless" rearchitecture of Bevy (coming in the next release) would make a lot of sense for toggleable "Open to LAN" functionality in singleplayer mode. And even in regular servers I could see it being useful too. |
From discussion on discord: this valence_network refactor is too complex for me to handle right now, so I'm just going to be adding the |
injecting recv packets works, but not sending packets yet
Some things I'd love to be able to test once this is complete because the entity/chunk code is horribly complicated:
|
I've implemented my previous suggestions along with the |
Sorry about the merge conflicts 😬 |
There's a couple of weird quirks that I've discovered when working on
And regarding the merge conflicts, it seems like I'm probably going to have to rewrite most of this PR to make it work again. |
Perhaps you could wrap up all the initialization boilerplate (create an app, create an instance and client, add client to instance, etc.) in a helper function? Immediately disconnecting the client when not in an instance was a deliberate design choice, but maybe we could afford to be a bit lax there. |
should slightly reduce build time when cfg(not(test))
I think this is ready to review. I'm happy with the verbosity of the example tests. It should be sufficient to test that chunk stuff. |
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.
Looking good.
Motivation: There are a lot of edge cases we have to handle, and every new line of code we write increases the risk of regressions. Regressions slow down dev time: a perfect example of this is what happened in #189.
Unsolved issues:
test_client_position
is flakeyTest plan