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.
Files changed (187) hide show
  1. package/.github/workflows/publish.yml +8 -16
  2. package/msb.mjs +13 -25
  3. package/package.json +8 -4
  4. package/proto/network.proto +74 -0
  5. package/rpc/{create_server.mjs → create_server.js} +4 -4
  6. package/rpc/{handlers.mjs → handlers.js} +7 -7
  7. package/rpc/routes/{index.mjs → index.js} +1 -1
  8. package/rpc/routes/{v1.mjs → v1.js} +1 -1
  9. package/rpc/rpc_server.js +10 -0
  10. package/rpc/rpc_services.js +48 -7
  11. package/rpc/utils/{helpers.mjs → helpers.js} +1 -1
  12. package/src/config/config.js +137 -0
  13. package/src/config/env.js +63 -0
  14. package/src/core/network/Network.js +133 -119
  15. package/src/core/network/identity/NetworkWalletFactory.js +5 -6
  16. package/src/core/network/protocols/LegacyProtocol.js +67 -0
  17. package/src/core/network/protocols/NetworkMessages.js +48 -0
  18. package/src/core/network/protocols/ProtocolInterface.js +31 -0
  19. package/src/core/network/protocols/ProtocolSession.js +59 -0
  20. package/src/core/network/protocols/V1Protocol.js +64 -0
  21. package/src/core/network/protocols/legacy/NetworkMessageRouter.js +84 -0
  22. package/src/core/network/protocols/legacy/handlers/GetRequestHandler.js +53 -0
  23. package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +37 -0
  24. package/src/core/network/{messaging → protocols/legacy}/validators/ValidatorResponse.js +2 -2
  25. package/src/core/network/{messaging → protocols/legacy}/validators/base/BaseResponse.js +13 -6
  26. package/src/core/network/protocols/shared/handlers/RoleOperationHandler.js +88 -0
  27. package/src/core/network/protocols/shared/handlers/SubnetworkOperationHandler.js +93 -0
  28. package/src/core/network/protocols/shared/handlers/TransferOperationHandler.js +57 -0
  29. package/src/core/network/{messaging → protocols/shared}/handlers/base/BaseOperationHandler.js +21 -26
  30. package/src/core/network/{messaging → protocols/shared}/validators/PartialBootstrapDeployment.js +3 -3
  31. package/src/core/network/{messaging → protocols/shared}/validators/PartialRoleAccess.js +15 -12
  32. package/src/core/network/{messaging → protocols/shared}/validators/PartialTransaction.js +10 -11
  33. package/src/core/network/{messaging → protocols/shared}/validators/PartialTransfer.js +10 -7
  34. package/src/core/network/{messaging → protocols/shared}/validators/base/PartialOperation.js +40 -22
  35. package/src/core/network/protocols/v1/NetworkMessageRouter.js +15 -0
  36. package/src/core/network/services/ConnectionManager.js +13 -19
  37. package/src/core/network/services/MessageOrchestrator.js +10 -22
  38. package/src/core/network/services/TransactionPoolService.js +10 -10
  39. package/src/core/network/services/TransactionRateLimiterService.js +5 -3
  40. package/src/core/network/services/ValidatorObserverService.js +46 -21
  41. package/src/core/state/State.js +137 -141
  42. package/src/core/state/utils/address.js +18 -16
  43. package/src/core/state/utils/adminEntry.js +17 -16
  44. package/src/core/state/utils/deploymentEntry.js +15 -15
  45. package/src/core/state/utils/transaction.js +3 -95
  46. package/src/index.js +250 -325
  47. package/src/messages/network/v1/NetworkMessageBuilder.js +325 -0
  48. package/src/messages/network/v1/NetworkMessageDirector.js +137 -0
  49. package/src/messages/network/v1/networkMessageFactory.js +12 -0
  50. package/src/messages/state/ApplyStateMessageBuilder.js +661 -0
  51. package/src/messages/state/ApplyStateMessageDirector.js +516 -0
  52. package/src/messages/state/applyStateMessageFactory.js +12 -0
  53. package/src/utils/buffer.js +53 -1
  54. package/src/utils/check.js +21 -17
  55. package/src/utils/cli.js +0 -8
  56. package/src/utils/cliCommands.js +11 -11
  57. package/src/utils/constants.js +36 -24
  58. package/src/utils/fileUtils.js +1 -4
  59. package/src/utils/helpers.js +9 -20
  60. package/src/utils/migrationUtils.js +2 -2
  61. package/src/utils/normalizers.js +94 -11
  62. package/src/utils/protobuf/network.cjs +840 -0
  63. package/src/utils/protobuf/operationHelpers.js +10 -0
  64. package/tests/acceptance/v1/account/account.test.mjs +2 -2
  65. package/tests/acceptance/v1/balance/balance.test.mjs +1 -1
  66. package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +11 -2
  67. package/tests/acceptance/v1/rpc.test.mjs +10 -10
  68. package/tests/acceptance/v1/tx/tx.test.mjs +4 -2
  69. package/tests/acceptance/v1/tx-details/tx-details.test.mjs +7 -3
  70. package/tests/fixtures/check.fixtures.js +42 -42
  71. package/tests/fixtures/networkV1.fixtures.js +84 -0
  72. package/tests/fixtures/protobuf.fixtures.js +110 -26
  73. package/tests/helpers/StateNetworkFactory.js +3 -5
  74. package/tests/helpers/autobaseTestHelpers.js +1 -2
  75. package/tests/helpers/config.js +3 -0
  76. package/tests/helpers/setupApplyTests.js +113 -99
  77. package/tests/helpers/transactionPayloads.mjs +26 -12
  78. package/tests/unit/messages/messages.test.js +12 -0
  79. package/tests/unit/messages/network/NetworkMessageBuilder.test.js +276 -0
  80. package/tests/unit/messages/network/NetworkMessageDirector.test.js +203 -0
  81. package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +521 -0
  82. package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +233 -0
  83. package/tests/unit/network/ConnectionManager.test.js +10 -7
  84. package/tests/unit/network/NetworkWalletFactory.test.js +14 -14
  85. package/tests/unit/network/networkModule.test.js +3 -2
  86. package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +10 -6
  87. package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +11 -8
  88. package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +11 -7
  89. package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +18 -20
  90. package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +57 -48
  91. package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +2 -1
  92. package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +72 -57
  93. package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +3 -7
  94. package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +12 -14
  95. package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +18 -13
  96. package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js +2 -1
  97. package/tests/unit/state/apply/banValidator/banValidatorBanAndReWhitelistScenario.js +2 -1
  98. package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +27 -30
  99. package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +2 -1
  100. package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +24 -21
  101. package/tests/unit/state/apply/common/access-control/adminConsistencyMismatchScenario.js +5 -4
  102. package/tests/unit/state/apply/common/access-control/adminPublicKeyDecodeFailureScenario.js +4 -3
  103. package/tests/unit/state/apply/common/balances/base/requesterBalanceScenarioBase.js +2 -1
  104. package/tests/unit/state/apply/common/commonScenarioHelper.js +16 -16
  105. package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +10 -5
  106. package/tests/unit/state/apply/common/payload-structure/invalidHashValidationScenario.js +2 -2
  107. package/tests/unit/state/apply/common/requester/requesterNodeEntryBufferMissingScenario.js +2 -1
  108. package/tests/unit/state/apply/common/requester/requesterNodeEntryDecodeFailureScenario.js +2 -1
  109. package/tests/unit/state/apply/common/validatorConsistency/base/validatorConsistencyScenarioBase.js +2 -1
  110. package/tests/unit/state/apply/common/validatorEntryValidation/base/validatorEntryValidationScenarioBase.js +2 -1
  111. package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +16 -9
  112. package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +6 -5
  113. package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +23 -19
  114. package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +45 -36
  115. package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +48 -45
  116. package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +32 -29
  117. package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardScenarioFactory.js +2 -1
  118. package/tests/unit/state/stateModule.test.js +0 -1
  119. package/tests/unit/state/stateTestUtils.js +7 -3
  120. package/tests/unit/state/utils/address.test.js +3 -3
  121. package/tests/unit/state/utils/adminEntry.test.js +10 -9
  122. package/tests/unit/unit.test.js +1 -1
  123. package/tests/unit/utils/buffer/buffer.test.js +62 -1
  124. package/tests/unit/utils/check/adminControlOperation.test.js +3 -3
  125. package/tests/unit/utils/check/balanceInitializationOperation.test.js +2 -2
  126. package/tests/unit/utils/check/bootstrapDeploymentOperation.test.js +2 -3
  127. package/tests/unit/utils/check/common.test.js +7 -6
  128. package/tests/unit/utils/check/coreAdminOperation.test.js +3 -3
  129. package/tests/unit/utils/check/roleAccessOperation.test.js +3 -2
  130. package/tests/unit/utils/check/transactionOperation.test.js +3 -3
  131. package/tests/unit/utils/check/transferOperation.test.js +3 -3
  132. package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +2 -1
  133. package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +2 -1
  134. package/tests/unit/utils/migrationUtils/validateAddressFromIncomingFile.test.js +7 -0
  135. package/tests/unit/utils/normalizers/normalizers.test.js +469 -0
  136. package/tests/unit/utils/protobuf/operationHelpers.test.js +120 -2
  137. package/tests/unit/utils/utils.test.js +0 -1
  138. package/rpc/rpc_server.mjs +0 -10
  139. package/src/core/network/messaging/NetworkMessages.js +0 -63
  140. package/src/core/network/messaging/handlers/GetRequestHandler.js +0 -112
  141. package/src/core/network/messaging/handlers/ResponseHandler.js +0 -108
  142. package/src/core/network/messaging/handlers/RoleOperationHandler.js +0 -116
  143. package/src/core/network/messaging/handlers/SubnetworkOperationHandler.js +0 -143
  144. package/src/core/network/messaging/handlers/TransferOperationHandler.js +0 -52
  145. package/src/core/network/messaging/routes/NetworkMessageRouter.js +0 -94
  146. package/src/core/network/messaging/validators/AdminResponse.js +0 -58
  147. package/src/core/network/messaging/validators/CustomNodeResponse.js +0 -46
  148. package/src/core/state/utils/indexerEntry.js +0 -105
  149. package/src/messages/base/StateBuilder.js +0 -25
  150. package/src/messages/completeStateMessages/CompleteStateMessageBuilder.js +0 -421
  151. package/src/messages/completeStateMessages/CompleteStateMessageDirector.js +0 -252
  152. package/src/messages/completeStateMessages/CompleteStateMessageOperations.js +0 -299
  153. package/src/messages/partialStateMessages/PartialStateMessageBuilder.js +0 -272
  154. package/src/messages/partialStateMessages/PartialStateMessageDirector.js +0 -137
  155. package/src/messages/partialStateMessages/PartialStateMessageOperations.js +0 -131
  156. package/src/utils/crypto.js +0 -11
  157. package/tests/integration/apply/addAdmin/addAdminBasic.test.js +0 -68
  158. package/tests/integration/apply/addAdmin/addAdminRecovery.test.js +0 -125
  159. package/tests/integration/apply/addIndexer.test.js +0 -237
  160. package/tests/integration/apply/addWhitelist.test.js +0 -53
  161. package/tests/integration/apply/addWriter.test.js +0 -244
  162. package/tests/integration/apply/apply.test.js +0 -19
  163. package/tests/integration/apply/banValidator.test.js +0 -109
  164. package/tests/integration/apply/postTx/invalidSubValues.test.js +0 -103
  165. package/tests/integration/apply/postTx/postTx.test.js +0 -222
  166. package/tests/integration/apply/removeIndexer.test.js +0 -128
  167. package/tests/integration/apply/removeWriter.test.js +0 -167
  168. package/tests/integration/apply/transfer.test.js +0 -81
  169. package/tests/integration/integration.test.js +0 -9
  170. package/tests/unit/messageOperations/assembleAddIndexerMessage.test.js +0 -21
  171. package/tests/unit/messageOperations/assembleAddWriterMessage.test.js +0 -16
  172. package/tests/unit/messageOperations/assembleAdminMessage.test.js +0 -69
  173. package/tests/unit/messageOperations/assembleBanWriterMessage.test.js +0 -16
  174. package/tests/unit/messageOperations/assemblePostTransaction.test.js +0 -442
  175. package/tests/unit/messageOperations/assembleRemoveIndexerMessage.test.js +0 -19
  176. package/tests/unit/messageOperations/assembleRemoveWriterMessage.test.js +0 -17
  177. package/tests/unit/messageOperations/assembleWhitelistMessages.test.js +0 -58
  178. package/tests/unit/messageOperations/commonsStateMessageOperationsTest.js +0 -277
  179. package/tests/unit/messageOperations/stateMessageOperations.test.js +0 -19
  180. package/tests/unit/state/utils/indexerEntry.test.js +0 -83
  181. package/tests/unit/state/utils/transaction.test.js +0 -97
  182. package/tests/unit/utils/crypto/createHash.test.js +0 -15
  183. /package/rpc/{constants.mjs → constants.js} +0 -0
  184. /package/rpc/{cors.mjs → cors.js} +0 -0
  185. /package/rpc/utils/{confirmedParameter.mjs → confirmedParameter.js} +0 -0
  186. /package/rpc/utils/{url.mjs → url.js} +0 -0
  187. /package/src/utils/{operations.js → applyOperations.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import applyOperations from './applyOperations.cjs';
2
+ import networkV1Operations from './network.cjs';
2
3
  import b4a from 'b4a';
3
4
 
4
5
  /**
@@ -48,3 +49,12 @@ export const normalizeIncomingMessage = (message) => {
48
49
 
49
50
  return null;
50
51
  };
52
+
53
+ export const encodeV1networkOperation = (payload) => {
54
+ return networkV1Operations.MessageHeader.encode(payload);
55
+ }
56
+
57
+
58
+ export const decodeV1networkOperation = (payload) => {
59
+ return networkV1Operations.MessageHeader.decode(payload);
60
+ }
@@ -1,6 +1,6 @@
1
1
  import request from "supertest"
2
2
  import { bufferToBigInt, licenseBufferToBigInt } from "../../../../src/utils/amountSerialization.js"
3
- import { ZERO_WK } from "../../../../rpc/constants.mjs"
3
+ import { ZERO_WK } from "../../../../rpc/constants.js"
4
4
  import { ADMIN_INITIAL_STAKED_BALANCE } from "../../../../src/utils/constants.js"
5
5
  import { BALANCE_TO_STAKE } from "../../../../src/core/state/utils/balance.js"
6
6
  import { randomAddress } from "../../../unit/state/stateTestUtils.js"
@@ -72,7 +72,7 @@ export const registerAccountTests = (context) => {
72
72
  })
73
73
 
74
74
  it("returns default state for non-existent node", async () => {
75
- const address = randomAddress()
75
+ const address = randomAddress(context.rpcMsb.config.addressPrefix)
76
76
 
77
77
  const res = await request(context.server).get(`/v1/account/${address}`)
78
78
  expect(res.statusCode).toBe(200)
@@ -37,7 +37,7 @@ export const registerBalanceTests = (context) => {
37
37
  })
38
38
 
39
39
  it("returns zero balance for an unknown address", async () => {
40
- const address = randomAddress()
40
+ const address = randomAddress(context.rpcMsb.config.addressPrefix)
41
41
  const res = await request(context.server).get(`/v1/balance/${address}`)
42
42
  expect(res.statusCode).toBe(200)
43
43
  expect(res.body.address).toBe(address)
@@ -1,7 +1,7 @@
1
1
  import request from "supertest"
2
2
  import b4a from "b4a"
3
3
  import { $TNK } from "../../../../src/core/state/utils/balance.js"
4
- import { buildRpcSelfTransferPayload } from "../../../helpers/transactionPayloads.mjs"
4
+ import { buildRpcSelfTransferPayload, waitForConnection } from "../../../helpers/transactionPayloads.mjs"
5
5
 
6
6
  const toBase64 = (value) => b4a.toString(b4a.from(JSON.stringify(value)), "base64")
7
7
 
@@ -9,10 +9,11 @@ export const registerBroadcastTransactionTests = (context) => {
9
9
  describe("POST /v1/broadcast-transaction", () => {
10
10
  it("broadcasts transaction and returns lengths", async () => {
11
11
  const { payload } = await buildRpcSelfTransferPayload(
12
- context.wallet,
12
+ context,
13
13
  context.rpcMsb.state,
14
14
  1n
15
15
  );
16
+ await waitForConnection(context.rpcMsb)
16
17
  const res = await request(context.server)
17
18
  .post("/v1/broadcast-transaction")
18
19
  .set("Accept", "application/json")
@@ -30,6 +31,7 @@ export const registerBroadcastTransactionTests = (context) => {
30
31
  })
31
32
 
32
33
  it("returns 400 when payload is missing", async () => {
34
+ await waitForConnection(context.rpcMsb)
33
35
  const res = await request(context.server)
34
36
  .post("/v1/broadcast-transaction")
35
37
  .set("Accept", "application/json")
@@ -40,6 +42,7 @@ export const registerBroadcastTransactionTests = (context) => {
40
42
  })
41
43
 
42
44
  it("returns 400 when payload is not base64", async () => {
45
+ await waitForConnection(context.rpcMsb)
43
46
  const res = await request(context.server)
44
47
  .post("/v1/broadcast-transaction")
45
48
  .set("Accept", "application/json")
@@ -52,6 +55,8 @@ export const registerBroadcastTransactionTests = (context) => {
52
55
  // TODO: enable once handler returns 400 for client-side decode errors
53
56
  it.skip("returns 400 when decoded payload is not valid JSON", async () => {
54
57
  const invalidJsonBase64 = b4a.toString(b4a.from("{{invalid"), "base64")
58
+
59
+ await waitForConnection(context.rpcMsb)
55
60
  const res = await request(context.server)
56
61
  .post("/v1/broadcast-transaction")
57
62
  .set("Accept", "application/json")
@@ -67,6 +72,8 @@ export const registerBroadcastTransactionTests = (context) => {
67
72
  type: 1,
68
73
  address: context.wallet.address,
69
74
  }
75
+
76
+ await waitForConnection(context.rpcMsb)
70
77
  const res = await request(context.server)
71
78
  .post("/v1/broadcast-transaction")
72
79
  .set("Accept", "application/json")
@@ -81,6 +88,7 @@ export const registerBroadcastTransactionTests = (context) => {
81
88
  const largeString = "a".repeat(3_000_000)
82
89
  const payload = toBase64({ type: 1, address: context.wallet.address, txo: { large: largeString } })
83
90
 
91
+ await waitForConnection(context.rpcMsb)
84
92
  const res = await request(context.server)
85
93
  .post("/v1/broadcast-transaction")
86
94
  .set("Accept", "application/json")
@@ -99,6 +107,7 @@ export const registerBroadcastTransactionTests = (context) => {
99
107
  )
100
108
 
101
109
  const payload = tracCrypto.transaction.build(txData, b4a.from(context.wallet.secretKey, 'hex'))
110
+ await waitForConnection(context.rpcMsb)
102
111
  const res = await request(context.server)
103
112
  .post("/v1/broadcast-transaction")
104
113
  .set("Accept", "application/json")
@@ -1,4 +1,4 @@
1
- import { createServer } from "../../../rpc/create_server.mjs"
1
+ import { createServer } from "../../../rpc/create_server.js"
2
2
  import { initTemporaryDirectory } from '../../helpers/setupApplyTests.js'
3
3
  import { testKeyPair1, testKeyPair2, testKeyPair3 } from '../../fixtures/apply.fixtures.js'
4
4
  import { randomBytes, setupMsbAdmin, setupMsbWriter, removeTemporaryDirectory, setupMsbPeer, tryToSyncWriters, waitForNodeState } from "../../helpers/setupApplyTests.js"
@@ -31,14 +31,14 @@ const setupNetwork = async () => {
31
31
  const rpcOpts = {
32
32
  bootstrap: randomBytes(32).toString('hex'),
33
33
  channel: randomBytes(32).toString('hex'),
34
- enable_role_requester: false,
35
- enable_wallet: true,
36
- enable_validator_observer: true,
37
- enable_interactive_mode: false,
38
- disable_rate_limit: true,
39
- enable_tx_apply_logs: false,
40
- stores_directory: `${tmpDirectory}/stores/`,
41
- store_name: '/admin'
34
+ enableRoleRequester: false,
35
+ enableWallet: true,
36
+ enableValidatorObserver: true,
37
+ enableInteractiveMode: false,
38
+ disableRateLimit: true,
39
+ enableTxApplyLogs: false,
40
+ storesDirectory: `${tmpDirectory}/stores/`,
41
+ storeName: '/admin'
42
42
  }
43
43
 
44
44
  const admin = await setupMsbAdmin(testKeyPair1, tmpDirectory, rpcOpts)
@@ -58,7 +58,7 @@ const setupNetwork = async () => {
58
58
 
59
59
  beforeAll(async () => {
60
60
  const { admin, writer, reader } = await setupNetwork()
61
- const server = createServer(reader.msb)
61
+ const server = createServer(reader.msb, reader.config)
62
62
  toClose = admin.msb
63
63
  Object.assign(testContext, {
64
64
  writerMsb: writer.msb,
@@ -1,14 +1,16 @@
1
1
  import request from "supertest"
2
- import { buildRpcSelfTransferPayload } from "../../../helpers/transactionPayloads.mjs"
2
+ import { buildRpcSelfTransferPayload, waitForConnection } from "../../../helpers/transactionPayloads.mjs"
3
3
 
4
4
  export const registerTxTests = (context) => {
5
5
  describe("GET /v1/tx/:hash", () => {
6
6
  it("returns tx details for a broadcasted transaction", async () => {
7
7
  const { payload, txHashHex } = await buildRpcSelfTransferPayload(
8
- context.wallet,
8
+ context,
9
9
  context.rpcMsb.state,
10
10
  1n
11
11
  );
12
+
13
+ await waitForConnection(context.rpcMsb)
12
14
  const broadcastRes = await request(context.server)
13
15
  .post("/v1/broadcast-transaction")
14
16
  .set("Accept", "application/json")
@@ -1,14 +1,16 @@
1
1
  import request from "supertest"
2
- import { buildRpcSelfTransferPayload } from "../../../helpers/transactionPayloads.mjs"
2
+ import { buildRpcSelfTransferPayload, waitForConnection } from "../../../helpers/transactionPayloads.mjs"
3
3
 
4
4
  export const registerTxDetailsTests = (context) => {
5
5
  describe("GET /v1/tx/details", () => {
6
6
  it("returns 200 for broadcasted hash (confirmed and unconfirmed)", async () => {
7
7
  const { payload, txHashHex } = await buildRpcSelfTransferPayload(
8
- context.wallet,
8
+ context,
9
9
  context.rpcMsb.state,
10
10
  1n
11
11
  );
12
+
13
+ await waitForConnection(context.rpcMsb)
12
14
  const broadcastRes = await request(context.server)
13
15
  .post("/v1/broadcast-transaction")
14
16
  .set("Accept", "application/json")
@@ -38,7 +40,7 @@ export const registerTxDetailsTests = (context) => {
38
40
 
39
41
  it("handles null confirmed_length for unconfirmed transaction", async () => {
40
42
  const { payload, txHashHex } = await buildRpcSelfTransferPayload(
41
- context.wallet,
43
+ context,
42
44
  context.rpcMsb.state,
43
45
  1n
44
46
  );
@@ -47,6 +49,8 @@ export const registerTxDetailsTests = (context) => {
47
49
  context.rpcMsb.state.getTransactionConfirmedLength = async () => null
48
50
 
49
51
  try {
52
+
53
+ await waitForConnection(context.rpcMsb)
50
54
  const broadcastRes = await request(context.server)
51
55
  .post("/v1/broadcast-transaction")
52
56
  .set("Accept", "application/json")
@@ -7,36 +7,36 @@ import {
7
7
  WRITER_BYTE_LENGTH,
8
8
  BOOTSTRAP_BYTE_LENGTH,
9
9
  NONCE_BYTE_LENGTH,
10
- OperationType, AMOUNT_BYTE_LENGTH,
11
- TRAC_ADDRESS_SIZE
10
+ OperationType, AMOUNT_BYTE_LENGTH
12
11
  } from '../../src/utils/constants.js';
12
+ import { config } from '../helpers/config.js'
13
13
 
14
14
  export const TRO = {
15
15
  valid_partial_transfer: {
16
16
  type: OperationType.TRANSFER,
17
- address: addressToBuffer('trac123z3gfpr2epjwww7ntm3m6ud2fhmq0tvts27p2f5mx3qkecsutlqfys769'),
17
+ address: addressToBuffer('trac123z3gfpr2epjwww7ntm3m6ud2fhmq0tvts27p2f5mx3qkecsutlqfys769', config.addressPrefix),
18
18
  tro: {
19
19
  tx: b4a.from('c59f70942febb1de32fcb59febe84560416265d39f39b48fae676592910a98f4', 'hex'),
20
20
  txv: b4a.from('eb59a3e756d1c9597e46b33bcea91e262f8f73e94c238bdf70854aa2e8c42608', 'hex'),
21
21
  in: b4a.from('863fef21f5146553b0396b2ee1a93a8dbfce240411b71ccdcfc504504a6b9b50', 'hex'),
22
- to: addressToBuffer('trac1mqktwme8fvklrds4hlhfy6lhmsu9qgfn3c3kuhz7c5zwjt8rc3dqj9tx7h'),
22
+ to: addressToBuffer('trac1mqktwme8fvklrds4hlhfy6lhmsu9qgfn3c3kuhz7c5zwjt8rc3dqj9tx7h', config.addressPrefix),
23
23
  am: b4a.from('00000000000000015af1d78b58c40001', 'hex'),
24
24
  is: b4a.from('06acd7faecd5159221259ebb1d7e98eccd7c6e2884de9de45097e6d9d8c37192602901c74dde6bb2f48f6f665edc84140627f6e9c42f774a0e9f55ef3b348e06', 'hex')
25
25
  }
26
26
  },
27
27
  valid_complete_transfer: {
28
28
  type: OperationType.TRANSFER,
29
- address: addressToBuffer('trac123z3gfpr2epjwww7ntm3m6ud2fhmq0tvts27p2f5mx3qkecsutlqfys769'),
29
+ address: addressToBuffer('trac123z3gfpr2epjwww7ntm3m6ud2fhmq0tvts27p2f5mx3qkecsutlqfys769', config.addressPrefix),
30
30
  tro: {
31
31
  tx: b4a.from('c59f70942febb1de32fcb59febe84560416265d39f39b48fae676592910a98f4', 'hex'),
32
32
  txv: b4a.from('eb59a3e756d1c9597e46b33bcea91e262f8f73e94c238bdf70854aa2e8c42608', 'hex'),
33
33
  in: b4a.from('863fef21f5146553b0396b2ee1a93a8dbfce240411b71ccdcfc504504a6b9b50', 'hex'),
34
- to: addressToBuffer('trac1mqktwme8fvklrds4hlhfy6lhmsu9qgfn3c3kuhz7c5zwjt8rc3dqj9tx7h'),
34
+ to: addressToBuffer('trac1mqktwme8fvklrds4hlhfy6lhmsu9qgfn3c3kuhz7c5zwjt8rc3dqj9tx7h', config.addressPrefix),
35
35
  am: b4a.from('00000000000000015af1d78b58c40001', 'hex'),
36
36
  is: b4a.from('06acd7faecd5159221259ebb1d7e98eccd7c6e2884de9de45097e6d9d8c37192602901c74dde6bb2f48f6f665edc84140627f6e9c42f774a0e9f55ef3b348e06', 'hex'),
37
37
  vn: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
38
38
  vs: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
39
- va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
39
+ va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
40
40
  }
41
41
  },
42
42
  top_fields_transfer: ['type', 'address', 'tro'],
@@ -46,19 +46,19 @@ export const TRO = {
46
46
  tx: HASH_BYTE_LENGTH,
47
47
  txv: HASH_BYTE_LENGTH,
48
48
  in: NONCE_BYTE_LENGTH,
49
- to: TRAC_ADDRESS_SIZE,
49
+ to: config.addressLength,
50
50
  am: AMOUNT_BYTE_LENGTH,
51
51
  },
52
52
  required_length_of_fields_for_complete_transfer: {
53
53
  tx: HASH_BYTE_LENGTH,
54
54
  txv: HASH_BYTE_LENGTH,
55
55
  in: NONCE_BYTE_LENGTH,
56
- to: TRAC_ADDRESS_SIZE,
56
+ to: config.addressLength,
57
57
  am: AMOUNT_BYTE_LENGTH,
58
58
  is: SIGNATURE_BYTE_LENGTH,
59
59
  vn: NONCE_BYTE_LENGTH,
60
60
  vs: SIGNATURE_BYTE_LENGTH,
61
- va: TRAC_ADDRESS_SIZE
61
+ va: config.addressLength
62
62
  },
63
63
 
64
64
  }
@@ -66,7 +66,7 @@ export const TRO = {
66
66
  export const BDO = {
67
67
  valid_partial_bootstrap_deployment: {
68
68
  type: OperationType.BOOTSTRAP_DEPLOYMENT,
69
- address: addressToBuffer("trac1cep6jwcf02vmwekr4s0sttraqv736v8nf2gkaejz2203zhf7j7csnf44nm"),
69
+ address: addressToBuffer("trac1cep6jwcf02vmwekr4s0sttraqv736v8nf2gkaejz2203zhf7j7csnf44nm", config.addressPrefix),
70
70
  bdo: {
71
71
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
72
72
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -79,7 +79,7 @@ export const BDO = {
79
79
 
80
80
  valid_complete_bootstrap_deployment: {
81
81
  type: OperationType.BOOTSTRAP_DEPLOYMENT,
82
- address: addressToBuffer("trac1cep6jwcf02vmwekr4s0sttraqv736v8nf2gkaejz2203zhf7j7csnf44nm"),
82
+ address: addressToBuffer("trac1cep6jwcf02vmwekr4s0sttraqv736v8nf2gkaejz2203zhf7j7csnf44nm", config.addressPrefix),
83
83
  bdo: {
84
84
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
85
85
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -87,7 +87,7 @@ export const BDO = {
87
87
  ic: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
88
88
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
89
89
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
90
- va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
90
+ va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
91
91
  vn: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
92
92
  vs: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
93
93
  }
@@ -104,7 +104,7 @@ export const BDO = {
104
104
  is: SIGNATURE_BYTE_LENGTH,
105
105
  vn: NONCE_BYTE_LENGTH,
106
106
  vs: SIGNATURE_BYTE_LENGTH,
107
- va: TRAC_ADDRESS_SIZE
107
+ va: config.addressLength
108
108
  },
109
109
  required_length_of_fields_for_partial_bootstrap_deployment: {
110
110
  tx: HASH_BYTE_LENGTH,
@@ -118,7 +118,7 @@ export const BDO = {
118
118
  export const TXO = {
119
119
  valid_complete_transaction_operation: {
120
120
  type: OperationType.TX,
121
- address: addressToBuffer('trac1c232xtkvyg08zyeurn7l0wrarc4y36fzq5vhcdsgkxe6hdpzuslsm63dw8'),
121
+ address: addressToBuffer('trac1c232xtkvyg08zyeurn7l0wrarc4y36fzq5vhcdsgkxe6hdpzuslsm63dw8', config.addressPrefix),
122
122
  txo: {
123
123
  tx: b4a.from('6fb7f6e7f6970477977080f2b46cc837d48605e67691d30bf7511a1417d17ed7', 'hex'),
124
124
  txv: b4a.from('6fb7f6e7f6970477977080f2b46cc837d48605e67691d30bf7511a1417d17ed7', 'hex'),
@@ -130,12 +130,12 @@ export const TXO = {
130
130
  mbs: b4a.from('5f3b9a6a516066de365e5e75a7ac0feb55ab7cd4a29facbb028a047fc3f3956e', 'hex'),
131
131
  vn: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
132
132
  vs: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
133
- va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
133
+ va: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
134
134
  }
135
135
  },
136
136
  valid_partial_transaction_operation: {
137
137
  type: OperationType.TX,
138
- address: addressToBuffer('trac1c232xtkvyg08zyeurn7l0wrarc4y36fzq5vhcdsgkxe6hdpzuslsm63dw8'),
138
+ address: addressToBuffer('trac1c232xtkvyg08zyeurn7l0wrarc4y36fzq5vhcdsgkxe6hdpzuslsm63dw8', config.addressPrefix),
139
139
  txo: {
140
140
  tx: b4a.from('6fb7f6e7f6970477977080f2b46cc837d48605e67691d30bf7511a1417d17ed7', 'hex'),
141
141
  txv: b4a.from('6fb7f6e7f6970477977080f2b46cc837d48605e67691d30bf7511a1417d17ed7', 'hex'),
@@ -162,7 +162,7 @@ export const TXO = {
162
162
  mbs: BOOTSTRAP_BYTE_LENGTH,
163
163
  vn: NONCE_BYTE_LENGTH,
164
164
  vs: SIGNATURE_BYTE_LENGTH,
165
- va: TRAC_ADDRESS_SIZE
165
+ va: config.addressLength
166
166
 
167
167
  },
168
168
  required_length_of_fields_for_partial_transaction_operation: {
@@ -181,7 +181,7 @@ export const TXO = {
181
181
  export const CAO = {
182
182
  validAddAdminOperation: {
183
183
  type: OperationType.ADD_ADMIN,
184
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
184
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
185
185
  cao: {
186
186
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
187
187
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -192,7 +192,7 @@ export const CAO = {
192
192
  },
193
193
  validDisableInitializationOperation: {
194
194
  type: OperationType.DISABLE_INITIALIZATION,
195
- address: addressToBuffer('trac1sq3njyxzd27rsy8zcksgv2jmcsl9dlsmklwwqruhx92dufs3cemqgyrpf7'),
195
+ address: addressToBuffer('trac1sq3njyxzd27rsy8zcksgv2jmcsl9dlsmklwwqruhx92dufs3cemqgyrpf7', config.addressPrefix),
196
196
  cao: {
197
197
  tx: b4a.from('0fc518b31505d163a696555df8dceae415032773f85e578a9a1810ad5c99cf0c', 'hex'),
198
198
  txv: b4a.from('dd6b3809673cbca08ee60c32971e9ed9d39fb962c53ab8ef49cd6b467d6977f3', 'hex'),
@@ -215,48 +215,48 @@ export const CAO = {
215
215
  export const ACO = {
216
216
  validAppendWhitelistOperation: {
217
217
  type: OperationType.APPEND_WHITELIST,
218
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
218
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
219
219
  aco: {
220
220
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
221
221
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
222
222
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
223
- ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
223
+ ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
224
224
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex')
225
225
  }
226
226
  },
227
227
 
228
228
  validAddIndexerOperation: {
229
229
  type: OperationType.ADD_INDEXER,
230
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
230
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
231
231
  aco: {
232
232
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
233
233
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
234
234
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
235
- ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
235
+ ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
236
236
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex')
237
237
  }
238
238
  },
239
239
 
240
240
  validRemoveIndexerOperation: {
241
241
  type: OperationType.REMOVE_INDEXER,
242
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
242
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
243
243
  aco: {
244
244
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
245
245
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
246
246
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
247
- ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
247
+ ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
248
248
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex')
249
249
  }
250
250
  },
251
251
 
252
252
  validBanValidatorOperation: {
253
253
  type: OperationType.BAN_VALIDATOR,
254
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
254
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
255
255
  aco: {
256
256
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
257
257
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
258
258
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
259
- ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
259
+ ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
260
260
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex')
261
261
  }
262
262
  },
@@ -267,7 +267,7 @@ export const ACO = {
267
267
  tx: HASH_BYTE_LENGTH,
268
268
  txv: HASH_BYTE_LENGTH,
269
269
  in: NONCE_BYTE_LENGTH,
270
- ia: TRAC_ADDRESS_SIZE,
270
+ ia: config.addressLength,
271
271
  is: SIGNATURE_BYTE_LENGTH
272
272
  }
273
273
  };
@@ -275,21 +275,21 @@ export const ACO = {
275
275
  export const RAO = {
276
276
  valid_complete_add_writer: {
277
277
  type: OperationType.ADD_WRITER,
278
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
278
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
279
279
  rao: {
280
280
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
281
281
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
282
282
  iw: b4a.from('71c53657a8738b48772f0940398d4f4b01dc56cb32cd2fd84c30359f0cbb08f1', 'hex'),
283
283
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
284
284
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
285
- va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
285
+ va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
286
286
  vn: b4a.from('9027192c6de13b683bc0c0fbcfe09c4e55d47c12c46b122d988f06c282a4be5e', 'hex'),
287
287
  vs: b4a.from('8fb8a3ba30e00c347bca5a8554c47e167f63b248c87e1ea5532eebbad1bc036184fe8872ff65a9e63acfee68d2213a187466c13ff6687d3ab57e5209abd4fb01', 'hex')
288
288
  }
289
289
  },
290
290
  valid_partial_add_writer: {
291
291
  type: OperationType.ADD_WRITER,
292
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
292
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
293
293
  rao: {
294
294
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
295
295
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -302,21 +302,21 @@ export const RAO = {
302
302
 
303
303
  valid_complete_remove_writer: {
304
304
  type: OperationType.REMOVE_WRITER,
305
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
305
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
306
306
  rao: {
307
307
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
308
308
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
309
309
  iw: b4a.from('71c53657a8738b48772f0940398d4f4b01dc56cb32cd2fd84c30359f0cbb08f1', 'hex'),
310
310
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
311
311
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
312
- va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
312
+ va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
313
313
  vn: b4a.from('9027192c6de13b683bc0c0fbcfe09c4e55d47c12c46b122d988f06c282a4be5e', 'hex'),
314
314
  vs: b4a.from('8fb8a3ba30e00c347bca5a8554c47e167f63b248c87e1ea5532eebbad1bc036184fe8872ff65a9e63acfee68d2213a187466c13ff6687d3ab57e5209abd4fb01', 'hex')
315
315
  }
316
316
  },
317
317
  valid_partial_remove_writer: {
318
318
  type: OperationType.REMOVE_WRITER,
319
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
319
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
320
320
  rao: {
321
321
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
322
322
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -327,21 +327,21 @@ export const RAO = {
327
327
  },
328
328
  valid_complete_admin_recovery: {
329
329
  type: OperationType.ADMIN_RECOVERY,
330
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
330
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
331
331
  rao: {
332
332
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
333
333
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
334
334
  iw: b4a.from('71c53657a8738b48772f0940398d4f4b01dc56cb32cd2fd84c30359f0cbb08f1', 'hex'),
335
335
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
336
336
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex'),
337
- va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
337
+ va: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
338
338
  vn: b4a.from('9027192c6de13b683bc0c0fbcfe09c4e55d47c12c46b122d988f06c282a4be5e', 'hex'),
339
339
  vs: b4a.from('8fb8a3ba30e00c347bca5a8554c47e167f63b248c87e1ea5532eebbad1bc036184fe8872ff65a9e63acfee68d2213a187466c13ff6687d3ab57e5209abd4fb01', 'hex')
340
340
  }
341
341
  },
342
342
  valid_partial_admin_recovery: {
343
343
  type: OperationType.ADMIN_RECOVERY,
344
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
344
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
345
345
  rao: {
346
346
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
347
347
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
@@ -360,7 +360,7 @@ export const RAO = {
360
360
  iw: WRITER_BYTE_LENGTH,
361
361
  in: NONCE_BYTE_LENGTH,
362
362
  is: SIGNATURE_BYTE_LENGTH,
363
- va: TRAC_ADDRESS_SIZE,
363
+ va: config.addressLength,
364
364
  vn: NONCE_BYTE_LENGTH,
365
365
  vs: SIGNATURE_BYTE_LENGTH
366
366
  },
@@ -378,12 +378,12 @@ export const RAO = {
378
378
  export const BIO = {
379
379
  valid_balance_initialization_operation: {
380
380
  type: OperationType.BALANCE_INITIALIZATION,
381
- address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p'),
381
+ address: addressToBuffer('trac18qq7h503y3326v6msgvq0jwc0e8jp4t4q53z9p9jvd98arj7mtpqfac04p', config.addressPrefix),
382
382
  bio: {
383
383
  tx: b4a.from('1bd4f96adeffba9c04943a82993c5b19660c3a5f572620d82a67464f381640e2', 'hex'),
384
384
  txv: b4a.from('f24e61cf7941256b080be2133bccb520414c78021215edfcb781622da526c414', 'hex'),
385
385
  in: b4a.from('0ad7fe36a35a27ea4df932b800200823a97d4db31bca247f43ad7523b0493645', 'hex'),
386
- ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc'),
386
+ ia: addressToBuffer('trac1xvqvlzx4w2q2pfqrmycew87kq4rv0q0cewxk68ddvddgk2xm09cqvpc4jc', config.addressPrefix),
387
387
  am: b4a.from('00000000000000015af1d78b58c40001', 'hex'),
388
388
  is: b4a.from('5b534be7a374148962c271d194c26cf5b1ad705ab218a87709a33fe74f9d1b811772447c939b17b2f803e3da7648f49b666b929fbb20e458ced952f147162c08', 'hex')
389
389
  }
@@ -395,7 +395,7 @@ export const BIO = {
395
395
  tx: HASH_BYTE_LENGTH,
396
396
  txv: HASH_BYTE_LENGTH,
397
397
  in: NONCE_BYTE_LENGTH,
398
- ia: TRAC_ADDRESS_SIZE,
398
+ ia: config.addressLength,
399
399
  am: AMOUNT_BYTE_LENGTH,
400
400
  is: SIGNATURE_BYTE_LENGTH
401
401
  }
@@ -0,0 +1,84 @@
1
+ import b4a from 'b4a';
2
+ import { v7 as uuidv7 } from 'uuid';
3
+ import { NetworkOperationType, ResultCode as NetworkResultCode } from '../../src/utils/constants.js';
4
+
5
+ const payloadValidatorConnectionRequest = {
6
+ type: NetworkOperationType.VALIDATOR_CONNECTION_REQUEST,
7
+ id: uuidv7(),
8
+ timestamp: 123,
9
+ validator_connection_request: {
10
+ issuer_address: 'trac1xm76l9qaujh7vqktk8302mw9sfrxau3l45w62hqfl4kasswt6yts0autkh',
11
+ nonce: b4a.from('00', 'hex'),
12
+ signature: b4a.from('01', 'hex')
13
+ },
14
+ capabilities: ['cap:a', 'cap:b']
15
+ };
16
+
17
+ const payloadValidatorConnectionResponse = {
18
+ type: NetworkOperationType.VALIDATOR_CONNECTION_RESPONSE,
19
+ id: uuidv7(),
20
+ timestamp: 456,
21
+ validator_connection_response: {
22
+ issuer_address: 'trac1xm76l9qaujh7vqktk8302mw9sfrxau3l45w62hqfl4kasswt6yts0autkh',
23
+ nonce: b4a.from('02', 'hex'),
24
+ signature: b4a.from('03', 'hex'),
25
+ result: NetworkResultCode.OK
26
+ },
27
+ capabilities: ['cap:a']
28
+ };
29
+
30
+ const payloadLivenessRequest = {
31
+ type: NetworkOperationType.LIVENESS_REQUEST,
32
+ id: uuidv7(),
33
+ timestamp: 789,
34
+ liveness_request: {
35
+ nonce: b4a.from('04', 'hex'),
36
+ signature: b4a.from('05', 'hex')
37
+ },
38
+ capabilities: []
39
+ };
40
+
41
+ const payloadLivenessResponse = {
42
+ type: NetworkOperationType.LIVENESS_RESPONSE,
43
+ id: uuidv7(),
44
+ timestamp: 101112,
45
+ liveness_response: {
46
+ nonce: b4a.from('06', 'hex'),
47
+ signature: b4a.from('07', 'hex'),
48
+ result: NetworkResultCode.OK
49
+ },
50
+ capabilities: []
51
+ };
52
+
53
+ const payloadBroadcastTransactionRequest = {
54
+ type: NetworkOperationType.BROADCAST_TRANSACTION_REQUEST,
55
+ id: uuidv7(),
56
+ timestamp: 131415,
57
+ broadcast_transaction_request: {
58
+ data: b4a.from('deadbeef', 'hex'),
59
+ nonce: b4a.from('08', 'hex'),
60
+ signature: b4a.from('09', 'hex')
61
+ },
62
+ capabilities: ['cap:a']
63
+ };
64
+
65
+ const payloadBroadcastTransactionResponse = {
66
+ type: NetworkOperationType.BROADCAST_TRANSACTION_RESPONSE,
67
+ id: uuidv7(),
68
+ timestamp: 161718,
69
+ broadcast_transaction_response: {
70
+ nonce: b4a.from('0a', 'hex'),
71
+ signature: b4a.from('0b', 'hex'),
72
+ result: NetworkResultCode.OK
73
+ },
74
+ capabilities: ['cap:b']
75
+ };
76
+
77
+ export default {
78
+ payloadValidatorConnectionRequest,
79
+ payloadValidatorConnectionResponse,
80
+ payloadLivenessRequest,
81
+ payloadLivenessResponse,
82
+ payloadBroadcastTransactionRequest,
83
+ payloadBroadcastTransactionResponse,
84
+ };