Skip to content

test(network): add a regression test for #1079 (EntityRef.copy on a client) - #5384

Open
soloturn wants to merge 1 commit into
developfrom
soloturn-entity-copy-client-test-1079
Open

test(network): add a regression test for #1079 (EntityRef.copy on a client)#5384
soloturn wants to merge 1 commit into
developfrom
soloturn-entity-copy-client-test-1079

Conversation

@soloturn

Copy link
Copy Markdown
Contributor

AI-assisted change proposal. Filed by agent driven by @soloturn via GDD.

Investigated #1079 ("EntityManager::copy works incorrectly on a remote client" - copying a networked entity and modifying the copy also modified the original, attributed at the time to the copy's EntityRef getting redirected via net-id lookup).

Traced the mechanism the original report described: NetworkEntitySystem#onAddNetworkComponent is what registers a NetworkComponent-bearing entity into the netId→entity lookup (NetworkSystemImpl#netIdToEntityId). It's gated @NetFilterEvent(netFilter = RegisterMode.AUTHORITY) - a client never runs it, including for a locally-created copy that happens to carry a (copied) NetworkComponent. That's the mechanism the 2014 report needed to exist for the redirection to happen, and it doesn't apply client-side.

Confirmed by running an actual test against a real client context via the MTE integration environment (ModuleTestingHelper#createClient()): creating a NetworkComponent-bearing entity on a client, copying it, and mutating a component on the copy leaves the original untouched.

No production code change - the bug doesn't reproduce against current develop. Adding the test as a permanent regression guard and documentation of why, since the entity system has been substantially rewritten since 2014 and nothing currently links back to this issue.

Test plan

  • EntityCopyOnClientTest (1/1 pass) via :engine-tests:integrationTest.

…lient)

#1079 reported that copying a networked entity on a remote client and then
modifying a component on the copy also modified the original, attributed at
the time to the copy's EntityRef "getting directed to the last registered
thing with the given net id".

That mechanism no longer exists: NetworkEntitySystem#onAddNetworkComponent,
which registers a NetworkComponent-bearing entity into the netId lookup, is
gated @NetFilterEvent(netFilter = RegisterMode.AUTHORITY) - a client never
runs it, including for a locally-created copy that happens to carry a
(copied) NetworkComponent. Confirmed by running this test against a real
client context via the MTE integration environment: component mutation on
the copy is properly isolated from the original.

No production code change - the bug doesn't reproduce. Adding the test as
a permanent regression guard and documentation of why.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 67d054c7-5960-450e-8dbf-ed72e46a1caa

📥 Commits

Reviewing files that changed from the base of the PR and between 338d7dd and 190838f.

📒 Files selected for processing (1)
  • engine-tests/src/test/java/org/terasology/engine/integrationenvironment/EntityCopyOnClientTest.java

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added a regression test confirming that copying a networked entity on a client creates an independent entity.
    • Verified that modifying a component on the copied entity does not change the original entity.

Walkthrough

Adds an integration regression test for copying a networked entity on a client. The test verifies that changing a component on the copy does not change the original entity.

Changes

Client entity copy isolation

Layer / File(s) Summary
Client copy isolation test
engine-tests/src/test/java/org/terasology/engine/integrationenvironment/EntityCopyOnClientTest.java
Creates a networked entity on a client, copies it, changes the copy’s component value, and verifies that the original retains its value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 19083

This is a localized regression-test-only change with no production behavior change, and the reported integration test passes. No actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit copied an entity with care,
Its values stayed safely paired.
The copy changed from forty-two to ninety-nine,
While the original kept its own design.
“Separate refs!” the rabbit cheered,
“The regression test is cleared!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the regression test, its network scope, and issue #1079.
Description check ✅ Passed The description explains the issue, investigation, test behavior, and verification result, and it matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch soloturn-entity-copy-client-test-1079

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants