trac-msb 0.2.6 → 0.2.8
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 +9 -16
- package/docs/networking-dualstack-plan.md +75 -0
- package/docs/networking-layer-redesign.md +155 -0
- package/msb.mjs +11 -23
- package/package.json +2 -3
- package/rpc/{create_server.mjs → create_server.js} +2 -2
- package/rpc/{handlers.mjs → handlers.js} +5 -5
- package/rpc/routes/{index.mjs → index.js} +1 -1
- package/rpc/routes/{v1.mjs → v1.js} +1 -1
- package/rpc/{rpc_server.mjs → rpc_server.js} +1 -1
- package/rpc/rpc_services.js +4 -4
- package/src/config/config.js +137 -0
- package/src/config/env.js +61 -0
- package/src/core/network/Network.js +131 -72
- package/src/core/network/identity/NetworkWalletFactory.js +3 -4
- package/src/core/network/messaging/NetworkMessages.js +12 -11
- package/src/core/network/messaging/handlers/GetRequestHandler.js +5 -4
- package/src/core/network/messaging/handlers/ResponseHandler.js +4 -5
- package/src/core/network/messaging/handlers/RoleOperationHandler.js +17 -19
- package/src/core/network/messaging/handlers/SubnetworkOperationHandler.js +44 -38
- package/src/core/network/messaging/handlers/TransferOperationHandler.js +29 -25
- package/src/core/network/messaging/handlers/base/BaseOperationHandler.js +20 -21
- package/src/core/network/messaging/routes/NetworkMessageRouter.js +24 -20
- package/src/core/network/messaging/validators/AdminResponse.js +2 -2
- package/src/core/network/messaging/validators/CustomNodeResponse.js +2 -2
- package/src/core/network/messaging/validators/PartialBootstrapDeployment.js +3 -3
- package/src/core/network/messaging/validators/PartialRoleAccess.js +15 -12
- package/src/core/network/messaging/validators/PartialTransaction.js +9 -10
- package/src/core/network/messaging/validators/PartialTransfer.js +10 -7
- package/src/core/network/messaging/validators/ValidatorResponse.js +2 -2
- package/src/core/network/messaging/validators/base/BaseResponse.js +13 -5
- package/src/core/network/messaging/validators/base/PartialOperation.js +37 -21
- package/src/core/network/services/ConnectionManager.js +248 -62
- package/src/core/network/services/MessageOrchestrator.js +83 -0
- package/src/core/network/services/TransactionPoolService.js +9 -8
- package/src/core/network/services/ValidatorObserverService.js +95 -34
- package/src/core/state/State.js +136 -139
- 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 +153 -201
- package/src/messages/completeStateMessages/CompleteStateMessageBuilder.js +36 -32
- package/src/messages/completeStateMessages/CompleteStateMessageOperations.js +39 -42
- package/src/messages/partialStateMessages/PartialStateMessageBuilder.js +20 -20
- package/src/messages/partialStateMessages/PartialStateMessageOperations.js +29 -22
- package/src/utils/check.js +21 -17
- package/src/utils/cliCommands.js +11 -11
- package/src/utils/constants.js +2 -9
- 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 +10 -9
- 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 +9 -9
- 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/protobuf.fixtures.js +27 -26
- package/tests/helpers/StateNetworkFactory.js +3 -5
- package/tests/helpers/autobaseTestHelpers.js +48 -2
- package/tests/helpers/config.js +3 -0
- package/tests/helpers/setupApplyTests.js +89 -82
- package/tests/helpers/transactionPayloads.mjs +26 -12
- package/tests/integration/apply/addAdmin/addAdminBasic.test.js +10 -9
- package/tests/integration/apply/addAdmin/addAdminRecovery.test.js +20 -19
- package/tests/integration/apply/addIndexer.test.js +23 -21
- package/tests/integration/apply/addWhitelist.test.js +9 -9
- package/tests/integration/apply/addWriter.test.js +33 -32
- package/tests/integration/apply/banValidator.test.js +16 -9
- package/tests/integration/apply/postTx/invalidSubValues.test.js +4 -4
- package/tests/integration/apply/postTx/postTx.test.js +7 -33
- package/tests/integration/apply/removeIndexer.test.js +11 -7
- package/tests/integration/apply/removeWriter.test.js +20 -19
- package/tests/integration/apply/transfer.test.js +18 -16
- package/tests/unit/messageOperations/assembleAddIndexerMessage.test.js +2 -2
- package/tests/unit/messageOperations/assembleAddWriterMessage.test.js +2 -1
- package/tests/unit/messageOperations/assembleAdminMessage.test.js +9 -10
- package/tests/unit/messageOperations/assembleBanWriterMessage.test.js +3 -2
- package/tests/unit/messageOperations/assemblePostTransaction.test.js +25 -43
- package/tests/unit/messageOperations/assembleRemoveIndexerMessage.test.js +2 -2
- package/tests/unit/messageOperations/assembleRemoveWriterMessage.test.js +2 -2
- package/tests/unit/messageOperations/assembleWhitelistMessages.test.js +5 -4
- package/tests/unit/messageOperations/commonsStateMessageOperationsTest.js +4 -3
- package/tests/unit/network/ConnectionManager.test.js +41 -70
- package/tests/unit/network/NetworkWalletFactory.test.js +14 -14
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +6 -6
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +8 -8
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +6 -5
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +24 -23
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +10 -16
- package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +2 -1
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +45 -41
- package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +3 -7
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +17 -16
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +3 -4
- 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 +23 -25
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +2 -1
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +19 -18
- 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 +3 -4
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +2 -2
- 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 +11 -10
- package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +6 -5
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +6 -7
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +35 -34
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +44 -43
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +26 -25
- 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/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/utils.test.js +0 -1
- package/src/core/state/utils/indexerEntry.js +0 -105
- package/src/utils/crypto.js +0 -11
- 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/{helpers.mjs → helpers.js} +0 -0
- /package/rpc/utils/{url.mjs → url.js} +0 -0
|
@@ -19,16 +19,17 @@ import {
|
|
|
19
19
|
testKeyPair7
|
|
20
20
|
} from '../../fixtures/apply.fixtures.js';
|
|
21
21
|
import b4a from 'b4a';
|
|
22
|
+
import { config } from '../../helpers/config.js';
|
|
22
23
|
|
|
23
24
|
let tmpDirectory, admin, indexer1, indexer2, reader1, reader2, indexer3, writer;
|
|
24
25
|
|
|
25
26
|
hook('Initialize nodes for addIndexer tests', async t => {
|
|
26
27
|
const randomChannel = randomBytes(32).toString('hex');
|
|
27
28
|
const baseOptions = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
enableTxApplyLogs: false,
|
|
30
|
+
enableInteractiveMode: false,
|
|
31
|
+
enableRoleRequester: false,
|
|
32
|
+
enableValidatorObserver: false,
|
|
32
33
|
channel: randomChannel,
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -54,7 +55,8 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
54
55
|
// indexer3 is just a writer.
|
|
55
56
|
const oldIndexersEntry = await admin.msb.state.getIndexersEntry();
|
|
56
57
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
57
|
-
const assembledAddIndexerMessage = await CompleteStateMessageOperations
|
|
58
|
+
const assembledAddIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
59
|
+
.assembleAddIndexerMessage(indexer1.wallet.address, validity);
|
|
58
60
|
await waitIndexer(indexer1, async () => await admin.msb.state.append(assembledAddIndexerMessage))
|
|
59
61
|
|
|
60
62
|
await waitForNodeState(admin, indexer1.wallet.address, {
|
|
@@ -80,11 +82,11 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
80
82
|
// reader2 is just a reading node.
|
|
81
83
|
// indexer3 is just a writer.
|
|
82
84
|
const indexersEntryBefore = await admin.msb.state.getIndexersEntry();
|
|
83
|
-
const assembledAddIndexerMessage = await CompleteStateMessageOperations.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
const assembledAddIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
86
|
+
.assembleAddIndexerMessage(
|
|
87
|
+
indexer2.wallet.address,
|
|
88
|
+
await admin.msb.state.getIndexerSequenceState()
|
|
89
|
+
);
|
|
88
90
|
await waitIndexer(indexer2, async () => await admin.msb.state.append(assembledAddIndexerMessage))
|
|
89
91
|
|
|
90
92
|
await waitForNodeState(admin, indexer2.wallet.address, {
|
|
@@ -97,8 +99,7 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
97
99
|
await tryToSyncWriters(admin, indexer1, indexer2);
|
|
98
100
|
|
|
99
101
|
const adminSignedLengthBefore = admin.msb.state.getSignedLength();
|
|
100
|
-
const reqAddIndexerMessageAgain = await CompleteStateMessageOperations.assembleAddIndexerMessage(
|
|
101
|
-
admin.wallet,
|
|
102
|
+
const reqAddIndexerMessageAgain = await new CompleteStateMessageOperations(admin.wallet, config).assembleAddIndexerMessage(
|
|
102
103
|
indexer2.wallet.address,
|
|
103
104
|
await admin.msb.state.getIndexerSequenceState()
|
|
104
105
|
);
|
|
@@ -134,7 +135,8 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
134
135
|
// indexer3 is just a writer.
|
|
135
136
|
const indexersEntryBefore = await indexer1.msb.state.getIndexersEntry();
|
|
136
137
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
137
|
-
const reqAddReader = await CompleteStateMessageOperations
|
|
138
|
+
const reqAddReader = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
139
|
+
.assembleAddIndexerMessage(reader1.wallet.address, validity);
|
|
138
140
|
|
|
139
141
|
const adminSignedLengthBefore = admin.msb.state.getSignedLength()
|
|
140
142
|
const indexer1SignedLengthBefore = indexer1.msb.state.getSignedLength();
|
|
@@ -167,10 +169,10 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
167
169
|
const indexersEntryBeforeWhitelist = await admin.msb.state.getIndexersEntry();
|
|
168
170
|
const adminSignedLengthBefore = admin.msb.state.getSignedLength();
|
|
169
171
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
170
|
-
const reqAddIndexer2 = await CompleteStateMessageOperations.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
const reqAddIndexer2 = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
173
|
+
.assembleAddIndexerMessage(
|
|
174
|
+
reader2.wallet.address,
|
|
175
|
+
validity);
|
|
174
176
|
|
|
175
177
|
await admin.msb.state.append(reqAddIndexer2);
|
|
176
178
|
await tryToSyncWriters(admin, indexer1, indexer2);
|
|
@@ -198,10 +200,10 @@ test('handleApplyAddIndexerOperation (apply) - Append addIndexer payload into th
|
|
|
198
200
|
const adminSignedLengthBefore = admin.msb.state.getSignedLength();
|
|
199
201
|
|
|
200
202
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
201
|
-
const assembledAddIndexerMessage = await CompleteStateMessageOperations.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
const assembledAddIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
204
|
+
.assembleAddIndexerMessage(
|
|
205
|
+
indexer3.wallet.address,
|
|
206
|
+
validity);
|
|
205
207
|
|
|
206
208
|
await writer.msb.state.append(assembledAddIndexerMessage);
|
|
207
209
|
await tryToSyncWriters(admin, writer, indexer1, indexer2);
|
|
@@ -5,17 +5,17 @@ import { testKeyPair1, testKeyPair2 } from '../../fixtures/apply.fixtures.js';
|
|
|
5
5
|
import fileUtils from '../../../src/utils/fileUtils.js';
|
|
6
6
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
7
7
|
import { address as addressApi } from 'trac-crypto-api';
|
|
8
|
-
import {
|
|
8
|
+
import { config } from '../../helpers/config.js';
|
|
9
9
|
|
|
10
10
|
let admin, whitelistKeys, tmpDirectory, originalReadAddressesFromWhitelistFile;
|
|
11
|
-
const address = addressApi.encode(
|
|
11
|
+
const address = addressApi.encode(config.addressPrefix, b4a.from(testKeyPair2.publicKey, 'hex'))
|
|
12
12
|
hook('Initialize admin node for addWhitelist tests', async () => {
|
|
13
13
|
const randomChannel = randomBytes(32).toString('hex');
|
|
14
14
|
const baseOptions = {
|
|
15
15
|
enable_txchannels: false,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
enableTxApplyLogs: false,
|
|
17
|
+
enableInteractiveMode: false,
|
|
18
|
+
enableRoleRequester: false,
|
|
19
19
|
channel: randomChannel,
|
|
20
20
|
}
|
|
21
21
|
tmpDirectory = await initTemporaryDirectory();
|
|
@@ -31,9 +31,9 @@ hook('Initialize admin node for addWhitelist tests', async () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
test('Apply function addWhitelist - happy path', async (t) => {
|
|
34
|
-
const validity =
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
const validity = await admin.msb.state.getIndexerSequenceState();
|
|
35
|
+
const payload = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
36
|
+
.assembleAppendWhitelistMessages(validity, address);
|
|
37
37
|
|
|
38
38
|
await admin.msb.state.append(payload);
|
|
39
39
|
const isWhitelisted = await admin.msb.state.isAddressWhitelisted(address);
|
|
@@ -50,4 +50,4 @@ hook('Cleanup after addWhitelist tests', async () => {
|
|
|
50
50
|
await removeTemporaryDirectory(tmpDirectory);
|
|
51
51
|
}
|
|
52
52
|
fileUtils.readAddressesFromWhitelistFile = originalReadAddressesFromWhitelistFile;
|
|
53
|
-
});
|
|
53
|
+
});
|
|
@@ -27,23 +27,24 @@ import PartialStateMessageOperations from "../../../src/messages/partialStateMes
|
|
|
27
27
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
28
28
|
import {ZERO_WK} from '../../../src/utils/buffer.js';
|
|
29
29
|
import { $TNK } from '../../../src/core/state/utils/balance.js';
|
|
30
|
+
import { config } from '../../helpers/config.js';
|
|
30
31
|
|
|
31
32
|
const sendAddWriter = async (invoker, broadcaster) => {
|
|
32
33
|
const validity = await invoker.msb.state.getIndexerSequenceState()
|
|
33
|
-
const req = await PartialStateMessageOperations.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const raw = await CompleteStateMessageOperations.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
const req = await new PartialStateMessageOperations(invoker.wallet, config)
|
|
35
|
+
.assembleAddWriterMessage(
|
|
36
|
+
b4a.toString(invoker.msb.state.writingKey, 'hex'),
|
|
37
|
+
b4a.toString(validity, 'hex'));
|
|
38
|
+
|
|
39
|
+
const raw = await new CompleteStateMessageOperations(broadcaster.wallet, config)
|
|
40
|
+
.assembleAddWriterMessage(
|
|
41
|
+
req.address,
|
|
42
|
+
b4a.from(req.rao.tx, 'hex'),
|
|
43
|
+
b4a.from(req.rao.txv, 'hex'),
|
|
44
|
+
b4a.from(req.rao.iw, 'hex'),
|
|
45
|
+
b4a.from(req.rao.in, 'hex'),
|
|
46
|
+
b4a.from(req.rao.is, 'hex')
|
|
47
|
+
)
|
|
47
48
|
return await broadcaster.msb.state.append(raw)
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -52,11 +53,11 @@ let admin, writer1, writer2, writer3, writer4, indexer1, tmpDirectory;
|
|
|
52
53
|
hook('Initialize nodes for addWriter tests', async t => {
|
|
53
54
|
const randomChannel = randomBytes(32).toString('hex');
|
|
54
55
|
const baseOptions = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
enableTxApplyLogs: false,
|
|
57
|
+
enableInteractiveMode: false,
|
|
58
|
+
enableRoleRequester: false,
|
|
58
59
|
channel: randomChannel,
|
|
59
|
-
|
|
60
|
+
enableValidatorObserver: false
|
|
60
61
|
}
|
|
61
62
|
tmpDirectory = await initTemporaryDirectory();
|
|
62
63
|
admin = await setupMsbAdmin(testKeyPair1, tmpDirectory, baseOptions);
|
|
@@ -145,20 +146,20 @@ test('handleApplyAddWriterOperation (apply) - Append addWriter payload into the
|
|
|
145
146
|
const signedLengthWriter1Before = writer1.msb.state.getSignedLength();
|
|
146
147
|
|
|
147
148
|
const validity = await writer3.msb.state.getIndexerSequenceState()
|
|
148
|
-
const req = await PartialStateMessageOperations.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const raw = await CompleteStateMessageOperations.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
149
|
+
const req = await new PartialStateMessageOperations(writer3.wallet, config)
|
|
150
|
+
.assembleAddWriterMessage(
|
|
151
|
+
b4a.toString(ZERO_WK, 'hex'),
|
|
152
|
+
b4a.toString(validity, 'hex'));
|
|
153
|
+
|
|
154
|
+
const raw = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
155
|
+
.assembleAddWriterMessage(
|
|
156
|
+
admin.wallet.address,
|
|
157
|
+
b4a.from(req.rao.tx, 'hex'),
|
|
158
|
+
b4a.from(req.rao.txv, 'hex'),
|
|
159
|
+
b4a.from(req.rao.iw, 'hex'),
|
|
160
|
+
b4a.from(req.rao.in, 'hex'),
|
|
161
|
+
b4a.from(req.rao.is, 'hex')
|
|
162
|
+
)
|
|
162
163
|
await admin.msb.state.append(raw)
|
|
163
164
|
await tryToSyncWriters(writer3, admin, writer1, writer2, indexer1);
|
|
164
165
|
|
|
@@ -10,9 +10,11 @@ import {
|
|
|
10
10
|
} from '../../helpers/setupApplyTests.js';
|
|
11
11
|
import { randomBytes } from '../../helpers/setupApplyTests.js';
|
|
12
12
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
13
|
+
|
|
13
14
|
import { testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4 } from '../../fixtures/apply.fixtures.js';
|
|
14
15
|
import { sleep } from '../../../src/utils/helpers.js';
|
|
15
16
|
import b4a from 'b4a'
|
|
17
|
+
import { config } from '../../helpers/config.js';
|
|
16
18
|
|
|
17
19
|
let admin;
|
|
18
20
|
let indexer, writer1, writer2;
|
|
@@ -21,11 +23,11 @@ let tmpDirectory;
|
|
|
21
23
|
hook('Initialize nodes for banValidator tests', async () => {
|
|
22
24
|
const randomChannel = randomBytes(32).toString('hex');
|
|
23
25
|
const baseOptions = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
enableTxApplyLogs: false,
|
|
27
|
+
enableInteractiveMode: false,
|
|
28
|
+
enableRoleRequester: false,
|
|
27
29
|
channel: randomChannel,
|
|
28
|
-
|
|
30
|
+
enableValidatorObserver: false,
|
|
29
31
|
}
|
|
30
32
|
tmpDirectory = await initTemporaryDirectory();
|
|
31
33
|
admin = await setupMsbAdmin(testKeyPair1, tmpDirectory, baseOptions);
|
|
@@ -39,7 +41,8 @@ hook('Initialize nodes for banValidator tests', async () => {
|
|
|
39
41
|
|
|
40
42
|
test('handleApplyBanValidatorOperation (apply) - Append banValidator payload - ban indexer', async t => {
|
|
41
43
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
42
|
-
const assembledBanWriter = await CompleteStateMessageOperations
|
|
44
|
+
const assembledBanWriter = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
45
|
+
.assembleBanWriterMessage(indexer.wallet.address, validity);
|
|
43
46
|
await admin.msb.state.append(assembledBanWriter);
|
|
44
47
|
await tryToSyncWriters(admin, indexer, writer1, writer2);
|
|
45
48
|
|
|
@@ -53,7 +56,8 @@ test('handleApplyBanValidatorOperation (apply) - Append banValidator payload - b
|
|
|
53
56
|
|
|
54
57
|
test('handleApplyBanValidatorOperation (apply) - Append banValidator payload into the base by non-admin node', async t => {
|
|
55
58
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
56
|
-
const assembledBanWriter = await CompleteStateMessageOperations
|
|
59
|
+
const assembledBanWriter = await new CompleteStateMessageOperations(writer1.wallet, config)
|
|
60
|
+
.assembleBanWriterMessage(writer2.wallet.address, validity);
|
|
57
61
|
await writer1.msb.state.append(assembledBanWriter);
|
|
58
62
|
await sleep(5000); // wait for both peers to sync state
|
|
59
63
|
await tryToSyncWriters(admin);
|
|
@@ -67,7 +71,8 @@ test('handleApplyBanValidatorOperation (apply) - Append banValidator payload int
|
|
|
67
71
|
|
|
68
72
|
test('handleApplyBanValidatorOperation (apply) - Append banValidator payload into the base - happy path', async t => {
|
|
69
73
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
70
|
-
const assembledBanWriter = await CompleteStateMessageOperations
|
|
74
|
+
const assembledBanWriter = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
75
|
+
.assembleBanWriterMessage(writer1.wallet.address, validity);
|
|
71
76
|
await admin.msb.state.append(assembledBanWriter);
|
|
72
77
|
await sleep(5000); // wait for both peers to sync state
|
|
73
78
|
|
|
@@ -80,14 +85,16 @@ test('handleApplyBanValidatorOperation (apply) - Append banValidator payload int
|
|
|
80
85
|
|
|
81
86
|
test('handleApplyBanValidatorOperation (apply) - Append banValidator payload into the base - idempotence', async t => {
|
|
82
87
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
83
|
-
const assembledBanWriter = await CompleteStateMessageOperations
|
|
88
|
+
const assembledBanWriter = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
89
|
+
.assembleBanWriterMessage(writer2.wallet.address, validity);
|
|
84
90
|
await admin.msb.state.append(assembledBanWriter);
|
|
85
91
|
await sleep(5000); // wait for both peers to sync state
|
|
86
92
|
|
|
87
93
|
const nodeInfo = await writer2.msb.state.getNodeEntry(writer2.wallet.address);
|
|
88
94
|
|
|
89
95
|
const validity2 = await admin.msb.state.getIndexerSequenceState()
|
|
90
|
-
const assembledBanWriter2 = await CompleteStateMessageOperations
|
|
96
|
+
const assembledBanWriter2 = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
97
|
+
.assembleBanWriterMessage(writer2.wallet.address, validity2);
|
|
91
98
|
await admin.msb.state.append(assembledBanWriter2);
|
|
92
99
|
await sleep(5000); // wait for both peers to sync state
|
|
93
100
|
|
|
@@ -38,10 +38,10 @@ hook('Initialize nodes', async t => {
|
|
|
38
38
|
const randomChannel = randomBytes(32).toString('hex');
|
|
39
39
|
|
|
40
40
|
const baseOptions = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
enableTxApplyLogs: false,
|
|
42
|
+
enableInteractiveMode: false,
|
|
43
|
+
enableRoleRequester: false,
|
|
44
|
+
enableValidatorObserver: false,
|
|
45
45
|
channel: randomChannel,
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -21,6 +21,7 @@ import {testKeyPair1, testKeyPair2, testKeyPair3, testKeyPair4, testKeyPair5} fr
|
|
|
21
21
|
import {OperationType} from "../../../../src/utils/constants.js";
|
|
22
22
|
import {addressToBuffer} from "../../../../src/core/state/utils/address.js";
|
|
23
23
|
import { $TNK } from '../../../../src/core/state/utils/balance.js';
|
|
24
|
+
import { config } from '../../../helpers/config.js';
|
|
24
25
|
|
|
25
26
|
let tmpDirectory, admin, writer, externalNode, externalBootstrap, maliciousPeer;
|
|
26
27
|
|
|
@@ -32,10 +33,10 @@ hook('Initialize nodes', async t => {
|
|
|
32
33
|
const randomChannel = randomBytes(32).toString('hex');
|
|
33
34
|
|
|
34
35
|
const baseOptions = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
enableTxApplyLogs: false,
|
|
37
|
+
enableInteractiveMode: false,
|
|
38
|
+
enableRoleRequester: false,
|
|
39
|
+
enableValidatorObserver: false,
|
|
39
40
|
channel: randomChannel,
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -107,33 +108,6 @@ test('handleApplyTxOperation (apply) - different operation type', async t => {
|
|
|
107
108
|
t.absent(await writer.msb.state.get(txHash), 'post tx with incorrect operation type should not be added to the base');
|
|
108
109
|
})
|
|
109
110
|
|
|
110
|
-
// test('handleApplyTxOperation (apply) - replay attack', async t => {
|
|
111
|
-
// const {postTx, txHash} = await generatePostTx(writer, externalNode, externalBootstrap)
|
|
112
|
-
// const rawTx = await CompleteStateMessageOperations.assembleCompleteTransactionOperationMessage(
|
|
113
|
-
// writer.msb.wallet,
|
|
114
|
-
// postTx.address,
|
|
115
|
-
// b4a.from(postTx.txo.tx, 'hex'),
|
|
116
|
-
// b4a.from(postTx.txo.txv, 'hex'),
|
|
117
|
-
// b4a.from(postTx.txo.iw, 'hex'),
|
|
118
|
-
// b4a.from(postTx.txo.in, 'hex'),
|
|
119
|
-
// b4a.from(postTx.txo.ch, 'hex'),
|
|
120
|
-
// b4a.from(postTx.txo.is, 'hex'),
|
|
121
|
-
// b4a.from(postTx.txo.bs, 'hex'),
|
|
122
|
-
// b4a.from(postTx.txo.mbs, 'hex')
|
|
123
|
-
// );
|
|
124
|
-
// await writer.msb.state.append(rawTx);
|
|
125
|
-
// await tick();
|
|
126
|
-
// await sleep(500)
|
|
127
|
-
// const firstRes = await writer.msb.state.base.view.get(txHash);
|
|
128
|
-
|
|
129
|
-
// await writer.msb.state.append(rawTx);
|
|
130
|
-
// await sleep(500)
|
|
131
|
-
// await tick();
|
|
132
|
-
// const secondRes = await writer.msb.state.base.view.get(txHash);
|
|
133
|
-
|
|
134
|
-
// t.is(firstRes.seq, secondRes.seq, 'post tx should not be added to the base twice');
|
|
135
|
-
// })
|
|
136
|
-
|
|
137
111
|
test('handleApplyTxOperation (apply) - invalid postTx signature (adversary signature - writer signature)', async t => {
|
|
138
112
|
const maliciousWriter = await promoteToWriter(admin, maliciousPeer)
|
|
139
113
|
const {postTx, txHash} = await generatePostTx(writer, externalNode, externalBootstrap)
|
|
@@ -189,7 +163,7 @@ test('handleApplyTxOperation (apply) - invalid postTx address (malicious node re
|
|
|
189
163
|
const maliciousWriter = await promoteToWriter(admin, maliciousPeer)
|
|
190
164
|
const {postTx, txHash} = await generatePostTx(writer, externalNode, externalBootstrap)
|
|
191
165
|
let decodedPostTx = safeDecodeApplyOperation(postTx);
|
|
192
|
-
decodedPostTx.address = addressToBuffer(maliciousWriter.wallet.address);
|
|
166
|
+
decodedPostTx.address = addressToBuffer(maliciousWriter.wallet.address, config.addressPrefix);
|
|
193
167
|
const encodedMaliciousPostTx = safeEncodeApplyOperation(decodedPostTx);
|
|
194
168
|
await maliciousWriter.msb.state.append(encodedMaliciousPostTx);
|
|
195
169
|
await waitDemotion(maliciousWriter, async () => {
|
|
@@ -203,7 +177,7 @@ test('handleApplyTxOperation (apply) - invalid postTx txo.ia (malicious node rep
|
|
|
203
177
|
const maliciousWriter = await promoteToWriter(admin, maliciousPeer)
|
|
204
178
|
const {postTx, txHash} = await generatePostTx(writer, externalNode, externalBootstrap)
|
|
205
179
|
let decodedPostTx = safeDecodeApplyOperation(postTx);
|
|
206
|
-
decodedPostTx.txo.ia = addressToBuffer(maliciousWriter.wallet.address);
|
|
180
|
+
decodedPostTx.txo.ia = addressToBuffer(maliciousWriter.wallet.address, config.addressPrefix);
|
|
207
181
|
const encodedMaliciousPostTx = safeEncodeApplyOperation(decodedPostTx);
|
|
208
182
|
await waitDemotion(maliciousWriter, async () => {
|
|
209
183
|
await maliciousWriter.msb.state.append(encodedMaliciousPostTx);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {test, hook} from '../../helpers/wrapper.js';
|
|
2
2
|
|
|
3
3
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
4
|
+
import { config } from '../../helpers/config.js';
|
|
4
5
|
import {
|
|
5
6
|
initTemporaryDirectory,
|
|
6
7
|
removeTemporaryDirectory,
|
|
@@ -17,10 +18,10 @@ let tmpDirectory, admin, indexer1, indexer2, writer;
|
|
|
17
18
|
hook('Initialize nodes for addIndexer tests', async t => {
|
|
18
19
|
const randomChannel = randomBytes(32).toString('hex');
|
|
19
20
|
const baseOptions = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
enableTxApplyLogs: false,
|
|
22
|
+
enableInteractiveMode: false,
|
|
23
|
+
enableRoleRequester: false,
|
|
24
|
+
enableValidatorObserver: false,
|
|
24
25
|
channel: randomChannel,
|
|
25
26
|
}
|
|
26
27
|
tmpDirectory = await initTemporaryDirectory();
|
|
@@ -41,7 +42,8 @@ test('handleApplyRemoveIndexerOperation (apply) - Append removeIndexer payload i
|
|
|
41
42
|
// writer is already a writer
|
|
42
43
|
const indexersEntryBefore = await writer.msb.state.getIndexersEntry();
|
|
43
44
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
44
|
-
const assembledRemoveIndexerMessage = await CompleteStateMessageOperations
|
|
45
|
+
const assembledRemoveIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
46
|
+
.assembleRemoveIndexerMessage(indexer1.wallet.address, validity);
|
|
45
47
|
await admin.msb.state.append(assembledRemoveIndexerMessage);
|
|
46
48
|
await tryToSyncWriters(admin, indexer1, indexer2);
|
|
47
49
|
await waitForNodeState(indexer1, indexer1.wallet.address, {
|
|
@@ -71,7 +73,8 @@ test('handleApplyRemoveIndexerOperation (apply) - Append removeIndexer payload i
|
|
|
71
73
|
|
|
72
74
|
const indexersEntryBefore = await indexer1.msb.state.getIndexersEntry();
|
|
73
75
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
74
|
-
const assembledRemoveIndexerMessage = await CompleteStateMessageOperations
|
|
76
|
+
const assembledRemoveIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
77
|
+
.assembleRemoveIndexerMessage(indexer1.wallet.address, validity);
|
|
75
78
|
await admin.msb.state.append(assembledRemoveIndexerMessage);
|
|
76
79
|
await tryToSyncWriters(admin, indexer2, writer);
|
|
77
80
|
|
|
@@ -100,7 +103,8 @@ test('handleApplyAddIndexerOperation (apply) - Append removeIndexer payload into
|
|
|
100
103
|
const indexer2SignedLengthBefore = indexer2.msb.state.getSignedLength();
|
|
101
104
|
|
|
102
105
|
const validity = await admin.msb.state.getIndexerSequenceState()
|
|
103
|
-
const assembledRemoveIndexerMessage = await CompleteStateMessageOperations
|
|
106
|
+
const assembledRemoveIndexerMessage = await new CompleteStateMessageOperations(admin.wallet, config)
|
|
107
|
+
.assembleRemoveIndexerMessage(indexer2.wallet.address, validity);
|
|
104
108
|
await writer.msb.state.append(assembledRemoveIndexerMessage);
|
|
105
109
|
await tryToSyncWriters(admin, indexer2, writer);
|
|
106
110
|
|
|
@@ -21,26 +21,27 @@ import {
|
|
|
21
21
|
} from '../../fixtures/apply.fixtures.js';
|
|
22
22
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
23
23
|
import PartialStateMessageOperations from '../../../src/messages/partialStateMessages/PartialStateMessageOperations.js';
|
|
24
|
+
import { config } from '../../helpers/config.js';
|
|
24
25
|
|
|
25
26
|
let admin, writer1, writer2, writer3, writer4, indexer, tmpDirectory;
|
|
26
27
|
|
|
27
28
|
const sendRemoveWriter = async (invoker, broadcaster) => {
|
|
28
29
|
const validity = await invoker.msb.state.getIndexerSequenceState()
|
|
29
|
-
const writerRemoval = await PartialStateMessageOperations.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const raw = await CompleteStateMessageOperations.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
const writerRemoval = await new PartialStateMessageOperations(invoker.wallet, config)
|
|
31
|
+
.assembleRemoveWriterMessage(
|
|
32
|
+
b4a.toString(invoker.msb.state.writingKey, 'hex'),
|
|
33
|
+
b4a.toString(validity, 'hex')
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const raw = await new CompleteStateMessageOperations(broadcaster.wallet, config)
|
|
37
|
+
.assembleRemoveWriterMessage(
|
|
38
|
+
writerRemoval.address,
|
|
39
|
+
b4a.from(writerRemoval.rao.tx, 'hex'),
|
|
40
|
+
b4a.from(writerRemoval.rao.txv, 'hex'),
|
|
41
|
+
b4a.from(writerRemoval.rao.iw, 'hex'),
|
|
42
|
+
b4a.from(writerRemoval.rao.in, 'hex'),
|
|
43
|
+
b4a.from(writerRemoval.rao.is, 'hex'),
|
|
44
|
+
)
|
|
44
45
|
|
|
45
46
|
return await broadcaster.msb.state.append(raw)
|
|
46
47
|
}
|
|
@@ -50,10 +51,10 @@ hook('Initialize nodes for removeWriter tests', async () => {
|
|
|
50
51
|
const randomChannel = randomBytes(32).toString('hex');
|
|
51
52
|
|
|
52
53
|
admin = await setupMsbAdmin(testKeyPair1, tmpDirectory, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
enableTxApplyLogs: false,
|
|
55
|
+
enableInteractiveMode: false,
|
|
56
|
+
enableRoleRequester: false,
|
|
57
|
+
enableValidatorObserver: false,
|
|
57
58
|
channel: randomChannel,
|
|
58
59
|
});
|
|
59
60
|
writer1 = await setupMsbWriter(admin, 'writer', testKeyPair2, tmpDirectory, admin.options);
|
|
@@ -17,21 +17,23 @@ import {
|
|
|
17
17
|
import PartialStateMessageOperations from "../../../src/messages/partialStateMessages/PartialStateMessageOperations.js";
|
|
18
18
|
import CompleteStateMessageOperations from '../../../src/messages/completeStateMessages/CompleteStateMessageOperations.js';
|
|
19
19
|
import { $TNK } from '../../../src/core/state/utils/balance.js';
|
|
20
|
+
import { config } from '../../helpers/config.js';
|
|
20
21
|
|
|
21
22
|
const buildTransfer = async (admin, from, to, amount) => {
|
|
22
23
|
const txValidity = await from.msb.state.getIndexerSequenceState()
|
|
23
|
-
const tx = await PartialStateMessageOperations
|
|
24
|
+
const tx = await new PartialStateMessageOperations(from.wallet, config)
|
|
25
|
+
.assembleTransferOperationMessage(to.wallet.address, b4a.toString(amount, 'hex'), b4a.toString(txValidity, 'hex'))
|
|
24
26
|
return {
|
|
25
|
-
raw: await CompleteStateMessageOperations.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
raw: await new CompleteStateMessageOperations(admin.wallet, config)
|
|
28
|
+
.assembleCompleteTransferOperationMessage(
|
|
29
|
+
tx.address,
|
|
30
|
+
b4a.from(tx.tro.tx, 'hex'),
|
|
31
|
+
b4a.from(tx.tro.txv, 'hex'),
|
|
32
|
+
b4a.from(tx.tro.in, 'hex'),
|
|
33
|
+
tx.tro.to,
|
|
34
|
+
b4a.from(tx.tro.am, 'hex'),
|
|
35
|
+
b4a.from(tx.tro.is, 'hex'),
|
|
36
|
+
),
|
|
35
37
|
hash: tx.tro.tx
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -41,11 +43,11 @@ let admin, writer1, writer2, writer3, tmpDirectory;
|
|
|
41
43
|
hook('Initialize nodes for addWriter tests', async t => {
|
|
42
44
|
const randomChannel = randomBytes(32).toString('hex');
|
|
43
45
|
const baseOptions = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
enableTxApplyLogs: false,
|
|
47
|
+
enableInteractiveMode: false,
|
|
48
|
+
enableRoleRequester: false,
|
|
47
49
|
channel: randomChannel,
|
|
48
|
-
|
|
50
|
+
enableValidatorObserver: false
|
|
49
51
|
}
|
|
50
52
|
tmpDirectory = await initTemporaryDirectory();
|
|
51
53
|
admin = await setupMsbAdmin(testKeyPair1, tmpDirectory, baseOptions);
|
|
@@ -78,4 +80,4 @@ hook('Clean up handleApplyTransferOperation setup', async t => {
|
|
|
78
80
|
|
|
79
81
|
await Promise.all(toClose)
|
|
80
82
|
if (tmpDirectory) await removeTemporaryDirectory(tmpDirectory);
|
|
81
|
-
});
|
|
83
|
+
});
|
|
@@ -4,12 +4,13 @@ import { OperationType } from '../../src/utils/protobuf/applyOperations.cjs';
|
|
|
4
4
|
import { writingKeyNonAdmin, walletNonAdmin, initAll ,walletAdmin} from '../fixtures/assembleMessage.fixtures.js';
|
|
5
5
|
import { messageOperationsBkoTest } from './commonsStateMessageOperationsTest.js';
|
|
6
6
|
import { safeDecodeApplyOperation } from '../../src/utils/protobuf/operationHelpers.js';
|
|
7
|
+
import { config } from '../../helpers/config.js';
|
|
7
8
|
|
|
8
9
|
const testName = 'assembleAddIndexerMessage';
|
|
9
10
|
test(testName, async (t) => {
|
|
10
11
|
await initAll();
|
|
11
12
|
const assembler = async (wallet, address) => {
|
|
12
|
-
return safeDecodeApplyOperation(await CompleteStateMessageOperations.assembleAddIndexerMessage(
|
|
13
|
+
return safeDecodeApplyOperation(await new CompleteStateMessageOperations(wallet, config).assembleAddIndexerMessage(address));
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
await messageOperationsBkoTest(t, testName, assembler, walletAdmin, writingKeyNonAdmin, OperationType.ADD_INDEXER, 2, walletNonAdmin.address);
|
|
@@ -18,4 +19,3 @@ test(testName, async (t) => {
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
|
|
@@ -4,12 +4,13 @@ import {OperationType} from '../../src/utils/protobuf/applyOperations.cjs';
|
|
|
4
4
|
import {initAll, walletNonAdmin, writingKeyNonAdmin} from '../fixtures/assembleMessage.fixtures.js';
|
|
5
5
|
import {messageOperationsEkoTest} from './commonsStateMessageOperationsTest.js';
|
|
6
6
|
import {safeDecodeApplyOperation} from '../../src/utils/protobuf/operationHelpers.js';
|
|
7
|
+
import { config } from '../../helpers/config.js'
|
|
7
8
|
|
|
8
9
|
const testName = 'assembleAddWriterMessage';
|
|
9
10
|
test(testName, async (t) => {
|
|
10
11
|
await initAll();
|
|
11
12
|
const assembler = async (wallet, writingKey) => {
|
|
12
|
-
return safeDecodeApplyOperation(await CompleteStateMessageOperations
|
|
13
|
+
return safeDecodeApplyOperation(await new CompleteStateMessageOperations(wallet, config).assembleAddWriterMessage(writingKey));
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
await messageOperationsEkoTest(t, testName, assembler, walletNonAdmin, writingKeyNonAdmin, OperationType.ADD_WRITER, 3, walletNonAdmin.address);
|