trac-msb 0.2.7 → 0.2.9
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.
- package/.github/workflows/publish.yml +8 -16
- package/msb.mjs +13 -25
- package/package.json +8 -4
- package/proto/network.proto +74 -0
- package/rpc/{create_server.mjs → create_server.js} +4 -4
- package/rpc/{handlers.mjs → handlers.js} +7 -7
- package/rpc/routes/{index.mjs → index.js} +1 -1
- package/rpc/routes/{v1.mjs → v1.js} +1 -1
- package/rpc/rpc_server.js +10 -0
- package/rpc/rpc_services.js +48 -7
- package/rpc/utils/{helpers.mjs → helpers.js} +1 -1
- package/src/config/config.js +137 -0
- package/src/config/env.js +63 -0
- package/src/core/network/Network.js +133 -119
- package/src/core/network/identity/NetworkWalletFactory.js +5 -6
- package/src/core/network/protocols/LegacyProtocol.js +67 -0
- package/src/core/network/protocols/NetworkMessages.js +48 -0
- package/src/core/network/protocols/ProtocolInterface.js +31 -0
- package/src/core/network/protocols/ProtocolSession.js +59 -0
- package/src/core/network/protocols/V1Protocol.js +64 -0
- package/src/core/network/protocols/legacy/NetworkMessageRouter.js +84 -0
- package/src/core/network/protocols/legacy/handlers/GetRequestHandler.js +53 -0
- package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +37 -0
- package/src/core/network/{messaging → protocols/legacy}/validators/ValidatorResponse.js +2 -2
- package/src/core/network/{messaging → protocols/legacy}/validators/base/BaseResponse.js +13 -6
- package/src/core/network/protocols/shared/handlers/RoleOperationHandler.js +88 -0
- package/src/core/network/protocols/shared/handlers/SubnetworkOperationHandler.js +93 -0
- package/src/core/network/protocols/shared/handlers/TransferOperationHandler.js +57 -0
- package/src/core/network/{messaging → protocols/shared}/handlers/base/BaseOperationHandler.js +21 -26
- package/src/core/network/{messaging → protocols/shared}/validators/PartialBootstrapDeployment.js +3 -3
- package/src/core/network/{messaging → protocols/shared}/validators/PartialRoleAccess.js +15 -12
- package/src/core/network/{messaging → protocols/shared}/validators/PartialTransaction.js +10 -11
- package/src/core/network/{messaging → protocols/shared}/validators/PartialTransfer.js +10 -7
- package/src/core/network/{messaging → protocols/shared}/validators/base/PartialOperation.js +40 -22
- package/src/core/network/protocols/v1/NetworkMessageRouter.js +15 -0
- package/src/core/network/services/ConnectionManager.js +13 -19
- package/src/core/network/services/MessageOrchestrator.js +10 -22
- package/src/core/network/services/TransactionPoolService.js +10 -10
- package/src/core/network/services/TransactionRateLimiterService.js +5 -3
- package/src/core/network/services/ValidatorObserverService.js +46 -21
- package/src/core/state/State.js +137 -141
- package/src/core/state/utils/address.js +18 -16
- package/src/core/state/utils/adminEntry.js +17 -16
- package/src/core/state/utils/deploymentEntry.js +15 -15
- package/src/core/state/utils/transaction.js +3 -95
- package/src/index.js +250 -325
- package/src/messages/network/v1/NetworkMessageBuilder.js +325 -0
- package/src/messages/network/v1/NetworkMessageDirector.js +137 -0
- package/src/messages/network/v1/networkMessageFactory.js +12 -0
- package/src/messages/state/ApplyStateMessageBuilder.js +661 -0
- package/src/messages/state/ApplyStateMessageDirector.js +516 -0
- package/src/messages/state/applyStateMessageFactory.js +12 -0
- package/src/utils/buffer.js +53 -1
- package/src/utils/check.js +21 -17
- package/src/utils/cli.js +0 -8
- package/src/utils/cliCommands.js +11 -11
- package/src/utils/constants.js +36 -24
- package/src/utils/fileUtils.js +1 -4
- package/src/utils/helpers.js +9 -20
- package/src/utils/migrationUtils.js +2 -2
- package/src/utils/normalizers.js +94 -11
- package/src/utils/protobuf/network.cjs +840 -0
- package/src/utils/protobuf/operationHelpers.js +10 -0
- package/tests/acceptance/v1/account/account.test.mjs +2 -2
- package/tests/acceptance/v1/balance/balance.test.mjs +1 -1
- package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +11 -2
- package/tests/acceptance/v1/rpc.test.mjs +10 -10
- package/tests/acceptance/v1/tx/tx.test.mjs +4 -2
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +7 -3
- package/tests/fixtures/check.fixtures.js +42 -42
- package/tests/fixtures/networkV1.fixtures.js +84 -0
- package/tests/fixtures/protobuf.fixtures.js +110 -26
- package/tests/helpers/StateNetworkFactory.js +3 -5
- package/tests/helpers/autobaseTestHelpers.js +1 -2
- package/tests/helpers/config.js +3 -0
- package/tests/helpers/setupApplyTests.js +113 -99
- package/tests/helpers/transactionPayloads.mjs +26 -12
- package/tests/unit/messages/messages.test.js +12 -0
- package/tests/unit/messages/network/NetworkMessageBuilder.test.js +276 -0
- package/tests/unit/messages/network/NetworkMessageDirector.test.js +203 -0
- package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +521 -0
- package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +233 -0
- package/tests/unit/network/ConnectionManager.test.js +10 -7
- package/tests/unit/network/NetworkWalletFactory.test.js +14 -14
- package/tests/unit/network/networkModule.test.js +3 -2
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +10 -6
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +11 -8
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +11 -7
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +18 -20
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +57 -48
- package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +2 -1
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +72 -57
- package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +3 -7
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +12 -14
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +18 -13
- package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js +2 -1
- package/tests/unit/state/apply/banValidator/banValidatorBanAndReWhitelistScenario.js +2 -1
- package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +27 -30
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +2 -1
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +24 -21
- package/tests/unit/state/apply/common/access-control/adminConsistencyMismatchScenario.js +5 -4
- package/tests/unit/state/apply/common/access-control/adminPublicKeyDecodeFailureScenario.js +4 -3
- package/tests/unit/state/apply/common/balances/base/requesterBalanceScenarioBase.js +2 -1
- package/tests/unit/state/apply/common/commonScenarioHelper.js +16 -16
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +10 -5
- package/tests/unit/state/apply/common/payload-structure/invalidHashValidationScenario.js +2 -2
- package/tests/unit/state/apply/common/requester/requesterNodeEntryBufferMissingScenario.js +2 -1
- package/tests/unit/state/apply/common/requester/requesterNodeEntryDecodeFailureScenario.js +2 -1
- package/tests/unit/state/apply/common/validatorConsistency/base/validatorConsistencyScenarioBase.js +2 -1
- package/tests/unit/state/apply/common/validatorEntryValidation/base/validatorEntryValidationScenarioBase.js +2 -1
- package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +16 -9
- package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +6 -5
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +23 -19
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +45 -36
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +48 -45
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +32 -29
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardScenarioFactory.js +2 -1
- package/tests/unit/state/stateModule.test.js +0 -1
- package/tests/unit/state/stateTestUtils.js +7 -3
- package/tests/unit/state/utils/address.test.js +3 -3
- package/tests/unit/state/utils/adminEntry.test.js +10 -9
- package/tests/unit/unit.test.js +1 -1
- package/tests/unit/utils/buffer/buffer.test.js +62 -1
- package/tests/unit/utils/check/adminControlOperation.test.js +3 -3
- package/tests/unit/utils/check/balanceInitializationOperation.test.js +2 -2
- package/tests/unit/utils/check/bootstrapDeploymentOperation.test.js +2 -3
- package/tests/unit/utils/check/common.test.js +7 -6
- package/tests/unit/utils/check/coreAdminOperation.test.js +3 -3
- package/tests/unit/utils/check/roleAccessOperation.test.js +3 -2
- package/tests/unit/utils/check/transactionOperation.test.js +3 -3
- package/tests/unit/utils/check/transferOperation.test.js +3 -3
- package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +2 -1
- package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +2 -1
- package/tests/unit/utils/migrationUtils/validateAddressFromIncomingFile.test.js +7 -0
- package/tests/unit/utils/normalizers/normalizers.test.js +469 -0
- package/tests/unit/utils/protobuf/operationHelpers.test.js +120 -2
- package/tests/unit/utils/utils.test.js +0 -1
- package/rpc/rpc_server.mjs +0 -10
- package/src/core/network/messaging/NetworkMessages.js +0 -63
- package/src/core/network/messaging/handlers/GetRequestHandler.js +0 -112
- package/src/core/network/messaging/handlers/ResponseHandler.js +0 -108
- package/src/core/network/messaging/handlers/RoleOperationHandler.js +0 -116
- package/src/core/network/messaging/handlers/SubnetworkOperationHandler.js +0 -143
- package/src/core/network/messaging/handlers/TransferOperationHandler.js +0 -52
- package/src/core/network/messaging/routes/NetworkMessageRouter.js +0 -94
- package/src/core/network/messaging/validators/AdminResponse.js +0 -58
- package/src/core/network/messaging/validators/CustomNodeResponse.js +0 -46
- package/src/core/state/utils/indexerEntry.js +0 -105
- package/src/messages/base/StateBuilder.js +0 -25
- package/src/messages/completeStateMessages/CompleteStateMessageBuilder.js +0 -421
- package/src/messages/completeStateMessages/CompleteStateMessageDirector.js +0 -252
- package/src/messages/completeStateMessages/CompleteStateMessageOperations.js +0 -299
- package/src/messages/partialStateMessages/PartialStateMessageBuilder.js +0 -272
- package/src/messages/partialStateMessages/PartialStateMessageDirector.js +0 -137
- package/src/messages/partialStateMessages/PartialStateMessageOperations.js +0 -131
- package/src/utils/crypto.js +0 -11
- package/tests/integration/apply/addAdmin/addAdminBasic.test.js +0 -68
- package/tests/integration/apply/addAdmin/addAdminRecovery.test.js +0 -125
- package/tests/integration/apply/addIndexer.test.js +0 -237
- package/tests/integration/apply/addWhitelist.test.js +0 -53
- package/tests/integration/apply/addWriter.test.js +0 -244
- package/tests/integration/apply/apply.test.js +0 -19
- package/tests/integration/apply/banValidator.test.js +0 -109
- package/tests/integration/apply/postTx/invalidSubValues.test.js +0 -103
- package/tests/integration/apply/postTx/postTx.test.js +0 -222
- package/tests/integration/apply/removeIndexer.test.js +0 -128
- package/tests/integration/apply/removeWriter.test.js +0 -167
- package/tests/integration/apply/transfer.test.js +0 -81
- package/tests/integration/integration.test.js +0 -9
- package/tests/unit/messageOperations/assembleAddIndexerMessage.test.js +0 -21
- package/tests/unit/messageOperations/assembleAddWriterMessage.test.js +0 -16
- package/tests/unit/messageOperations/assembleAdminMessage.test.js +0 -69
- package/tests/unit/messageOperations/assembleBanWriterMessage.test.js +0 -16
- package/tests/unit/messageOperations/assemblePostTransaction.test.js +0 -442
- package/tests/unit/messageOperations/assembleRemoveIndexerMessage.test.js +0 -19
- package/tests/unit/messageOperations/assembleRemoveWriterMessage.test.js +0 -17
- package/tests/unit/messageOperations/assembleWhitelistMessages.test.js +0 -58
- package/tests/unit/messageOperations/commonsStateMessageOperationsTest.js +0 -277
- package/tests/unit/messageOperations/stateMessageOperations.test.js +0 -19
- package/tests/unit/state/utils/indexerEntry.test.js +0 -83
- package/tests/unit/state/utils/transaction.test.js +0 -97
- package/tests/unit/utils/crypto/createHash.test.js +0 -15
- /package/rpc/{constants.mjs → constants.js} +0 -0
- /package/rpc/{cors.mjs → cors.js} +0 -0
- /package/rpc/utils/{confirmedParameter.mjs → confirmedParameter.js} +0 -0
- /package/rpc/utils/{url.mjs → url.js} +0 -0
- /package/src/utils/{operations.js → applyOperations.js} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
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, encodeCapabilities, timestampToBuffer, idToBuffer } from '../../../../src/utils/buffer.js';
|
|
4
|
+
import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
|
|
4
5
|
|
|
5
6
|
const invalidDataTypes = [
|
|
6
7
|
null,
|
|
@@ -188,3 +189,63 @@ test('deepCopyBuffer - modifying copy does not affect original (is not a referen
|
|
|
188
189
|
t.is(buf[0], 9, 'original unchanged');
|
|
189
190
|
t.is(copy[0], 1, 'copy modified independently');
|
|
190
191
|
});
|
|
192
|
+
|
|
193
|
+
test('encodeCapabilities - deterministic ordering and encoding', t => {
|
|
194
|
+
const caps = ['cap-b', 'cap-a'];
|
|
195
|
+
const result = encodeCapabilities(caps);
|
|
196
|
+
|
|
197
|
+
const capA = b4a.from('cap-a', 'utf8');
|
|
198
|
+
const capB = b4a.from('cap-b', 'utf8');
|
|
199
|
+
|
|
200
|
+
const expected = b4a.concat([
|
|
201
|
+
b4a.from([0x00, capA.length]),
|
|
202
|
+
capA,
|
|
203
|
+
b4a.from([0x00, capB.length]),
|
|
204
|
+
capB
|
|
205
|
+
]);
|
|
206
|
+
|
|
207
|
+
t.is(result.length, expected.length, 'length matches');
|
|
208
|
+
t.ok(b4a.equals(result, expected), 'ordering is sorted and encoding matches');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('encodeCapabilities - empty array yields empty buffer', t => {
|
|
212
|
+
const result = encodeCapabilities([]);
|
|
213
|
+
t.ok(b4a.isBuffer(result), 'returns a buffer');
|
|
214
|
+
t.is(result.length, 0, 'empty buffer for no caps');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('encodeCapabilities - throws on invalid input', t => {
|
|
218
|
+
t.exception(
|
|
219
|
+
() => encodeCapabilities('not-array'),
|
|
220
|
+
errorMessageIncludes('Capabilities must be an array')
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
t.exception(
|
|
224
|
+
() => encodeCapabilities([1, 2]),
|
|
225
|
+
errorMessageIncludes('must contain only strings')
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('timestampToBuffer - encodes uint64 BE', t => {
|
|
230
|
+
const ts = 2n ** 53n; // beyond uint32
|
|
231
|
+
|
|
232
|
+
const tsBuf = timestampToBuffer(ts);
|
|
233
|
+
|
|
234
|
+
t.is(tsBuf.length, 8);
|
|
235
|
+
t.is(tsBuf.readBigUInt64BE(0), ts);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('idToBuffer - encodes utf8 string', t => {
|
|
239
|
+
const id = 'test-id';
|
|
240
|
+
const idBuf = idToBuffer(id);
|
|
241
|
+
t.ok(b4a.isBuffer(idBuf));
|
|
242
|
+
t.ok(b4a.equals(idBuf, b4a.from(id, 'utf8')));
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('timestampToBuffer and idToBuffer - reject invalid input', t => {
|
|
246
|
+
t.exception(() => timestampToBuffer(-1), errorMessageIncludes('timestamp'));
|
|
247
|
+
t.exception(() => timestampToBuffer(1.5), errorMessageIncludes('timestamp'));
|
|
248
|
+
t.exception(() => timestampToBuffer('1'), errorMessageIncludes('timestamp'));
|
|
249
|
+
t.exception.all(() => idToBuffer(1));
|
|
250
|
+
t.exception.all(() => idToBuffer(null));
|
|
251
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js'
|
|
4
|
-
import {ACO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js'
|
|
3
|
+
import { ACO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js'
|
|
5
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
6
6
|
|
|
7
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
8
8
|
|
|
9
9
|
test('validateAdminControlOperation- happy paths for all operation types', t => {
|
|
10
10
|
const validInputs = [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js'
|
|
4
3
|
import { BIO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js'
|
|
5
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
6
6
|
|
|
7
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
8
8
|
|
|
9
9
|
test('validateBalanceInitialization - happy path', t => {
|
|
10
10
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js';
|
|
4
3
|
import {BDO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js';
|
|
5
|
-
|
|
6
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
7
6
|
|
|
8
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
9
8
|
|
|
10
9
|
test('validateBootstrapDeployment - happy-path case', t => {
|
|
11
10
|
const partial_result = check.validateBootstrapDeploymentOperation(BDO.valid_partial_bootstrap_deployment)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
|
|
3
|
-
import { MIN_SAFE_VALIDATION_INTEGER, MAX_SAFE_VALIDATION_INTEGER
|
|
3
|
+
import { MIN_SAFE_VALIDATION_INTEGER, MAX_SAFE_VALIDATION_INTEGER } from '../../../../src/utils/constants.js';
|
|
4
4
|
import { partial_operation_value_type } from "../../../fixtures/check.fixtures.js";
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
5
6
|
|
|
6
7
|
export function topLevelValidationTests(
|
|
7
8
|
t,
|
|
@@ -210,11 +211,11 @@ export function addressBufferLengthTest(
|
|
|
210
211
|
validFixture,
|
|
211
212
|
) {
|
|
212
213
|
const emptyBuffer = b4a.alloc(0);
|
|
213
|
-
const oneTooShort = b4a.alloc(
|
|
214
|
-
const tooShort = b4a.alloc(
|
|
215
|
-
const exact = b4a.alloc(
|
|
216
|
-
const oneTooLong = b4a.alloc(
|
|
217
|
-
const tooLong = b4a.alloc(
|
|
214
|
+
const oneTooShort = b4a.alloc(config.addressLength - 1, 0x01);
|
|
215
|
+
const tooShort = b4a.alloc(config.addressLength - 2, 0x01);
|
|
216
|
+
const exact = b4a.alloc(config.addressLength, 0x01);
|
|
217
|
+
const oneTooLong = b4a.alloc(config.addressLength + 1, 0x01);
|
|
218
|
+
const tooLong = b4a.alloc(config.addressLength + 2, 0x01);
|
|
218
219
|
|
|
219
220
|
const inputs = {
|
|
220
221
|
emptyBufferInput: { ...validFixture, address: emptyBuffer },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js'
|
|
4
|
-
import {CAO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js'
|
|
3
|
+
import { CAO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js'
|
|
5
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
6
6
|
|
|
7
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
8
8
|
|
|
9
9
|
test('validateCoreAdminOperation- happy paths for all operation types', t => {
|
|
10
10
|
const validInputs = [
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
2
|
|
|
3
3
|
import Check from '../../../../src/utils/check.js';
|
|
4
|
-
import {RAO, not_allowed_data_types} from '../../../fixtures/check.fixtures.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
|
+
import { config } from '../../../helpers/config.js';
|
|
6
7
|
|
|
7
|
-
const check = new Check()
|
|
8
|
+
const check = new Check(config)
|
|
8
9
|
|
|
9
10
|
test('validateRoleAccessOperation - happy-path case', t => {
|
|
10
11
|
// ADD_WRITER
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js';
|
|
4
|
-
import {TXO, not_allowed_data_types} from '../../../fixtures/check.fixtures.js';
|
|
3
|
+
import { TXO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js';
|
|
5
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
6
6
|
|
|
7
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
8
8
|
|
|
9
9
|
test('validateTransactionOperation - happy-path case', t => {
|
|
10
10
|
// ADD_WRITER
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import test from 'brittle'
|
|
2
|
-
|
|
3
2
|
import Check from '../../../../src/utils/check.js';
|
|
4
|
-
import {TRO, not_allowed_data_types
|
|
3
|
+
import { TRO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js';
|
|
5
4
|
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
5
|
+
import { config } from '../../../helpers/config.js';
|
|
6
6
|
|
|
7
|
-
const check = new Check()
|
|
7
|
+
const check = new Check(config)
|
|
8
8
|
|
|
9
9
|
test('validateTransferOperation - happy-path case', t => {
|
|
10
10
|
// ADD_WRITER
|
|
@@ -3,6 +3,7 @@ import fileUtils from '../../../../src/utils/fileUtils.js';
|
|
|
3
3
|
import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import PeerWallet from 'trac-wallet';
|
|
6
|
+
import { config } from '../../../helpers/config.js';
|
|
6
7
|
|
|
7
8
|
const DUMMY_PATH_OK = './dummy_whitelist_ok.csv';
|
|
8
9
|
const DUMMY_PATH_DUP = './dummy_whitelist_dup.csv';
|
|
@@ -34,7 +35,7 @@ hook('Initialize dummy whitelist files', async t => {
|
|
|
34
35
|
return wallet.address;
|
|
35
36
|
};
|
|
36
37
|
for (let i = 0; i < 1000; i++) {
|
|
37
|
-
const rand = await randomAddress();
|
|
38
|
+
const rand = await randomAddress(config.addressPrefix);
|
|
38
39
|
large += `${rand}\n`;
|
|
39
40
|
}
|
|
40
41
|
fs.writeFileSync(DUMMY_PATH_LARGE, large);
|
|
@@ -3,6 +3,7 @@ import fileUtils from '../../../../src/utils/fileUtils.js';
|
|
|
3
3
|
import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import PeerWallet from 'trac-wallet';
|
|
6
|
+
import { config } from '../../../helpers/config.js';
|
|
6
7
|
|
|
7
8
|
const DUMMY_PATH_OK = './dummy_balance_ok.csv';
|
|
8
9
|
const DUMMY_PATH_DUP = './dummy_balance_dup.csv';
|
|
@@ -51,7 +52,7 @@ hook('Initialize dummy balance files', async t => {
|
|
|
51
52
|
return wallet.address;
|
|
52
53
|
}
|
|
53
54
|
for (let i = 0; i < 1000; i++) {
|
|
54
|
-
const rand = await randomAddress();
|
|
55
|
+
const rand = await randomAddress(config.addressPrefix);
|
|
55
56
|
large += `${rand},1.0\n`;
|
|
56
57
|
}
|
|
57
58
|
fs.writeFileSync(DUMMY_PATH_LARGE, large);
|
|
@@ -3,6 +3,8 @@ import migrationUtils from '../../../../src/utils/migrationUtils.js';
|
|
|
3
3
|
import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
|
|
4
4
|
import { ZERO_LICENSE } from '../../../../src/core/state/utils/nodeEntry.js';
|
|
5
5
|
import b4a from 'b4a';
|
|
6
|
+
import { config } from '../../../helpers/config.js';
|
|
7
|
+
|
|
6
8
|
const VALID_ADDRESS = 'trac1dguwzsvcsehslh6dgj2mqlsxdn7s5t5vhem56yd0xlg47aq6exzqymhr6u';
|
|
7
9
|
const ADMIN_ADDRESS = 'trac1yva2pduhz5yst8jgzmrc9ve0as5mx7tcw6le9srj6xcwqkx9hacqxxhsf9';
|
|
8
10
|
const INVALID_ADDRESS = 'notanaddress';
|
|
@@ -41,6 +43,7 @@ const mockStateInstanceBanned = {
|
|
|
41
43
|
test('validateAddressFromIncomingFile - valid address', async (t) => {
|
|
42
44
|
await migrationUtils.validateAddressFromIncomingFile(
|
|
43
45
|
mockStateInstance,
|
|
46
|
+
config,
|
|
44
47
|
VALID_ADDRESS,
|
|
45
48
|
{ address: ADMIN_ADDRESS }
|
|
46
49
|
);
|
|
@@ -51,6 +54,7 @@ test('validateAddressFromIncomingFile - invalid address format', async (t) => {
|
|
|
51
54
|
await t.exception(
|
|
52
55
|
() => migrationUtils.validateAddressFromIncomingFile(
|
|
53
56
|
mockStateInstance,
|
|
57
|
+
config,
|
|
54
58
|
INVALID_ADDRESS,
|
|
55
59
|
{ address: ADMIN_ADDRESS }
|
|
56
60
|
),
|
|
@@ -62,6 +66,7 @@ test('validateAddressFromIncomingFile - admin address', async (t) => {
|
|
|
62
66
|
await t.exception(
|
|
63
67
|
() => migrationUtils.validateAddressFromIncomingFile(
|
|
64
68
|
mockStateInstance,
|
|
69
|
+
config,
|
|
65
70
|
ADMIN_ADDRESS,
|
|
66
71
|
{ address: ADMIN_ADDRESS }
|
|
67
72
|
),
|
|
@@ -73,6 +78,7 @@ test('validateAddressFromIncomingFile - whitelisted node', async (t) => {
|
|
|
73
78
|
await t.exception(
|
|
74
79
|
() => migrationUtils.validateAddressFromIncomingFile(
|
|
75
80
|
mockStateInstanceWhitelisted,
|
|
81
|
+
config,
|
|
76
82
|
VALID_ADDRESS,
|
|
77
83
|
{ address: ADMIN_ADDRESS }
|
|
78
84
|
),
|
|
@@ -84,6 +90,7 @@ test('validateAddressFromIncomingFile - banned/previously whitelisted address',
|
|
|
84
90
|
await t.exception(
|
|
85
91
|
() => migrationUtils.validateAddressFromIncomingFile(
|
|
86
92
|
mockStateInstanceBanned,
|
|
93
|
+
config,
|
|
87
94
|
VALID_ADDRESS,
|
|
88
95
|
{ address: ADMIN_ADDRESS }
|
|
89
96
|
),
|