Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Duplicate Code] Share the Cloud Hypervisor network-plan fixture between launch and config tests

Closed Beginner friendly
#8,974 0 comments 0 reactions 0 assignees View on GitHub

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

code-quality refactoring

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-40
  • src/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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/gh-aw-firewall

All issues in github/gh-aw-firewall

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.