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,10 +1,9 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { applyStateMessageFactory } from '../../../../../src/messages/state/applyStateMessageFactory.js';
|
|
3
|
+
import { safeEncodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
4
4
|
import { deriveIndexerSequenceState, eventFlush } from '../../../../helpers/autobaseTestHelpers.js';
|
|
5
5
|
import { safeDecodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
6
6
|
import nodeEntryUtils, { ZERO_LICENSE } from '../../../../../src/core/state/utils/nodeEntry.js';
|
|
7
|
-
import nodeRoleUtils from '../../../../../src/core/state/utils/roles.js';
|
|
8
7
|
import lengthEntryUtils from '../../../../../src/core/state/utils/lengthEntry.js';
|
|
9
8
|
import addressUtils from '../../../../../src/core/state/utils/address.js';
|
|
10
9
|
import { EntryType } from '../../../../../src/utils/constants.js';
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
} from '../../../../../src/core/state/utils/balance.js';
|
|
18
17
|
import { decimalStringToBigInt, bigIntTo16ByteBuffer } from '../../../../../src/utils/amountSerialization.js';
|
|
19
18
|
import { setupAdminAndWhitelistedReaderNetwork } from '../common/commonScenarioHelper.js';
|
|
19
|
+
import { config } from '../../../../helpers/config.js';
|
|
20
20
|
|
|
21
21
|
const DEFAULT_WRITER_FUNDING = bigIntTo16ByteBuffer(decimalStringToBigInt('10'));
|
|
22
22
|
const STAKE_ENTRY_MARK = Symbol('stake-entry-mark');
|
|
@@ -105,21 +105,24 @@ export async function buildAddWriterPayload(
|
|
|
105
105
|
) {
|
|
106
106
|
const txValidity = await deriveIndexerSequenceState(validatorPeer.base);
|
|
107
107
|
const writingKey = writerKeyBuffer ?? readerPeer.base.local.key;
|
|
108
|
-
const partial = await
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
const partial = await applyStateMessageFactory(readerPeer.wallet, config)
|
|
109
|
+
.buildPartialAddWriterMessage(
|
|
110
|
+
readerPeer.wallet.address,
|
|
111
|
+
writingKey.toString('hex'),
|
|
112
|
+
txValidity.toString('hex'),
|
|
113
|
+
'json'
|
|
114
|
+
);
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
const payload = await applyStateMessageFactory(validatorPeer.wallet, config)
|
|
117
|
+
.buildCompleteAddWriterMessage(
|
|
118
|
+
partial.address,
|
|
119
|
+
b4a.from(partial.rao.tx, 'hex'),
|
|
120
|
+
b4a.from(partial.rao.txv, 'hex'),
|
|
121
|
+
b4a.from(partial.rao.iw, 'hex'),
|
|
122
|
+
b4a.from(partial.rao.in, 'hex'),
|
|
123
|
+
b4a.from(partial.rao.is, 'hex')
|
|
124
|
+
);
|
|
125
|
+
return safeEncodeApplyOperation(payload);
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
export async function buildAddWriterPayloadWithTxValidity(
|
|
@@ -136,21 +139,24 @@ export async function buildAddWriterPayloadWithTxValidity(
|
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
const writingKey = writerKeyBuffer ?? readerPeer.base.local.key;
|
|
139
|
-
const partial = await
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const partial = await applyStateMessageFactory(readerPeer.wallet, config)
|
|
143
|
+
.buildPartialAddWriterMessage(
|
|
144
|
+
readerPeer.wallet.address,
|
|
145
|
+
writingKey.toString('hex'),
|
|
146
|
+
mutatedTxValidity.toString('hex'),
|
|
147
|
+
'json'
|
|
148
|
+
);
|
|
144
149
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
const payload = await applyStateMessageFactory(validatorPeer.wallet, config)
|
|
151
|
+
.buildCompleteAddWriterMessage(
|
|
152
|
+
partial.address,
|
|
153
|
+
b4a.from(partial.rao.tx, 'hex'),
|
|
154
|
+
mutatedTxValidity,
|
|
155
|
+
b4a.from(partial.rao.iw, 'hex'),
|
|
156
|
+
b4a.from(partial.rao.in, 'hex'),
|
|
157
|
+
b4a.from(partial.rao.is, 'hex')
|
|
158
|
+
);
|
|
159
|
+
return safeEncodeApplyOperation(payload);
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
export async function buildRemoveWriterPayload(
|
|
@@ -163,21 +169,24 @@ export async function buildRemoveWriterPayload(
|
|
|
163
169
|
) {
|
|
164
170
|
const txValidity = await deriveIndexerSequenceState(validatorPeer.base);
|
|
165
171
|
const writerKey = writerKeyBuffer ?? readerPeer.base.local.key;
|
|
166
|
-
const partial = await
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
const partial = await applyStateMessageFactory(readerPeer.wallet, config)
|
|
173
|
+
.buildPartialRemoveWriterMessage(
|
|
174
|
+
readerPeer.wallet.address,
|
|
175
|
+
writerKey.toString('hex'),
|
|
176
|
+
txValidity.toString('hex'),
|
|
177
|
+
'json'
|
|
178
|
+
);
|
|
171
179
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const payload = await applyStateMessageFactory(validatorPeer.wallet, config)
|
|
181
|
+
.buildCompleteRemoveWriterMessage(
|
|
182
|
+
partial.address,
|
|
183
|
+
b4a.from(partial.rao.tx, 'hex'),
|
|
184
|
+
b4a.from(partial.rao.txv, 'hex'),
|
|
185
|
+
b4a.from(partial.rao.iw, 'hex'),
|
|
186
|
+
b4a.from(partial.rao.in, 'hex'),
|
|
187
|
+
b4a.from(partial.rao.is, 'hex')
|
|
188
|
+
);
|
|
189
|
+
return safeEncodeApplyOperation(payload);
|
|
181
190
|
}
|
|
182
191
|
|
|
183
192
|
export async function assertAddWriterSuccessState(
|
|
@@ -207,7 +216,7 @@ export async function assertAddWriterSuccessState(
|
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
const writerAddress = readerPeer.wallet.address;
|
|
210
|
-
|
|
219
|
+
const writerAddressBuffer = addressUtils.addressToBuffer(writerAddress, config.addressPrefix);
|
|
211
220
|
const writingKey = writerKeyBuffer ?? readerPeer.base.local.key;
|
|
212
221
|
const writingKeyHex = writingKey.toString('hex');
|
|
213
222
|
|
|
@@ -588,7 +597,7 @@ async function assertWriterDowngradedEntry(
|
|
|
588
597
|
'writer liquid balance matches expected amount after downgrade'
|
|
589
598
|
);
|
|
590
599
|
}
|
|
591
|
-
|
|
600
|
+
const addressBuffer = addressUtils.addressToBuffer(address, config.addressPrefix);
|
|
592
601
|
const writerRegistryEntry = await base.view.get(
|
|
593
602
|
EntryType.WRITER_ADDRESS + writingKey.toString('hex')
|
|
594
603
|
);
|
|
@@ -654,7 +663,7 @@ async function withPeerEntryOverrideOnApply({
|
|
|
654
663
|
const node = assertWritableNode(selectNode(context));
|
|
655
664
|
const base = node.base;
|
|
656
665
|
const targetAddress = targetPeer.wallet.address;
|
|
657
|
-
|
|
666
|
+
const targetBuffer = addressUtils.addressToBuffer(targetAddress, config.addressPrefix);
|
|
658
667
|
const originalApply = base._handlers.apply;
|
|
659
668
|
|
|
660
669
|
base._handlers.apply = async function patchedApply(nodes, view, baseCtx) {
|
|
@@ -12,6 +12,7 @@ import { initializeBalances, whitelistAddress } from '../common/commonScenarioHe
|
|
|
12
12
|
import { eventFlush } from '../../../../helpers/autobaseTestHelpers.js';
|
|
13
13
|
import { safeDecodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
14
14
|
import addressUtils from '../../../../../src/core/state/utils/address.js';
|
|
15
|
+
import { config } from '../../../../helpers/config.js';
|
|
15
16
|
|
|
16
17
|
export default function addWriterValidatorRewardScenario() {
|
|
17
18
|
test(
|
|
@@ -97,7 +98,7 @@ function assertPayloadValidator(t, payload, validatorAddress) {
|
|
|
97
98
|
t.ok(decoded, 'validator reward payload decodes');
|
|
98
99
|
const validatorBuffer = decoded?.rao?.va;
|
|
99
100
|
t.ok(validatorBuffer, 'payload carries validator address');
|
|
100
|
-
const expected = addressUtils.addressToBuffer(validatorAddress);
|
|
101
|
+
const expected = addressUtils.addressToBuffer(validatorAddress, config.addressPrefix);
|
|
101
102
|
t.ok(
|
|
102
103
|
b4a.equals(validatorBuffer, expected),
|
|
103
104
|
'payload validator address matches processing writer'
|
|
@@ -2,11 +2,10 @@ import b4a from 'b4a';
|
|
|
2
2
|
import adminEntryUtils from '../../../../../src/core/state/utils/adminEntry.js';
|
|
3
3
|
import nodeEntryUtils, { setWritingKey } from '../../../../../src/core/state/utils/nodeEntry.js';
|
|
4
4
|
import { EntryType } from '../../../../../src/utils/constants.js';
|
|
5
|
-
import { blake3Hash } from '../../../../../src/utils/crypto.js';
|
|
6
5
|
import { decimalStringToBigInt, bigIntTo16ByteBuffer } from '../../../../../src/utils/amountSerialization.js';
|
|
7
6
|
import { deriveIndexerSequenceState, eventFlush } from '../../../../helpers/autobaseTestHelpers.js';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
7
|
+
import { applyStateMessageFactory } from '../../../../../src/messages/state/applyStateMessageFactory.js';
|
|
8
|
+
import { safeEncodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
10
9
|
import {
|
|
11
10
|
setupAdminNetwork,
|
|
12
11
|
initializeBalances,
|
|
@@ -16,8 +15,8 @@ import { promotePeerToWriter } from '../addWriter/addWriterScenarioHelpers.js';
|
|
|
16
15
|
import { buildAddIndexerPayload } from '../addIndexer/addIndexerScenarioHelpers.js';
|
|
17
16
|
import { toBalance, BALANCE_FEE } from '../../../../../src/core/state/utils/balance.js';
|
|
18
17
|
import lengthEntryUtils from '../../../../../src/core/state/utils/lengthEntry.js';
|
|
19
|
-
import * as bufferUtils from '../../../../../src/utils/buffer.js';
|
|
20
18
|
import { safeDecodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
19
|
+
import { config } from '../../../../helpers/config.js';
|
|
21
20
|
|
|
22
21
|
export const DEFAULT_FUNDING = bigIntTo16ByteBuffer(decimalStringToBigInt('50'));
|
|
23
22
|
export const TRANSFER_AMOUNT = bigIntTo16ByteBuffer(decimalStringToBigInt('1'));
|
|
@@ -91,21 +90,24 @@ export async function buildAdminRecoveryPayload(context) {
|
|
|
91
90
|
const { adminPeer, validatorPeer1, newAdminWriterKey } = context.adminRecovery;
|
|
92
91
|
const txValidity = await deriveIndexerSequenceState(validatorPeer1.base);
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
93
|
+
const partial = await applyStateMessageFactory(adminPeer.wallet, config)
|
|
94
|
+
.buildPartialAdminRecoveryMessage(
|
|
95
|
+
adminPeer.wallet.address,
|
|
96
|
+
b4a.toString(newAdminWriterKey, 'hex'),
|
|
97
|
+
b4a.toString(txValidity, 'hex'),
|
|
98
|
+
'json'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const payload = await applyStateMessageFactory(validatorPeer1.wallet, config)
|
|
102
|
+
.buildCompleteAdminRecoveryMessage(
|
|
103
|
+
partial.address,
|
|
104
|
+
b4a.from(partial.rao.tx, 'hex'),
|
|
105
|
+
b4a.from(partial.rao.txv, 'hex'),
|
|
106
|
+
b4a.from(partial.rao.iw, 'hex'),
|
|
107
|
+
b4a.from(partial.rao.in, 'hex'),
|
|
108
|
+
b4a.from(partial.rao.is, 'hex')
|
|
109
|
+
);
|
|
110
|
+
return safeEncodeApplyOperation(payload);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
export async function buildAdminRecoveryPayloadWithTxValidity(context, mutatedTxValidity) {
|
|
@@ -114,21 +116,24 @@ export async function buildAdminRecoveryPayloadWithTxValidity(context, mutatedTx
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
const { adminPeer, validatorPeer1, newAdminWriterKey } = context.adminRecovery;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
119
|
+
const partial = await applyStateMessageFactory(adminPeer.wallet, config)
|
|
120
|
+
.buildPartialAdminRecoveryMessage(
|
|
121
|
+
adminPeer.wallet.address,
|
|
122
|
+
b4a.toString(newAdminWriterKey, 'hex'),
|
|
123
|
+
b4a.toString(mutatedTxValidity, 'hex'),
|
|
124
|
+
'json'
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const payload = await applyStateMessageFactory(validatorPeer1.wallet, config)
|
|
128
|
+
.buildCompleteAdminRecoveryMessage(
|
|
129
|
+
partial.address,
|
|
130
|
+
b4a.from(partial.rao.tx, 'hex'),
|
|
131
|
+
mutatedTxValidity,
|
|
132
|
+
b4a.from(partial.rao.iw, 'hex'),
|
|
133
|
+
b4a.from(partial.rao.in, 'hex'),
|
|
134
|
+
b4a.from(partial.rao.is, 'hex')
|
|
135
|
+
);
|
|
136
|
+
return safeEncodeApplyOperation(payload);
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
export async function applyAdminRecovery(context, payload) {
|
|
@@ -517,23 +522,26 @@ export async function applyTransferSeries(context, count = TRANSFER_COUNT) {
|
|
|
517
522
|
|
|
518
523
|
async function buildSimpleTransferPayload({ requesterPeer, validatorPeer, recipientPeer, amount }) {
|
|
519
524
|
const txValidity = await deriveIndexerSequenceState(validatorPeer.base);
|
|
520
|
-
const partial = await
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
525
|
+
const partial = await applyStateMessageFactory(requesterPeer.wallet, config)
|
|
526
|
+
.buildPartialTransferOperationMessage(
|
|
527
|
+
requesterPeer.wallet.address,
|
|
528
|
+
recipientPeer.wallet.address,
|
|
529
|
+
b4a.toString(amount, 'hex'),
|
|
530
|
+
b4a.toString(txValidity, 'hex'),
|
|
531
|
+
'json'
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
const payload = await applyStateMessageFactory(validatorPeer.wallet, config)
|
|
535
|
+
.buildCompleteTransferOperationMessage(
|
|
536
|
+
partial.address,
|
|
537
|
+
b4a.from(partial.tro.tx, 'hex'),
|
|
538
|
+
b4a.from(partial.tro.txv, 'hex'),
|
|
539
|
+
b4a.from(partial.tro.in, 'hex'),
|
|
540
|
+
partial.tro.to,
|
|
541
|
+
b4a.from(partial.tro.am, 'hex'),
|
|
542
|
+
b4a.from(partial.tro.is, 'hex')
|
|
543
|
+
);
|
|
544
|
+
return safeEncodeApplyOperation(payload);
|
|
537
545
|
}
|
|
538
546
|
|
|
539
547
|
export async function assertAdminRecoverySuccessState(t, context, { viewBase } = {}) {
|
|
@@ -548,7 +556,7 @@ export async function assertAdminRecoverySuccessState(t, context, { viewBase } =
|
|
|
548
556
|
const adminEntry = await base.view.get(EntryType.ADMIN);
|
|
549
557
|
t.ok(adminEntry, 'admin entry exists');
|
|
550
558
|
|
|
551
|
-
const decodedAdminEntry = adminEntryUtils.decode(adminEntry.value);
|
|
559
|
+
const decodedAdminEntry = adminEntryUtils.decode(adminEntry.value, config.addressPrefix);
|
|
552
560
|
t.ok(decodedAdminEntry, 'admin entry decodes');
|
|
553
561
|
t.ok(b4a.equals(decodedAdminEntry.wk, newAdminWriterKey), 'admin writer key updated');
|
|
554
562
|
|
|
@@ -597,7 +605,7 @@ export async function assertAdminRecoveryFailureState(t, context, { skipSync } =
|
|
|
597
605
|
const adminEntry = await adminPeer.base.view.get(EntryType.ADMIN);
|
|
598
606
|
t.ok(adminEntry, 'admin entry persists');
|
|
599
607
|
|
|
600
|
-
const decodedAdminEntry = adminEntryUtils.decode(adminEntry.value);
|
|
608
|
+
const decodedAdminEntry = adminEntryUtils.decode(adminEntry.value, config.addressPrefix);
|
|
601
609
|
t.ok(decodedAdminEntry, 'admin entry decodes');
|
|
602
610
|
t.ok(b4a.equals(decodedAdminEntry.wk, oldAdminWriterKey), 'admin writer key remains unchanged');
|
|
603
611
|
|
|
@@ -767,15 +775,22 @@ export async function applyWithIndexerSequenceFailure(context, payload) {
|
|
|
767
775
|
}
|
|
768
776
|
|
|
769
777
|
export async function applyWithIndexerSequenceCorruption(context, payload) {
|
|
770
|
-
const
|
|
771
|
-
const originalHash =
|
|
772
|
-
|
|
778
|
+
const { PeerWallet } = await import('trac-wallet');
|
|
779
|
+
const originalHash = PeerWallet.blake3;
|
|
780
|
+
const originalHashSafe = PeerWallet.blake3Safe;
|
|
781
|
+
|
|
782
|
+
PeerWallet.blake3 = async () => {
|
|
773
783
|
throw new Error('forced indexer sequence state failure');
|
|
774
784
|
};
|
|
785
|
+
PeerWallet.blake3Safe = async () => {
|
|
786
|
+
return b4a.alloc(0);
|
|
787
|
+
}
|
|
788
|
+
|
|
775
789
|
try {
|
|
776
790
|
await applyAdminRecoveryViaValidator(context, payload);
|
|
777
791
|
} finally {
|
|
778
|
-
|
|
792
|
+
PeerWallet.blake3 = originalHash;
|
|
793
|
+
PeerWallet.blake3Safe = originalHashSafe;
|
|
779
794
|
}
|
|
780
795
|
}
|
|
781
796
|
|
|
@@ -4,17 +4,13 @@ import {
|
|
|
4
4
|
setupAdminRecoveryScenario,
|
|
5
5
|
buildAdminRecoveryPayload,
|
|
6
6
|
assertAdminRecoveryFailureState,
|
|
7
|
-
assertAdminRecoverySuccessState,
|
|
8
7
|
applyAdminRecoveryViaValidator,
|
|
9
8
|
buildAdminRecoveryPayloadWithTxValidity,
|
|
10
9
|
applyWithMissingComponentBypass,
|
|
11
10
|
applyWithRoleAccessBypass,
|
|
12
11
|
applyWithRegisteredWriterKey,
|
|
13
12
|
applyWithIndexerSequenceFailure,
|
|
14
|
-
applyWithIndexerSequenceCorruption,
|
|
15
13
|
applyWithAdminEntryMutation,
|
|
16
|
-
applyWithAdminNodeEntryMutation,
|
|
17
|
-
cloneIndexers,
|
|
18
14
|
applyWithAdminEncodeFailure,
|
|
19
15
|
applyWithAdminBalanceDecodeFailure,
|
|
20
16
|
applyWithInvalidRequesterMessage,
|
|
@@ -51,7 +47,7 @@ import ValidatorConsistencyScenarioBase, {
|
|
|
51
47
|
} from '../common/validatorConsistency/base/validatorConsistencyScenarioBase.js';
|
|
52
48
|
import adminEntryUtils from '../../../../../src/core/state/utils/adminEntry.js';
|
|
53
49
|
import addressUtils from '../../../../../src/core/state/utils/address.js';
|
|
54
|
-
import
|
|
50
|
+
import { config } from '../../../../helpers/config.js';
|
|
55
51
|
|
|
56
52
|
adminRecoveryHappyPathScenario();
|
|
57
53
|
|
|
@@ -299,8 +295,8 @@ new OperationValidationScenarioBase({
|
|
|
299
295
|
mutatePayload: (_t, payload) => payload,
|
|
300
296
|
applyInvalidPayload: async (context, invalidPayload) => {
|
|
301
297
|
const otherAddress = context.adminRecovery.validatorPeer2.wallet.address;
|
|
302
|
-
const otherAddressBuffer = addressUtils.addressToBuffer(otherAddress);
|
|
303
|
-
const mutatedEntry = adminEntryUtils.encode(otherAddressBuffer, context.adminRecovery.oldAdminWriterKey);
|
|
298
|
+
const otherAddressBuffer = addressUtils.addressToBuffer(otherAddress, config.addressPrefix);
|
|
299
|
+
const mutatedEntry = adminEntryUtils.encode(otherAddressBuffer, context.adminRecovery.oldAdminWriterKey, config.addressPrefix);
|
|
304
300
|
return applyWithAdminEntryMutation(context, invalidPayload, () => ({ value: mutatedEntry }));
|
|
305
301
|
},
|
|
306
302
|
expectedLogs: ['Admin public key does not match the node public key.']
|
|
@@ -6,13 +6,14 @@ import {
|
|
|
6
6
|
deriveIndexerSequenceState,
|
|
7
7
|
eventFlush
|
|
8
8
|
} from '../../../../helpers/autobaseTestHelpers.js';
|
|
9
|
-
import
|
|
9
|
+
import { applyStateMessageFactory } from '../../../../../src/messages/state/applyStateMessageFactory.js';
|
|
10
10
|
import { AUTOBASE_VALUE_ENCODING, EntryType } from '../../../../../src/utils/constants.js';
|
|
11
11
|
import { safeDecodeApplyOperation, safeEncodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
12
12
|
import nodeEntryUtils, { ZERO_LICENSE } from '../../../../../src/core/state/utils/nodeEntry.js';
|
|
13
13
|
import lengthEntryUtils from '../../../../../src/core/state/utils/lengthEntry.js';
|
|
14
14
|
import addressUtils from '../../../../../src/core/state/utils/address.js';
|
|
15
15
|
import { buildAddAdminRequesterPayload } from '../addAdmin/addAdminScenarioHelpers.js';
|
|
16
|
+
import { config } from '../../../../helpers/config.js';
|
|
16
17
|
|
|
17
18
|
export async function setupAppendWhitelistScenario(t, { nodes = 2 } = {}) {
|
|
18
19
|
const context = await setupStateNetwork({
|
|
@@ -44,10 +45,9 @@ export async function buildAppendWhitelistPayload(context, readerAddress = null)
|
|
|
44
45
|
const adminNode = context.adminBootstrap;
|
|
45
46
|
const targetAddress = readerAddress ?? selectReaderPeer(context).wallet.address;
|
|
46
47
|
const txValidity = await deriveIndexerSequenceState(adminNode.base);
|
|
47
|
-
return
|
|
48
|
-
adminNode.wallet,
|
|
49
|
-
|
|
50
|
-
targetAddress
|
|
48
|
+
return safeEncodeApplyOperation(
|
|
49
|
+
await applyStateMessageFactory(adminNode.wallet, config)
|
|
50
|
+
.buildCompleteAppendWhitelistMessage(adminNode.wallet.address, targetAddress, txValidity)
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -58,20 +58,18 @@ export async function buildAppendWhitelistPayloadWithTxValidity(
|
|
|
58
58
|
) {
|
|
59
59
|
const adminNode = context.adminBootstrap;
|
|
60
60
|
const targetAddress = readerAddress ?? selectReaderPeer(context).wallet.address;
|
|
61
|
-
return
|
|
62
|
-
adminNode.wallet,
|
|
63
|
-
|
|
64
|
-
targetAddress
|
|
61
|
+
return safeEncodeApplyOperation(
|
|
62
|
+
await applyStateMessageFactory(adminNode.wallet, config)
|
|
63
|
+
.buildCompleteAppendWhitelistMessage(adminNode.wallet.address, targetAddress, txValidity)
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
export async function buildBanWriterPayload(context, readerAddress) {
|
|
69
68
|
const adminNode = context.adminBootstrap;
|
|
70
69
|
const txValidity = await deriveIndexerSequenceState(adminNode.base);
|
|
71
|
-
return
|
|
72
|
-
adminNode.wallet,
|
|
73
|
-
|
|
74
|
-
txValidity
|
|
70
|
+
return safeEncodeApplyOperation(
|
|
71
|
+
await applyStateMessageFactory(adminNode.wallet, config)
|
|
72
|
+
.buildCompleteBanWriterMessage(adminNode.wallet.address, readerAddress, txValidity)
|
|
75
73
|
);
|
|
76
74
|
}
|
|
77
75
|
|
|
@@ -146,7 +144,7 @@ export async function assertReaderWhitelisted(
|
|
|
146
144
|
const licenseId = lengthEntryUtils.decodeBE(decodedEntry.license);
|
|
147
145
|
const licenseIndexEntry = await base.view.get(`${EntryType.LICENSE_INDEX}${licenseId}`);
|
|
148
146
|
t.ok(licenseIndexEntry, 'license index entry exists for reader');
|
|
149
|
-
const readerAddressBuffer = addressUtils.addressToBuffer(readerAddress);
|
|
147
|
+
const readerAddressBuffer = addressUtils.addressToBuffer(readerAddress, config.addressPrefix);
|
|
150
148
|
t.ok(readerAddressBuffer.length > 0, 'reader address encodes to buffer');
|
|
151
149
|
t.ok(
|
|
152
150
|
licenseIndexEntry && b4a.equals(licenseIndexEntry.value, readerAddressBuffer),
|
package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js
CHANGED
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
deriveIndexerSequenceState,
|
|
7
7
|
eventFlush
|
|
8
8
|
} from '../../../../helpers/autobaseTestHelpers.js';
|
|
9
|
-
import
|
|
9
|
+
import { applyStateMessageFactory } from '../../../../../src/messages/state/applyStateMessageFactory.js';
|
|
10
10
|
import { AUTOBASE_VALUE_ENCODING } from '../../../../../src/utils/constants.js';
|
|
11
11
|
import { toTerm } from '../../../../../src/core/state/utils/balance.js';
|
|
12
12
|
import { safeDecodeApplyOperation, safeEncodeApplyOperation } from '../../../../../src/utils/protobuf/operationHelpers.js';
|
|
13
13
|
import { buildAddAdminRequesterPayload } from '../addAdmin/addAdminScenarioHelpers.js';
|
|
14
|
+
import { config } from '../../../../helpers/config.js';
|
|
14
15
|
|
|
15
16
|
export async function setupBalanceInitializationScenario(t, { recipientCount = 2 } = {}) {
|
|
16
17
|
const context = await setupStateNetwork({
|
|
@@ -41,12 +42,14 @@ async function bootstrapAdmin(context) {
|
|
|
41
42
|
export async function buildBalanceInitializationPayload(context, recipientAddress, balanceBuffer) {
|
|
42
43
|
const adminNode = context.adminBootstrap;
|
|
43
44
|
const txValidity = await deriveIndexerSequenceState(adminNode.base);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const payload = await applyStateMessageFactory(adminNode.wallet, config)
|
|
46
|
+
.buildCompleteBalanceInitializationMessage(
|
|
47
|
+
adminNode.wallet.address,
|
|
48
|
+
recipientAddress,
|
|
49
|
+
balanceBuffer,
|
|
50
|
+
txValidity
|
|
51
|
+
);
|
|
52
|
+
return safeEncodeApplyOperation(payload);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export async function buildBalanceInitializationPayloadWithTxValidity({
|
|
@@ -60,12 +63,14 @@ export async function buildBalanceInitializationPayloadWithTxValidity({
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
const adminNode = context.adminBootstrap;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const payload = await applyStateMessageFactory(adminNode.wallet, config)
|
|
67
|
+
.buildCompleteBalanceInitializationMessage(
|
|
68
|
+
adminNode.wallet.address,
|
|
69
|
+
decoded.bio.ia,
|
|
70
|
+
decoded.bio.am,
|
|
71
|
+
mutatedTxValidity
|
|
72
|
+
);
|
|
73
|
+
return safeEncodeApplyOperation(payload);
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
export async function buildDefaultBalanceInitializationPayload(context) {
|
package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js
CHANGED
|
@@ -7,6 +7,7 @@ import setupBalanceInitializationScenario, {
|
|
|
7
7
|
buildDefaultBalanceInitializationPayload,
|
|
8
8
|
assertBalanceInitializationFailureState
|
|
9
9
|
} from './balanceInitializationScenarioHelpers.js';
|
|
10
|
+
import { config } from '../../../../helpers/config.js';
|
|
10
11
|
|
|
11
12
|
export default function balanceInitializationNodeEntryBalanceUpdateFailureScenario() {
|
|
12
13
|
new OperationValidationScenarioBase({
|
|
@@ -30,7 +31,7 @@ async function applyWithCorruptExistingNodeEntry(context, payload, _t, validPayl
|
|
|
30
31
|
const decoded = safeDecodeApplyOperation(validPayload ?? payload);
|
|
31
32
|
const targetAddressBuffer = decoded?.bio?.ia;
|
|
32
33
|
const targetAddressString = targetAddressBuffer
|
|
33
|
-
? addressUtils.bufferToAddress(targetAddressBuffer)
|
|
34
|
+
? addressUtils.bufferToAddress(targetAddressBuffer, config.addressPrefix)
|
|
34
35
|
: null;
|
|
35
36
|
if (!targetAddressString || !targetAddressBuffer) {
|
|
36
37
|
throw new Error('Failed to resolve recipient address for balance update failure scenario.');
|
|
@@ -19,6 +19,7 @@ import addressUtils from '../../../../../src/core/state/utils/address.js';
|
|
|
19
19
|
import { EntryType } from '../../../../../src/utils/constants.js';
|
|
20
20
|
import { BALANCE_ZERO, toBalance } from '../../../../../src/core/state/utils/balance.js';
|
|
21
21
|
import lengthEntryUtils from '../../../../../src/core/state/utils/lengthEntry.js';
|
|
22
|
+
import { config } from '../../../../helpers/config.js';
|
|
22
23
|
|
|
23
24
|
export default function banValidatorBanAndReWhitelistScenario() {
|
|
24
25
|
test('State.apply banValidator allows re-whitelisting without changing license', async t => {
|
|
@@ -93,7 +94,7 @@ export default function banValidatorBanAndReWhitelistScenario() {
|
|
|
93
94
|
const licenseId = decodedBefore.license.readUInt32BE();
|
|
94
95
|
const licenseIndexEntry = await adminPeer.base.view.get(`${EntryType.LICENSE_INDEX}${licenseId}`);
|
|
95
96
|
t.ok(licenseIndexEntry, 'license index entry persists after re-whitelist');
|
|
96
|
-
const addressBuffer = addressUtils.addressToBuffer(validatorPeer.wallet.address);
|
|
97
|
+
const addressBuffer = addressUtils.addressToBuffer(validatorPeer.wallet.address, config.addressPrefix);
|
|
97
98
|
if (licenseIndexEntry?.value && addressBuffer) {
|
|
98
99
|
t.ok(
|
|
99
100
|
b4a.equals(licenseIndexEntry.value, addressBuffer),
|