trac-msb 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.env +0 -0
  2. package/.github/workflows/CI.yml +2 -4
  3. package/.github/workflows/acceptance-tests.yml +35 -0
  4. package/package.json +8 -6
  5. package/rpc/handlers.mjs +9 -2
  6. package/src/index.js +4 -0
  7. package/src/utils/helpers.js +2 -0
  8. package/{test → tests}/acceptance/v1/rpc.test.mjs +2 -2
  9. package/{test → tests/integration}/apply/addAdmin/addAdminBasic.test.js +6 -6
  10. package/{test → tests/integration}/apply/addAdmin/addAdminRecovery.test.js +8 -8
  11. package/{test → tests/integration}/apply/addIndexer.test.js +3 -4
  12. package/{test → tests/integration}/apply/addWhitelist.test.js +5 -5
  13. package/{test → tests/integration}/apply/addWriter.test.js +7 -7
  14. package/{test → tests/integration}/apply/banValidator.test.js +13 -14
  15. package/{test → tests/integration}/apply/postTx/invalidSubValues.test.js +6 -7
  16. package/{test → tests/integration}/apply/postTx/postTx.test.js +7 -8
  17. package/{test → tests/integration}/apply/removeIndexer.test.js +4 -4
  18. package/{test → tests/integration}/apply/removeWriter.test.js +5 -5
  19. package/{test → tests/integration}/apply/transfer.test.js +7 -7
  20. package/tests/integration/integration.test.js +9 -0
  21. package/{test → tests/unit}/messageOperations/assemblePostTransaction.test.js +1 -1
  22. package/{test → tests/unit}/network/ConnectionManager.test.js +5 -5
  23. package/{test → tests/unit}/state/stateTestUtils.js +1 -1
  24. package/{test → tests/unit}/state/utils/address.test.js +2 -2
  25. package/{test → tests/unit}/state/utils/adminEntry.test.js +3 -3
  26. package/{test → tests/unit}/state/utils/balance.test.js +5 -5
  27. package/{test → tests/unit}/state/utils/indexerEntry.test.js +2 -2
  28. package/{test → tests/unit}/state/utils/lengthEntry.test.js +1 -1
  29. package/{test → tests/unit}/state/utils/nodeEntry.test.js +3 -3
  30. package/{test → tests/unit}/state/utils/roles.test.js +1 -1
  31. package/tests/unit/unit.test.js +14 -0
  32. package/{test/functions → tests/unit/utils/amountSerialization}/amountSerialization.test.js +3 -3
  33. package/{test → tests/unit/utils}/buffer/buffer.test.js +1 -1
  34. package/{test → tests/unit/utils}/check/adminControlOperation.test.js +2 -2
  35. package/{test → tests/unit/utils}/check/balanceInitializationOperation.test.js +2 -2
  36. package/{test → tests/unit/utils}/check/bootstrapDeploymentOperation.test.js +2 -2
  37. package/{test → tests/unit/utils}/check/common.test.js +2 -2
  38. package/{test → tests/unit/utils}/check/coreAdminOperation.test.js +2 -2
  39. package/{test → tests/unit/utils}/check/roleAccessOperation.test.js +2 -2
  40. package/{test → tests/unit/utils}/check/transactionOperation.test.js +2 -2
  41. package/{test → tests/unit/utils}/check/transferOperation.test.js +2 -2
  42. package/{test/functions → tests/unit/utils/crypto}/createHash.test.js +1 -1
  43. package/{test → tests/unit/utils}/fileUtils/readAddressesFromWhitelistFile.test.js +2 -2
  44. package/{test → tests/unit/utils}/fileUtils/readBalanceMigrationFile.test.js +2 -3
  45. package/{test/functions/functions.test.js → tests/unit/utils/helpers/helpers.test.js} +0 -3
  46. package/{test/functions → tests/unit/utils/helpers}/isHexString.test.js +1 -1
  47. package/{test/functions → tests/unit/utils/helpers}/normalizeHex.test.js +1 -1
  48. package/{test → tests/unit/utils}/migrationUtils/validateAddressFromIncomingFile.test.js +3 -3
  49. package/{test/functions → tests/unit/utils/protobuf}/applyOperations.test.js +3 -3
  50. package/{test/protobuf/protobuf.test.js → tests/unit/utils/protobuf/operationHelpers.test.js} +3 -2
  51. package/tests/unit/utils/protobuf/protobuf.test.js +12 -0
  52. package/tests/unit/utils/utils.test.js +20 -0
  53. package/test/all.test.js +0 -23
  54. /package/{test → tests}/fixtures/apply.fixtures.js +0 -0
  55. /package/{test → tests}/fixtures/assembleMessage.fixtures.js +0 -0
  56. /package/{test → tests}/fixtures/check.fixtures.js +0 -0
  57. /package/{test → tests}/fixtures/protobuf.fixtures.js +0 -0
  58. /package/{test/utils → tests/helpers}/regexHelper.js +0 -0
  59. /package/{test/utils → tests/helpers}/setupApplyTests.js +0 -0
  60. /package/{test/utils → tests/helpers}/wrapper.js +0 -0
  61. /package/{test → tests/integration}/apply/apply.test.js +0 -0
  62. /package/{test → tests/unit}/messageOperations/assembleAddIndexerMessage.test.js +0 -0
  63. /package/{test → tests/unit}/messageOperations/assembleAddWriterMessage.test.js +0 -0
  64. /package/{test → tests/unit}/messageOperations/assembleAdminMessage.test.js +0 -0
  65. /package/{test → tests/unit}/messageOperations/assembleBanWriterMessage.test.js +0 -0
  66. /package/{test → tests/unit}/messageOperations/assembleRemoveIndexerMessage.test.js +0 -0
  67. /package/{test → tests/unit}/messageOperations/assembleRemoveWriterMessage.test.js +0 -0
  68. /package/{test → tests/unit}/messageOperations/assembleWhitelistMessages.test.js +0 -0
  69. /package/{test → tests/unit}/messageOperations/commonsStateMessageOperationsTest.js +0 -0
  70. /package/{test → tests/unit}/messageOperations/stateMessageOperations.test.js +0 -0
  71. /package/{test/network/connectionManagerTests.test.js → tests/unit/network/networkModule.test.js} +0 -0
  72. /package/{test → tests/unit}/state/State.test.js +0 -0
  73. /package/{test/state/stateTests.test.js → tests/unit/state/stateModule.test.js} +0 -0
  74. /package/{test → tests/unit}/state/utils/transaction.test.js +0 -0
  75. /package/{test → tests/unit/utils}/check/check.test.js +0 -0
