[Duplicate Code] Share the Cloud Hypervisor network-plan fixture between launch and config tests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing
Research direction
Start with the duplicated fixtures in src/cloud-hypervisor/manager-launch.test.ts and src/cloud-hypervisor/vm-config-builder.test.ts, then inspect the surrounding test utilities. Add the shared createTestNetworkPlan() helper in src/cloud-hypervisor/manager.test-utils.ts and update both tests to use it. Done means the topology is defined once and both test suites continue to use the expected network-interface data.
Written by the indexing model from the issue text.
Description
Duplicate Code Opportunity
Summary
- Pattern: The same Cloud Hypervisor network-plan fixture is inlined in two tests instead of being shared through a helper.
- Locations:
src/cloud-hypervisor/manager-launch.test.ts:17-40,src/cloud-hypervisor/vm-config-builder.test.ts:7-30 - Impact: 24 duplicated lines in a hot test area. Updates to the default topology, guest addresses, or interface metadata must be made in two places.
Evidence
A. src/cloud-hypervisor/manager-launch.test.ts:17-40
const args = buildSupervisorBootArgs({
runId: 'run',
resourceToken: '000000000000',
namespaceName: 'ns',
netnsPath: '/var/run/netns/ns',
nftTableName: 'table',
hostForwardRuleComment: 'awf:awf_vm_0123456789ab',
infrastructureBridge: 'awfbr0',
hostVethName: 'host',
namespaceVethName: 'namespace',
tapName: 'tap',
infrastructureIp: '172.30.0.20',
infrastructureCidr: '172.30.0.0/24',
hostGatewayIp: '172.30.0.1',
guestSubnet: '100.64.0.0/30',
guestIp: '100.64.0.2',
guestGatewayIp: '100.64.0.1',
guestPrefixLength: 30,
guestMac: '02:00:00:00:00:01',
tapOwnerUid: 1000,
tapOwnerGid: 1000,
tapVnetHdr: true,
allowedEndpoints: [],
networkInterface: { iface_id: 'eth0', host_dev_name: 'tap' },
}, guestConfig());
B. src/cloud-hypervisor/vm-config-builder.test.ts:7-30
return {
runId: 'run',
resourceToken: '000000000000',
namespaceName: 'ns',
netnsPath: '/var/run/netns/ns',
nftTableName: 'table',
hostForwardRuleComment: 'awf:awf_vm_0123456789ab',
infrastructureBridge: 'awfbr0',
hostVethName: 'host',
namespaceVethName: 'namespace',
tapName: 'tap',
infrastructureIp: '172.30.0.20',
infrastructureCidr: '172.30.0.0/24',
hostGatewayIp: '172.30.0.1',
guestSubnet: '100.64.0.0/30',
guestIp: '100.64.0.2',
guestGatewayIp: '100.64.0.1',
guestPrefixLength: 30,
guestMac: '02:00:00:00:00:01',
tapOwnerUid: 1000,
tapOwnerGid: 1000,
tapVnetHdr: true,
allowedEndpoints: [],
networkInterface: { iface_id: 'eth0', host_dev_name: 'tap', guest_mac: '02:00:00:00:00:01' },
};
Suggested Refactoring
Extract a shared createTestNetworkPlan() helper or fixture in src/cloud-hypervisor/manager.test-utils.ts and reuse it from both tests. That keeps the canonical Cloud Hypervisor topology in one place.
Affected Files
src/cloud-hypervisor/manager-launch.test.ts— lines 17-40src/cloud-hypervisor/vm-config-builder.test.ts— lines 7-30
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-09-24
Generated by Duplicate Code Detector · copilot · gpt50mini · 9.48 AIC · ⊞ 21K · ◷
- expires on Oct 24, 2026, 9:43 PM UTC
- Dominant language
- TypeScript
- Stars
- 145
- Forks
- 63
- Avg merge
- 6h 21m
- Merged PRs (30d)
- 239
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-aw-firewall
-
agentic-workflows automated dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/gh-aw-firewall#3837 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 4/5 3-5 days Newbie friendliness 35/100
github/gh-aw-firewall#9023 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 3/5 1-2 days Newbie friendliness 42/100
github/gh-aw-firewall#9022 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 4/5 3-5 days Newbie friendliness 25/100
github/gh-aw-firewall#9021 ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 3/5 1-2 days Newbie friendliness 76/100
github/gh-aw-firewall#9018 ·
Maintainers usually reply within 1 day
All issues in github/gh-aw-firewall
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
diegosouzapw/OmniRoute#14869 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
Maintainers usually reply within 1 day
-
status: waiting triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
freeCodeCamp/freeCodeCamp#70412 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 88/100
opensearch-project/OpenSearch-Dashboards#12816 ·
Maintainers usually reply within 1 day