Skip to content

Fixing swc specific bug with decorators and constructors #430

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

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

tegefaulkes
Copy link
Contributor

@tegefaulkes tegefaulkes commented Jul 26, 2022

Description

Due to a difference with swc on how decorators are handled. Classes were constructed without decorators applied when called inside of createX static functions. This was solved by using new this() to construct instead.

Fixed up some linting errors as well. Some // @ts-ignore lines were added without descriptions.

Tasks

  • 1. Use new this() to construct the class inside of createX static methods.

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

Due to a difference with swc on how decorators are handled. Classes were constructed without decorators applied when called inside of `createX` static functions. This was solved by using `new this()` to construct instead.

Fixed up some linting errors as well.
@ghost
Copy link

ghost commented Jul 26, 2022

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@tegefaulkes
Copy link
Contributor Author

There still are tests failing but I don't think they're related to the above bug. Here is a summary;

Summary of all failing tests
 FAIL  tests/nat/DMZ.test.ts (82.38 s)
  ● DMZ › agents in different namespaces can ping each other

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      192 |           dataDir,
      193 |         ));
    > 194 |         expect(exitCode).toBe(0);
          |                          ^
      195 |         expect(JSON.parse(stdout)).toEqual({
      196 |           success: true,
      197 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/DMZ.test.ts:194:26)

  ● DMZ › agents in different namespaces can ping each other via seed node

    thrown: "Exceeded timeout of 40000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      216 |       global.defaultTimeout * 2,
      217 |     );
    > 218 |     test(
          |     ^
      219 |       'agents in different namespaces can ping each other via seed node',
      220 |       async () => {
      221 |         const {

      at tests/nat/DMZ.test.ts:218:5
      at describeIf (tests/utils.ts:203:5)
      at Object.<anonymous> (tests/nat/DMZ.test.ts:14:11)

 FAIL  tests/nat/endpointDependentNAT.test.ts (93.588 s)
  ● endpoint dependent NAT traversal › node1 behind EDM NAT connects to node2

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      73 |           dataDir,
      74 |         );
    > 75 |         expect(exitCode).toBe(0);
         |                          ^
      76 |         expect(JSON.parse(stdout)).toEqual({
      77 |           success: true,
      78 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/endpointDependentNAT.test.ts:75:26)

  ● endpoint dependent NAT traversal › node1 connects to node2 behind EDM NAT

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      128 |           dataDir,
      129 |         ));
    > 130 |         expect(exitCode).toBe(0);
          |                          ^
      131 |         expect(JSON.parse(stdout)).toEqual({
      132 |           success: true,
      133 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/endpointDependentNAT.test.ts:130:26)

  ● endpoint dependent NAT traversal › node1 behind EDM NAT cannot connect to node2 behind EDM NAT

    thrown: undefined

      153 |       global.defaultTimeout * 2,
      154 |     );
    > 155 |     test(
          |     ^
      156 |       'node1 behind EDM NAT cannot connect to node2 behind EDM NAT',
      157 |       async () => {
      158 |         const {

      at tests/nat/endpointDependentNAT.test.ts:155:5
      at describeIf (tests/utils.ts:203:5)
      at Object.<anonymous> (tests/nat/endpointDependentNAT.test.ts:10:11)

  ● endpoint dependent NAT traversal › node1 behind EDM NAT cannot connect to node2 behind EIM NAT

    thrown: "Exceeded timeout of 40000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      207 |       global.defaultTimeout * 2,
      208 |     );
    > 209 |     test(
          |     ^
      210 |       'node1 behind EDM NAT cannot connect to node2 behind EIM NAT',
      211 |       async () => {
      212 |         const {

      at tests/nat/endpointDependentNAT.test.ts:209:5
      at describeIf (tests/utils.ts:203:5)
      at Object.<anonymous> (tests/nat/endpointDependentNAT.test.ts:10:11)

 FAIL  tests/nat/endpointIndependentNAT.test.ts (172.594 s)
  ● endpoint independent NAT traversal › node1 behind EIM NAT connects to node2

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      73 |           dataDir,
      74 |         );
    > 75 |         expect(exitCode).toBe(0);
         |                          ^
      76 |         expect(JSON.parse(stdout)).toEqual({
      77 |           success: true,
      78 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/endpointIndependentNAT.test.ts:75:26)

  ● endpoint independent NAT traversal › node1 connects to node2 behind EIM NAT

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      163 |           dataDir,
      164 |         ));
    > 165 |         expect(exitCode).toBe(0);
          |                          ^
      166 |         expect(JSON.parse(stdout)).toEqual({
      167 |           success: true,
      168 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/endpointIndependentNAT.test.ts:165:26)

  ● endpoint independent NAT traversal › node1 behind EIM NAT connects to node2 behind EIM NAT

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: 1

      269 |           dataDir,
      270 |         ));
    > 271 |         expect(exitCode).toBe(0);
          |                          ^
      272 |         expect(JSON.parse(stdout)).toEqual({
      273 |           success: true,
      274 |           message: 'Node is Active.',

      at Object.<anonymous> (tests/nat/endpointIndependentNAT.test.ts:271:26)

  ● endpoint independent NAT traversal › node1 behind EIM NAT connects to node2 behind EIM NAT via seed node

    thrown: "Exceeded timeout of 40000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      294 |       global.defaultTimeout * 2,
      295 |     );
    > 296 |     test(
          |     ^
      297 |       'node1 behind EIM NAT connects to node2 behind EIM NAT via seed node',
      298 |       async () => {
      299 |         const {

      at tests/nat/endpointIndependentNAT.test.ts:296:5
      at describeIf (tests/utils.ts:203:5)
      at Object.<anonymous> (tests/nat/endpointIndependentNAT.test.ts:10:11)

  ● endpoint independent NAT traversal › node1 behind EIM NAT cannot connect to node2 behind EDM NAT

    thrown: "Exceeded timeout of 40000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      346 |       global.defaultTimeout * 2,
      347 |     );
    > 348 |     test(
          |     ^
      349 |       'node1 behind EIM NAT cannot connect to node2 behind EDM NAT',
      350 |       async () => {
      351 |         const {

      at tests/nat/endpointIndependentNAT.test.ts:348:5
      at describeIf (tests/utils.ts:203:5)
      at Object.<anonymous> (tests/nat/endpointIndependentNAT.test.ts:10:11)

 FAIL  tests/vaults/VaultManager.test.ts (305.926 s)
  ● VaultManager › cannot concurrently create vaults with the same name

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: [{"data": [171, 2, 167, 19, 161, 206, 70, 154, 129, 202, …], "type": "IdInternal"}, {"data": [149, 126, 240, 165, 106, 178, 78, 231, 177, 99, …], "type": "IdInternal"}]

      342 |         vaultManager.createVault(vaultName),
      343 |       ]);
    > 344 |       await expect(() => vaults).rejects.toThrow(
          |             ^
      345 |         vaultsErrors.ErrorVaultsVaultDefined,
      346 |       );
      347 |     } finally {

      at expect (node_modules/expect/build/index.js:128:15)
      at Object.<anonymous> (tests/vaults/VaultManager.test.ts:344:13)


Test Suites: 4 failed, 132 passed, 136 total
Tests:       12 failed, 4 todo, 692 passed, 708 total
Snapshots:   0 total
Time:        333.593 s

@CMCDragonkai
Copy link
Member

What was the reason for changing the tests? Should focus only on converting to this and then merge to staging.

@tegefaulkes
Copy link
Contributor Author

The test changes was just fixing linting.

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

Successfully merging this pull request may close these issues.

2 participants