package/.env ADDED
File without changes
@@ -30,12 +30,10 @@ jobs:
30
30
  cache: 'npm'
31
31
  - name: Install dependencies
32
32
  run: npm ci
33
- - name: Run node tests
34
- run: npm run test:node
35
33
  - name: Install bare
36
34
  run: npm i -g bare
37
- - name: Run bare tests
38
- run: npm run test:bare
35
+ - name: Run all tests
36
+ run: npm run test:unit:all
39
37
  # For now acceptance tests should be disable due to instability of the running MSB instance in the github actions environment
40
38
  # Github machines are not powerful enough to run MSB, and we won't ever finish our tests.
41
39
  # - name: Run rpc acceptance tests
@@ -0,0 +1,35 @@
1
+ name: MSB-Acceptance-Tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ concurrency:
7
+ group: ${{ github.workflow }}-${{ github.ref }}
8
+ cancel-in-progress: true
9
+
10
+ jobs:
11
+ integration-tests:
12
+ name: Acceptance Tests
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ matrix:
16
+ node-version: [lts/*]
17
+ os: [ubuntu-latest, macos-latest, windows-latest]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Use Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v3
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ cache: 'npm'
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Install bare
32
+ run: npm i -g bare
33
+
34
+ - name: Run Integration Tests
35
+ run: npm run test:acceptance
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
@@ -13,11 +13,13 @@
13
13
  "dev-rpc": "pear run -d . ${npm_config_store} --rpc --port ${npm_config_port}",
14
14
  "prod-rpc": "pear run . ${npm_config_store} --rpc --host ${npm_config_host} --port ${npm_config_port}",
15
15
  "protobuf": "node scripts/generate-protobufs.js",
16
- "test:acceptance": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testTimeout=200000 test/acceptance/",
17
- "test:node": "brittle-node -t 1200000 test/all.test.js",
18
- "test:bare": "brittle-bare -t 1200000 test/all.test.js",
19
- "test:node:cov": "brittle-node -c -t 1200000 test/all.test.js",
20
- "test:bare:cov": "brittle-bare -c -t 1200000 test/all.test.js"
16
+ "test:acceptance": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testTimeout=200000 tests/acceptance/",
17
+ "test:integration": "brittle-node -t 1200000 tests/integration/integration.test.js",
18
+ "test:unit:node": "brittle-node -t 60000 tests/unit/unit.test.js",
19
+ "test:unit:bare": "brittle-bare -t 60000 tests/unit/unit.test.js",
20
+ "test:unit:all": "(npm run test:unit:node && npm run test:unit:bare) || exit 1",
21
+ "test:unit:node:cov": "brittle-node -c -t 60000 tests/unit/unit.test.js",
22
+ "test:unit:bare:cov": "brittle-bare -c -t 60000 tests/unit/unit.test.js"
21
23
  },
22
24
  "dependencies": {
23
25
  "@tracsystems/blake3": "0.0.13",
package/rpc/handlers.mjs CHANGED
@@ -68,10 +68,17 @@ export async function handleBroadcastTransaction({ msbInstance, respond, req })
68
68
  const result = await msbInstance.handleCommand('/broadcast_transaction', null, sanitizedPayload);
69
69
  respond(200, { result });
70
70
  } catch (error) {
71
+ let code = error instanceof SyntaxError ? 400 : 500;
72
+ let errorMsg = code === 400 ? 'Invalid JSON payload.' : 'An error occurred processing the transaction.'
73
+
74
+ if(error.message.includes("Failed to broadcast transaction after multiple attempts.")){
75
+ code = 429;
76
+ errorMsg = "Failed to broadcast transaction after multiple attempts."
77
+ }
78
+
71
79
  console.error('Error in handleBroadcastTransaction:', error);
72
80
  // Use 400 for client errors (like bad JSON), 500 for server/command errors
73
- const code = error instanceof SyntaxError ? 400 : 500;
74
- respond(code, { error: code === 400 ? 'Invalid JSON payload.' : 'An error occurred processing the transaction.' });
81
+ respond(code, { error: errorMsg});
75
82
  }
76
83
  });
77
84
 
package/src/index.js CHANGED
@@ -1199,6 +1199,10 @@ export class MainSettlementBus extends ReadyResource {
1199
1199
  this.network.validatorConnectionManager.rotate() // force change connection rotation for the next retry
1200
1200
  }
1201
1201
 
1202
+ if (await this.#state.get(hash) === null) {
1203
+ throw new Error("Failed to broadcast transaction after multiple attempts.");
1204
+ }
1205
+
1202
1206
  return { message: "Transaction broadcasted successfully.", signedLength, unsignedLength, tx: hash };
1203
1207
  } else {
1204
1208
  // Handle case where payload is missing if called internally without one.
@@ -2,6 +2,8 @@ import b4a from "b4a";
2
2
  import {bufferToAddress} from "../core/state/utils/address.js";
3
3
  import { EntryType, TRAC_ADDRESS_SIZE } from "./constants.js";
4
4
 
5
+ //TODO: change file name or split functions below into multiple files (Remember to update imports and tests accordingly)
6
+
5
7
  export function isHexString(string) {
6
8
  return typeof string === 'string' && string.length > 1 && /^[0-9a-fA-F]+$/.test(string) && string.length % 2 === 0;
7
9
  }
@@ -1,8 +1,8 @@
1
1
  import request from "supertest"
2
2
  import { createServer } from "../../../rpc/create_server.mjs"
3
- import { initTemporaryDirectory } from '../../utils/setupApplyTests.js'
3
+ import { initTemporaryDirectory } from '../../helpers/setupApplyTests.js'
4
4
  import { testKeyPair1, testKeyPair2 } from '../../fixtures/apply.fixtures.js'
5
- import { randomBytes, setupMsbAdmin, setupMsbWriter, fundPeer, removeTemporaryDirectory } from "../../utils/setupApplyTests.js"
5
+ import { randomBytes, setupMsbAdmin, setupMsbWriter, fundPeer, removeTemporaryDirectory } from "../../helpers/setupApplyTests.js"
6
6
  import { $TNK } from "../../../src/core/state/utils/balance.js"
7
7
  import tracCrypto from 'trac-crypto-api';
8
8
  import b4a from 'b4a'
@@ -1,13 +1,13 @@
1
- import {test, hook} from '../../utils/wrapper.js';
1
+ import {test, hook} from '../../../helpers/wrapper.js';
2
2
  import {
3
3
  initMsbAdmin, initTemporaryDirectory, removeTemporaryDirectory, setupMsbPeer, setupMsbWriter, setupMsbIndexer,
4
4
  tryToSyncWriters
5
- } from '../../utils/setupApplyTests.js';
6
- import {randomBytes} from '../../utils/setupApplyTests.js';
7
- import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
8
- import {testKeyPair1} from '../../fixtures/apply.fixtures.js';
5
+ } from '../../../helpers/setupApplyTests.js';
6
+ import {randomBytes} from '../../../helpers/setupApplyTests.js';
7
+ import CompleteStateMessageOperations from '../../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
8
+ import {testKeyPair1} from '../../../fixtures/apply.fixtures.js';
9
9
  import b4a from 'b4a';
10
- import { ADMIN_INITIAL_BALANCE } from '../../../src/utils/constants.js';
10
+ import { ADMIN_INITIAL_BALANCE } from '../../../../src/utils/constants.js';
11
11
 
12
12
  //TODO: ADD TEST WHEN NON-ADMIN NODE FORGES ADD ADMIN OPERATION AND BROADCASTS IT TO THE STATE - SHOULD BE REJECTED
13
13
 
@@ -1,16 +1,16 @@
1
- import {test, hook} from '../../utils/wrapper.js';
1
+ import {test, hook} from '../../../helpers/wrapper.js';
2
2
  import {
3
3
  initTemporaryDirectory, removeTemporaryDirectory, setupMsbPeer, setupMsbWriter, setupMsbIndexer,
4
4
  tryToSyncWriters, waitForAdminEntry, setupMsbAdmin
5
- } from '../../utils/setupApplyTests.js';
5
+ } from '../../../helpers/setupApplyTests.js';
6
6
 
7
- import {randomBytes} from '../../utils/setupApplyTests.js';
8
- import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
9
- import PartialStateMessageOperations from '../../../src/messages/partialStateMessages/PartialStateMessageOperations.js'
10
- import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4} from '../../fixtures/apply.fixtures.js';
7
+ import {randomBytes} from '../../../helpers/setupApplyTests.js';
8
+ import CompleteStateMessageOperations from '../../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
9
+ import PartialStateMessageOperations from '../../../../src/messages/partialStateMessages/PartialStateMessageOperations.js'
10
+ import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4} from '../../../fixtures/apply.fixtures.js';
11
11
  import b4a from 'b4a';
12
- import { decode as decodeAdmin } from '../../../src/core/state/utils/adminEntry.js';
13
- import { EntryType } from '../../../src/utils/constants.js';
12
+ import { decode as decodeAdmin } from '../../../../src/core/state/utils/adminEntry.js';
13
+ import { EntryType } from '../../../../src/utils/constants.js';
14
14
  //TODO: ADD TEST WHEN NON-ADMIN NODE FORGES ADD ADMIN OPERATION AND BROADCASTS IT TO THE STATE - SHOULD BE REJECTED
15
15
 
16
16
  let admin, newAdmin;
@@ -1,6 +1,5 @@
1
1
  import {test, hook, solo} from 'brittle';
2
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
3
- import {formatIndexersEntry} from '../../src/utils/helpers.js';
2
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
4
3
  import {
5
4
  initTemporaryDirectory,
6
5
  removeTemporaryDirectory,
@@ -9,7 +8,7 @@ import {
9
8
  randomBytes,
10
9
  setupMsbPeer,
11
10
  setupWhitelist, waitForNodeState, tryToSyncWriters, waitIndexer
12
- } from '../utils/setupApplyTests.js';
11
+ } from '../../helpers/setupApplyTests.js';
13
12
  import {
14
13
  testKeyPair1,
15
14
  testKeyPair2,
@@ -18,7 +17,7 @@ import {
18
17
  testKeyPair5,
19
18
  testKeyPair6,
20
19
  testKeyPair7
21
- } from '../fixtures/apply.fixtures.js';
20
+ } from '../../fixtures/apply.fixtures.js';
22
21
  import b4a from 'b4a';
23
22
 
24
23
  let tmpDirectory, admin, indexer1, indexer2, reader1, reader2, indexer3, writer;
@@ -1,9 +1,9 @@
1
- import { test, hook } from '../utils/wrapper.js';
1
+ import { test, hook } from '../../helpers/wrapper.js';
2
2
  import b4a from 'b4a';
3
- import { setupMsbAdmin, initTemporaryDirectory, removeTemporaryDirectory, randomBytes } from '../utils/setupApplyTests.js';
4
- import { testKeyPair1, testKeyPair2 } from '../fixtures/apply.fixtures.js';
5
- import fileUtils from '../../src/utils/fileUtils.js';
6
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
3
+ import { setupMsbAdmin, initTemporaryDirectory, removeTemporaryDirectory, randomBytes } from '../../helpers/setupApplyTests.js';
4
+ import { testKeyPair1, testKeyPair2 } from '../../fixtures/apply.fixtures.js';
5
+ import fileUtils from '../../../src/utils/fileUtils.js';
6
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
7
7
  import { address as addressApi } from 'trac-crypto-api';
8
8
  import { TRAC_NETWORK_MSB_MAINNET_PREFIX } from 'trac-wallet/constants.js';
9
9
 
@@ -1,5 +1,5 @@
1
1
  import b4a from 'b4a';
2
- import { test, hook } from '../utils/wrapper.js';
2
+ import { test, hook } from '../../helpers/wrapper.js';
3
3
 
4
4
  import {
5
5
  setupMsbAdmin,
@@ -14,7 +14,7 @@ import {
14
14
  tryToSyncWriters,
15
15
  waitForNodeState,
16
16
  waitWritable
17
- } from '../utils/setupApplyTests.js';
17
+ } from '../../helpers/setupApplyTests.js';
18
18
  import {
19
19
  testKeyPair1,
20
20
  testKeyPair2,
@@ -22,11 +22,11 @@ import {
22
22
  testKeyPair4,
23
23
  testKeyPair5,
24
24
  testKeyPair6
25
- } from '../fixtures/apply.fixtures.js';
26
- import PartialStateMessageOperations from "../../src/messages/partialStateMessages/PartialStateMessageOperations.js";
27
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
28
- import {ZERO_WK} from '../../src/utils/buffer.js';
29
- import { $TNK } from '../../src/core/state/utils/balance.js';
25
+ } from '../../fixtures/apply.fixtures.js';
26
+ import PartialStateMessageOperations from "../../../src/messages/partialStateMessages/PartialStateMessageOperations.js";
27
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
28
+ import {ZERO_WK} from '../../../src/utils/buffer.js';
29
+ import { $TNK } from '../../../src/core/state/utils/balance.js';
30
30
 
31
31
  const sendAddWriter = async (invoker, broadcaster) => {
32
32
  const validity = await invoker.msb.state.getIndexerSequenceState()
@@ -1,4 +1,4 @@
1
- import {test, hook} from '../utils/wrapper.js';
1
+ import { test, hook } from '../../helpers/wrapper.js';
2
2
 
3
3
  import {
4
4
  initTemporaryDirectory,
@@ -7,11 +7,11 @@ import {
7
7
  setupMsbIndexer,
8
8
  setupMsbAdmin,
9
9
  tryToSyncWriters
10
- } from '../utils/setupApplyTests.js';
11
- import {randomBytes} from '../utils/setupApplyTests.js';
12
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
13
- import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4} from '../fixtures/apply.fixtures.js';
14
- import {sleep} from '../../src/utils/helpers.js';
10
+ } from '../../helpers/setupApplyTests.js';
11
+ import { randomBytes } from '../../helpers/setupApplyTests.js';
12
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
13
+ import { testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4 } from '../../fixtures/apply.fixtures.js';
14
+ import { sleep } from '../../../src/utils/helpers.js';
15
15
  import b4a from 'b4a'
16
16
 
17
17
  let admin;
@@ -99,12 +99,11 @@ test('handleApplyBanValidatorOperation (apply) - Append banValidator payload int
99
99
  });
100
100
 
101
101
  hook('Clean up banValidator setup', async t => {
102
- // close msb instances and remove temp directory
103
- const toClose = []
104
- if (indexer.msb) toClose.push(indexer.msb.close());
105
- if (writer1.msb) toClose.push(writer1.msb.close());
106
- if (writer2.msb) toClose.push(writer2.msb.close());
107
- if (admin.msb) toClose.push(admin.msb.close());
108
- await Promise.all(toClose)
102
+ const toClose = [];
103
+ if (admin?.msb) toClose.push(admin.msb.close());
104
+ if (indexer?.msb) toClose.push(indexer.msb.close());
105
+ if (writer1?.msb) toClose.push(writer1.msb.close());
106
+ if (writer2?.msb) toClose.push(writer2.msb.close());
107
+ await Promise.all(toClose);
109
108
  if (tmpDirectory) await removeTemporaryDirectory(tmpDirectory);
110
- })
109
+ });
@@ -1,5 +1,4 @@
1
- import {hook, test} from '../../utils/wrapper.js';
2
- import b4a from "b4a";
1
+ import {hook, test} from '../../../helpers/wrapper.js';
3
2
  import {
4
3
  generatePostTx,
5
4
  initTemporaryDirectory,
@@ -13,11 +12,11 @@ import {
13
12
  tryToSyncWriters,
14
13
  waitDemotion,
15
14
  promoteToWriter
16
- } from '../../utils/setupApplyTests.js';
17
- import {safeDecodeApplyOperation, safeEncodeApplyOperation} from '../../../src/utils/protobuf/operationHelpers.js'
18
- import {testKeyPair1, testKeyPair2, testKeyPair4, testKeyPair5} from '../../fixtures/apply.fixtures.js';
19
- import { $TNK } from '../../../src/core/state/utils/balance.js';
20
- import { decode as decodeNodeEntry } from '../../../src/core/state/utils/nodeEntry.js';
15
+ } from '../../../helpers/setupApplyTests.js';
16
+ import {safeDecodeApplyOperation, safeEncodeApplyOperation} from '../../../../src/utils/protobuf/operationHelpers.js'
17
+ import {testKeyPair1, testKeyPair2, testKeyPair4, testKeyPair5} from '../../../fixtures/apply.fixtures.js';
18
+ import { $TNK } from '../../../../src/core/state/utils/balance.js';
19
+ import { decode as decodeNodeEntry } from '../../../../src/core/state/utils/nodeEntry.js';
21
20
 
22
21
  let tmpDirectory, admin, writer, externalNode, externalBootstrap, maliciousPeer;
23
22
  // is and vs is already covered
@@ -1,4 +1,4 @@
1
- import {hook, test} from '../../utils/wrapper.js';
1
+ import {hook, test} from '../../../helpers/wrapper.js';
2
2
  import b4a from "b4a";
3
3
  import {
4
4
  generatePostTx,
@@ -15,13 +15,12 @@ import {
15
15
  waitForHash,
16
16
  waitDemotion,
17
17
  promoteToWriter
18
- } from '../../utils/setupApplyTests.js';
19
- import {safeDecodeApplyOperation, safeEncodeApplyOperation} from '../../../src/utils/protobuf/operationHelpers.js'
20
- import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4, testKeyPair5} from '../../fixtures/apply.fixtures.js';
21
- import {OperationType} from "../../../src/utils/constants.js";
22
- import {addressToBuffer} from "../../../src/core/state/utils/address.js";
23
- import { $TNK } from '../../../src/core/state/utils/balance.js';
24
- import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
18
+ } from '../../../helpers/setupApplyTests.js';
19
+ import {safeDecodeApplyOperation, safeEncodeApplyOperation} from '../../../../src/utils/protobuf/operationHelpers.js'
20
+ import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4, testKeyPair5} from '../../../fixtures/apply.fixtures.js';
21
+ import {OperationType} from "../../../../src/utils/constants.js";
22
+ import {addressToBuffer} from "../../../../src/core/state/utils/address.js";
23
+ import { $TNK } from '../../../../src/core/state/utils/balance.js';
25
24
 
26
25
  let tmpDirectory, admin, writer, externalNode, externalBootstrap, maliciousPeer;
27
26
 
@@ -1,6 +1,6 @@
1
- import {test, hook} from '../utils/wrapper.js';
1
+ import {test, hook} from '../../helpers/wrapper.js';
2
2
 
3
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
3
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
4
4
  import {
5
5
  initTemporaryDirectory,
6
6
  removeTemporaryDirectory,
@@ -8,8 +8,8 @@ import {
8
8
  setupMsbWriter,
9
9
  randomBytes,
10
10
  setupMsbIndexer, waitForNodeState, tryToSyncWriters
11
- } from '../utils/setupApplyTests.js';
12
- import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4} from '../fixtures/apply.fixtures.js';
11
+ } from '../../helpers/setupApplyTests.js';
12
+ import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4} from '../../fixtures/apply.fixtures.js';
13
13
  import b4a from 'b4a'
14
14
 
15
15
  let tmpDirectory, admin, indexer1, indexer2, writer;
@@ -1,4 +1,4 @@
1
- import {test, hook} from '../utils/wrapper.js';
1
+ import {test, hook} from '../../helpers/wrapper.js';
2
2
  import b4a from 'b4a';
3
3
  import {
4
4
  setupMsbAdmin,
@@ -10,7 +10,7 @@ import {
10
10
  tryToSyncWriters,
11
11
  waitForNotIndexer,
12
12
  waitForNodeState,
13
- } from '../utils/setupApplyTests.js';
13
+ } from '../../helpers/setupApplyTests.js';
14
14
  import {
15
15
  testKeyPair1,
16
16
  testKeyPair2,
@@ -18,9 +18,9 @@ import {
18
18
  testKeyPair4,
19
19
  testKeyPair5,
20
20
  testKeyPair6
21
- } from '../fixtures/apply.fixtures.js';
22
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
23
- import PartialStateMessageOperations from '../../src/messages/partialStateMessages/PartialStateMessageOperations.js';
21
+ } from '../../fixtures/apply.fixtures.js';
22
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
23
+ import PartialStateMessageOperations from '../../../src/messages/partialStateMessages/PartialStateMessageOperations.js';
24
24
 
25
25
  let admin, writer1, writer2, writer3, writer4, indexer, tmpDirectory;
26
26
 
@@ -1,5 +1,5 @@
1
1
  import b4a from 'b4a';
2
- import { test, hook } from '../utils/wrapper.js';
2
+ import { test, hook } from '../../helpers/wrapper.js';
3
3
  import {
4
4
  setupMsbAdmin,
5
5
  initTemporaryDirectory,
@@ -7,16 +7,16 @@ import {
7
7
  setupMsbWriter,
8
8
  waitForHash,
9
9
  removeTemporaryDirectory
10
- } from '../utils/setupApplyTests.js';
10
+ } from '../../helpers/setupApplyTests.js';
11
11
  import {
12
12
  testKeyPair1,
13
13
  testKeyPair2,
14
14
  testKeyPair3,
15
15
  testKeyPair4
16
- } from '../fixtures/apply.fixtures.js';
17
- import PartialStateMessageOperations from "../../src/messages/partialStateMessages/PartialStateMessageOperations.js";
18
- import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
19
- import { $TNK } from '../../src/core/state/utils/balance.js';
16
+ } from '../../fixtures/apply.fixtures.js';
17
+ import PartialStateMessageOperations from "../../../src/messages/partialStateMessages/PartialStateMessageOperations.js";
18
+ import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
19
+ import { $TNK } from '../../../src/core/state/utils/balance.js';
20
20
 
21
21
  const buildTransfer = async (admin, from, to, amount) => {
22
22
  const txValidity = await from.msb.state.getIndexerSequenceState()
@@ -62,7 +62,7 @@ test('handleApplyTransferOperation (apply) - append two transfers', async t => {
62
62
  await Promise.all(
63
63
  [await waitForHash(writer2, first.hash), await waitForHash(writer2, second.hash)]
64
64
  );
65
-
65
+
66
66
  const firstResult = await writer2.msb.state.get(first.hash)
67
67
  const secondResult = await writer2.msb.state.get(second.hash)
68
68
  t.ok(firstResult, 'First result should not be null');
@@ -0,0 +1,9 @@
1
+ import { default as test } from 'brittle';
2
+
3
+ async function runTests() {
4
+ test.pause();
5
+ await import('./apply/apply.test.js');
6
+ test.resume();
7
+ }
8
+
9
+ await runTests();
@@ -7,7 +7,7 @@ import b4a from 'b4a';
7
7
  import {safeDecodeApplyOperation} from '../../src/utils/protobuf/operationHelpers.js';
8
8
  import {isAddressValid} from "../../src/core/state/utils/address.js";
9
9
  import {errorMessageIncludes} from "../utils/regexHelper.js";
10
- import {generatePostTx, randomBytes} from "../utils/setupApplyTests.js";
10
+ import {generatePostTx, randomBytes} from "../../helpers/setupApplyTests.js";
11
11
 
12
12
  const msgTxoLength = 10;
13
13
  const opType = OperationType.TX;
@@ -1,9 +1,9 @@
1
1
  import sinon from "sinon";
2
2
  import { hook, test } from 'brittle'
3
3
  import { default as EventEmitter } from "bare-events"
4
- import { testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4, testKeyPair5, testKeyPair6, testKeyPair7, testKeyPair8, testKeyPair9 } from "../fixtures/apply.fixtures.js";
5
- import ConnectionManager from "../../src/core/network/services/ConnectionManager.js";
6
- import { tick } from "../utils/setupApplyTests.js";
4
+ import { testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4, testKeyPair5, testKeyPair6, testKeyPair7, testKeyPair8, testKeyPair9 } from "../../fixtures/apply.fixtures.js";
5
+ import ConnectionManager from "../../../src/core/network/services/ConnectionManager.js";
6
+ import { tick } from "../../helpers/setupApplyTests.js";
7
7
  import b4a from 'b4a'
8
8
 
9
9
  const createConnection = (key) => {
@@ -13,7 +13,7 @@ const createConnection = (key) => {
13
13
  }
14
14
  emitter.connected = true
15
15
  emitter.remotePublicKey = b4a.from(key, 'hex')
16
-
16
+
17
17
  return { key: b4a.from(key, 'hex'), connection: emitter }
18
18
  }
19
19
 
@@ -50,7 +50,7 @@ test('ConnectionManager', () => {
50
50
  reset()
51
51
  const connectionManager = makeManager()
52
52
  t.is(connectionManager.connectionCount(), connections.length, 'should have the same length')
53
-
53
+
54
54
  const data = createConnection(testKeyPair5.publicKey)
55
55
  connectionManager.addValidator(data.key, data.connection)
56
56
  t.is(connectionManager.connectionCount(), connections.length + 1, 'should have the same length')
@@ -1,7 +1,7 @@
1
1
  import b4a from 'b4a';
2
2
  import { bech32m } from 'bech32';
3
3
  import { TRAC_NETWORK_MSB_MAINNET_PREFIX } from 'trac-wallet/constants.js';
4
- import { TOKEN_DECIMALS } from '../../src/utils/constants.js';
4
+ import { TOKEN_DECIMALS } from '../../../src/utils/constants.js';
5
5
 
6
6
  export function randomBuffer(size) {
7
7
  return b4a.from(Array.from({ length: size }, () => Math.floor(Math.random() * 256)));
@@ -1,8 +1,8 @@
1
1
  import { test } from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { TRAC_ADDRESS_SIZE } from '../../../src/utils/constants.js';
3
+ import { TRAC_ADDRESS_SIZE } from '../../../../src/utils/constants.js';
4
4
  import { randomAddress } from '../stateTestUtils.js';
5
- import addressUtils from '../../../src/core/state/utils/address.js';
5
+ import addressUtils from '../../../../src/core/state/utils/address.js';
6
6
 
7
7
  test('Convert bech32m address to and from buffer - Happy Path', t => {
8
8
  const hrp = 'test';
@@ -1,9 +1,9 @@
1
1
  import { test } from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { WRITER_BYTE_LENGTH, TRAC_ADDRESS_SIZE } from '../../../src/utils/constants.js';
3
+ import { WRITER_BYTE_LENGTH, TRAC_ADDRESS_SIZE } from '../../../../src/utils/constants.js';
4
4
  import { randomAddress, randomBuffer } from '../stateTestUtils.js';
5
- import addressUtils from '../../../src/core/state/utils/address.js';
6
- import adminEntryUtils from '../../../src/core/state/utils/adminEntry.js';
5
+ import addressUtils from '../../../../src/core/state/utils/address.js';
6
+ import adminEntryUtils from '../../../../src/core/state/utils/adminEntry.js';
7
7
 
8
8
  const isAddressValid = addressUtils.isAddressValid;
9
9
  const addressToBuffer = addressUtils.addressToBuffer;
@@ -1,11 +1,11 @@
1
1
  import { test } from 'brittle';
2
2
  import b4a from 'b4a';
3
3
  import { randomBuffer, TEN_THOUSAND_VALUE, tokenUnits } from '../stateTestUtils.js';
4
- import { ZERO_BALANCE, decode, encode } from '../../../src/core/state/utils/nodeEntry.js';
5
- import { WRITER_BYTE_LENGTH, ADMIN_INITIAL_BALANCE, BALANCE_BYTE_LENGTH } from '../../../src/utils/constants.js';
6
- import { $TNK, toBalance, toTerm, percent } from '../../../src/core/state/utils/balance.js';
7
- import { bufferToBigInt } from '../../../src/utils/amountSerialization.js';
8
- import { ZERO_LICENSE } from '../../../src/core/state/utils/nodeEntry.js';
4
+ import { ZERO_BALANCE, decode, encode } from '../../../../src/core/state/utils/nodeEntry.js';
5
+ import { WRITER_BYTE_LENGTH, ADMIN_INITIAL_BALANCE, BALANCE_BYTE_LENGTH } from '../../../../src/utils/constants.js';
6
+ import { $TNK, toBalance, toTerm, percent } from '../../../../src/core/state/utils/balance.js';
7
+ import { bufferToBigInt } from '../../../../src/utils/amountSerialization.js';
8
+ import { ZERO_LICENSE } from '../../../../src/core/state/utils/nodeEntry.js';
9
9
  test('Balance#asHex explicit', t => {
10
10
  const val = $TNK(1000n)
11
11
  t.is(toBalance(val).asHex(), b4a.toString(val, 'hex'), 'hex matches')
@@ -1,8 +1,8 @@
1
1
  import { test } from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { TRAC_ADDRESS_SIZE } from '../../../src/utils/constants.js';
3
+ import { TRAC_ADDRESS_SIZE } from '../../../../src/utils/constants.js';
4
4
  import { randomBuffer } from '../stateTestUtils.js';
5
- import indexerEntryUtils, { append } from '../../../src/core/state/utils/indexerEntry.js';
5
+ import indexerEntryUtils, { append } from '../../../../src/core/state/utils/indexerEntry.js';
6
6
 
7
7
  const appendIndexer = indexerEntryUtils.append;
8
8
  const removeIndexer = indexerEntryUtils.remove;
@@ -1,6 +1,6 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
- import lengthEntry from '../../../src/core/state/utils/lengthEntry.js';
3
+ import lengthEntry from '../../../../src/core/state/utils/lengthEntry.js';
4
4
 
5
5
  // Test init()
6
6
  test('Length Entry - init returns a 4-byte buffer initialized to 0', t => {
@@ -1,8 +1,8 @@
1
1
  import { test } from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { WRITER_BYTE_LENGTH, LICENSE_BYTE_LENGTH } from '../../../src/utils/constants.js';
3
+ import { WRITER_BYTE_LENGTH, LICENSE_BYTE_LENGTH } from '../../../../src/utils/constants.js';
4
4
  import { randomBuffer, TEN_THOUSAND_VALUE } from '../stateTestUtils.js';
5
- import { NodeRole } from '../../../src/core/state/utils/roles.js';
5
+ import { NodeRole } from '../../../../src/core/state/utils/roles.js';
6
6
  import {
7
7
  ZERO_BALANCE,
8
8
  ZERO_LICENSE,
@@ -14,7 +14,7 @@ import {
14
14
  setBalance as setNodeEntryBalance,
15
15
  setLicense as setNodeEntryLicense,
16
16
  setStakedBalance as setNodeEntryStakedBalance,
17
- } from '../../../src/core/state/utils/nodeEntry.js';
17
+ } from '../../../../src/core/state/utils/nodeEntry.js';
18
18
 
19
19
  // Test init()
20
20
  test('Node Entry - init - Happy Path', t => {
@@ -1,5 +1,5 @@
1
1
  import test from 'brittle';
2
- import roles from '../../../src/core/state/utils/roles.js';
2
+ import roles from '../../../../src/core/state/utils/roles.js';
3
3
 
4
4
  const { NodeRole, WHITELISTED_MASK, WRITER_MASK, INDEXER_MASK, calculateNodeRole, isNodeRoleValid } = roles;
5
5
 
@@ -0,0 +1,14 @@
1
+ // This runner is auto-generated by Brittle
2
+
3
+ import { default as test } from 'brittle';
4
+
5
+ async function runTests() {
6
+ test.pause();
7
+ await import('./network/networkModule.test.js')
8
+ await import('./state/stateModule.test.js');
9
+ await import('./utils/utils.test.js');
10
+ // await import('./messageOperations/stateMessageOperations.test.js'); // Broken test - needs fixing
11
+ test.resume();
12
+ }
13
+
14
+ await runTests();
@@ -1,8 +1,8 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { decimalStringToBigInt, bigIntTo16ByteBuffer, bufferToBigInt, bigIntToDecimalString, licenseBufferToBigInt } from '../../src/utils/amountSerialization.js';
4
- import { errorMessageIncludes } from "../utils/regexHelper.js";
5
- import lengthEntryUtils from '../../src/core/state/utils/lengthEntry.js';
3
+ import { decimalStringToBigInt, bigIntTo16ByteBuffer, bufferToBigInt, bigIntToDecimalString, licenseBufferToBigInt } from '../../../../src/utils/amountSerialization.js';
4
+ import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
5
+ import lengthEntryUtils from '../../../../src/core/state/utils/lengthEntry.js';
6
6
 
7
7
  test('decimalStringToBigInt', async t => {
8
8
  // Zero cases - all valid
@@ -1,6 +1,6 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
- import {createMessage, isBufferValid, safeWriteUInt32BE, deepCopyBuffer} from '../../src/utils/buffer.js';
3
+ import {createMessage, isBufferValid, safeWriteUInt32BE, deepCopyBuffer} from '../../../../src/utils/buffer.js';
4
4
 
5
5
  const invalidDataTypes = [
6
6
  null,
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js'
4
- import {ACO, not_allowed_data_types} from '../fixtures/check.fixtures.js'
3
+ import Check from '../../../../src/utils/check.js'
4
+ import {ACO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js'
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
6
6
 
7
7
  const check = new Check()
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js'
4
- import { BIO, not_allowed_data_types } from '../fixtures/check.fixtures.js'
3
+ import Check from '../../../../src/utils/check.js'
4
+ import { BIO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js'
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
6
6
 
7
7
  const check = new Check()
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js';
4
- import {BDO, not_allowed_data_types} from '../fixtures/check.fixtures.js';
3
+ import Check from '../../../../src/utils/check.js';
4
+ import {BDO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js';
5
5
 
6
6
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import b4a from 'b4a';
2
2
 
3
- import { MIN_SAFE_VALIDATION_INTEGER, MAX_SAFE_VALIDATION_INTEGER, TRAC_ADDRESS_SIZE } from '../../src/utils/constants.js';
4
- import { partial_operation_value_type } from "../fixtures/check.fixtures.js";
3
+ import { MIN_SAFE_VALIDATION_INTEGER, MAX_SAFE_VALIDATION_INTEGER, TRAC_ADDRESS_SIZE } from '../../../../src/utils/constants.js';
4
+ import { partial_operation_value_type } from "../../../fixtures/check.fixtures.js";
5
5
 
6
6
  export function topLevelValidationTests(
7
7
  t,
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js'
4
- import {CAO, not_allowed_data_types} from '../fixtures/check.fixtures.js'
3
+ import Check from '../../../../src/utils/check.js'
4
+ import {CAO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js'
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
6
6
 
7
7
  const check = new Check()
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js';
4
- import {RAO, not_allowed_data_types} from '../fixtures/check.fixtures.js';
3
+ import Check from '../../../../src/utils/check.js';
4
+ import {RAO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js';
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
6
6
 
7
7
  const check = new Check();
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js';
4
- import {TXO, not_allowed_data_types} from '../fixtures/check.fixtures.js';
3
+ import Check from '../../../../src/utils/check.js';
4
+ import {TXO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js';
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
6
6
 
7
7
  const check = new Check();
@@ -1,7 +1,7 @@
1
1
  import test from 'brittle'
2
2
 
3
- import Check from '../../src/utils/check.js';
4
- import {TRO, not_allowed_data_types, TXO} from '../fixtures/check.fixtures.js';
3
+ import Check from '../../../../src/utils/check.js';
4
+ import {TRO, not_allowed_data_types, TXO} from '../../../fixtures/check.fixtures.js';
5
5
  import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
6
6
 
7
7
  const check = new Check();
@@ -1,6 +1,6 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { blake3Hash} from '../../src/utils/crypto.js';
3
+ import { blake3Hash} from '../../../../src/utils/crypto.js';
4
4
 
5
5
  test('blake3', async (t) => {
6
6
  t.test('blake3Hash', async (k) => {
@@ -1,6 +1,6 @@
1
1
  import { test, hook } from 'brittle';
2
- import fileUtils from '../../src/utils/fileUtils.js';
3
- import { errorMessageIncludes } from "../utils/regexHelper.js";
2
+ import fileUtils from '../../../../src/utils/fileUtils.js';
3
+ import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
4
4
  import fs from 'fs';
5
5
  import PeerWallet from 'trac-wallet';
6
6
 
@@ -1,7 +1,6 @@
1
-
2
1
  import { test, hook } from 'brittle';
3
- import fileUtils from '../../src/utils/fileUtils.js';
4
- import { errorMessageIncludes } from "../utils/regexHelper.js";
2
+ import fileUtils from '../../../../src/utils/fileUtils.js';
3
+ import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
5
4
  import fs from 'fs';
6
5
  import PeerWallet from 'trac-wallet';
7
6
 
@@ -3,11 +3,8 @@ import { default as test } from 'brittle';
3
3
  async function runMsgUtilsTests() {
4
4
  test.pause();
5
5
 
6
- await import('./applyOperations.test.js');
7
- await import('./createHash.test.js');
8
6
  await import('./isHexString.test.js');
9
7
  await import('./normalizeHex.test.js');
10
- await import('./amountSerialization.test.js');
11
8
  test.resume();
12
9
  }
13
10
 
@@ -1,5 +1,5 @@
1
1
  import test from 'brittle';
2
- import { isHexString } from '../../src/utils/helpers.js';
2
+ import { isHexString } from '../../../../src/utils/helpers.js';
3
3
 
4
4
  test('isHexString', (t) => {
5
5
  t.ok(isHexString('1234567890abcdef'), 'Valid hex string should return true with all lowercase characters');
@@ -1,6 +1,6 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
- import { normalizeHex } from '../../src/utils/helpers.js';
3
+ import { normalizeHex } from '../../../../src/utils/helpers.js';
4
4
 
5
5
  test('normalizeHex should convert hex string to buffer', t => {
6
6
  const hexString = '1234abcd';
@@ -1,7 +1,7 @@
1
1
  import { test, hook } from 'brittle';
2
- import migrationUtils from '../../src/utils/migrationUtils.js';
3
- import { errorMessageIncludes } from "../utils/regexHelper.js";
4
- import { ZERO_LICENSE } from '../../src/core/state/utils/nodeEntry.js';
2
+ import migrationUtils from '../../../../src/utils/migrationUtils.js';
3
+ import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
4
+ import { ZERO_LICENSE } from '../../../../src/core/state/utils/nodeEntry.js';
5
5
  import b4a from 'b4a';
6
6
  const VALID_ADDRESS = 'trac1dguwzsvcsehslh6dgj2mqlsxdn7s5t5vhem56yd0xlg47aq6exzqymhr6u';
7
7
  const ADMIN_ADDRESS = 'trac1yva2pduhz5yst8jgzmrc9ve0as5mx7tcw6le9srj6xcwqkx9hacqxxhsf9';
@@ -1,8 +1,8 @@
1
1
  import test from 'brittle';
2
- import { safeDecodeApplyOperation, safeEncodeApplyOperation } from '../../src/utils/protobuf/operationHelpers.js';
2
+ import { safeDecodeApplyOperation, safeEncodeApplyOperation } from '../../../src/utils/protobuf/operationHelpers.js';
3
3
  import b4a from 'b4a';
4
- import fixtures from '../fixtures/protobuf.fixtures.js';
5
-
4
+ import fixtures from '../../fixtures/protobuf.fixtures.js';
5
+ //TODO add missing operations tests and fill fixtures with them
6
6
  test('Happy path encode/decode roundtrip for protobuf applyOperation payloads', t => {
7
7
  const payloadsHashMap = new Map([
8
8
  ["tx", fixtures.validTransactionOperation],
@@ -1,9 +1,10 @@
1
1
  import test from 'brittle';
2
2
  import b4a from 'b4a';
3
3
 
4
- import applyOperations from '../../src/utils/protobuf/applyOperations.cjs';
5
- import fixtures from '../fixtures/protobuf.fixtures.js';
4
+ import applyOperations from '../../../../src/utils/protobuf/applyOperations.cjs';
5
+ import fixtures from '../../../fixtures/protobuf.fixtures.js';
6
6
 
7
+ //TODO add missing operations tests and fill fixtures with them
7
8
  test('Happy path encode/decode roundtrip for protobuf applyOperation payloads', t => {
8
9
  const payloadsHashMap = new Map([
9
10
  ["txComplete", fixtures.validTransactionOperation],
@@ -0,0 +1,12 @@
1
+ // This runner is auto-generated by Brittle
2
+
3
+ import { default as test } from 'brittle';
4
+
5
+ async function runTests() {
6
+ test.pause();
7
+ await import('./applyOperations.test.js');
8
+ await import('./operationHelpers.test.js');
9
+ test.resume();
10
+ }
11
+
12
+ await runTests();
@@ -0,0 +1,20 @@
1
+ // This runner is auto-generated by Brittle
2
+
3
+ import { default as test } from 'brittle';
4
+
5
+ async function runTests() {
6
+ test.pause();
7
+
8
+ await import('./check/check.test.js');
9
+ await import('./protobuf/operationHelpers.test.js');
10
+ await import('./helpers/helpers.test.js');
11
+ await import('./fileUtils/readAddressesFromWhitelistFile.test.js');
12
+ await import('./fileUtils/readBalanceMigrationFile.test.js');
13
+ await import('./migrationUtils/validateAddressFromIncomingFile.test.js');
14
+ await import('./buffer/buffer.test.js')
15
+ await import('./amountSerialization/amountSerialization.test.js');
16
+ await import('./crypto/createHash.test.js');
17
+ test.resume();
18
+ }
19
+
20
+ await runTests();
package/test/all.test.js DELETED
@@ -1,23 +0,0 @@
1
- // This runner is auto-generated by Brittle
2
-
3
- import { default as test } from 'brittle';
4
-
5
- async function runTests() {
6
- test.pause();
7
-
8
- await import('./state/stateTests.test.js');
9
- // await import('./state/apply.addAdmin.basic.test.js');
10
- // await import('./check/check.test.js');
11
- // await import('./protobuf/protobuf.test.js');
12
- // await import('./functions/functions.test.js');
13
- // await import('./fileUtils/readAddressesFromWhitelistFile.test.js');
14
- // await import('./fileUtils/readBalanceMigrationFile.test.js');
15
- // await import('./migrationUtils/validateAddressFromIncomingFile.test.js');
16
- // await import('./messageOperations/stateMessageOperations.test.js');
17
- // await import('./buffer/buffer.test.js')
18
- // await import('./network/connectionManagerTests.test.js')
19
- // await import('./apply/apply.test.js'); // This test has been disabled because Github CI fails due to lack of resources. This test can still be run locally but sometimes it hangs when destroying resources.
20
- test.resume();
21
- }
22
-
23
- await runTests();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes