@cardano-sdk/e2e 0.17.2-patch.0 → 0.19.0

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 (34) hide show
  1. package/.env.example +1 -1
  2. package/CHANGELOG.md +29 -2
  3. package/dist/cjs/factories.d.ts.map +1 -1
  4. package/dist/cjs/factories.js +3 -6
  5. package/dist/cjs/factories.js.map +1 -1
  6. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  7. package/dist/esm/factories.d.ts.map +1 -1
  8. package/dist/esm/factories.js +3 -6
  9. package/dist/esm/factories.js.map +1 -1
  10. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  11. package/docker-compose.yml +8 -0
  12. package/local-network/README.md +1 -1
  13. package/local-network/scripts/cardano-node-ogmios.sh +1 -1
  14. package/local-network/scripts/get-epoch.sh +0 -1
  15. package/local-network/scripts/make-babbage.sh +61 -61
  16. package/local-network/scripts/mint-handles.sh +1 -1
  17. package/local-network/scripts/mint-tokens.sh +0 -1
  18. package/local-network/scripts/mnemonic_keys.sh +7 -7
  19. package/local-network/scripts/nodes-configuration.sh +1 -1
  20. package/local-network/scripts/plutus-transaction.sh +8 -10
  21. package/local-network/scripts/pools/update-node-utils.sh +221 -232
  22. package/local-network/scripts/reference-input-transaction.sh +30 -38
  23. package/local-network/scripts/start.sh +1 -2
  24. package/local-network/templates/babbage/byron-configuration.yaml +9 -14
  25. package/package.json +20 -20
  26. package/src/factories.ts +3 -14
  27. package/test/k6/README.md +3 -4
  28. package/test/long-running/delegation-rewards.test.ts +104 -58
  29. package/test/projection/offline-fork.test.ts +1 -1
  30. package/test/projection/single-tenant-utxo.test.ts +2 -2
  31. package/test/tsconfig.json +1 -0
  32. package/test/web-extension/extension/background/cip30.ts +5 -1
  33. package/test/web-extension/specs/wallet.spec.ts +2 -2
  34. package/test/tsconfig.tsbuildinfo +0 -1
@@ -21,38 +21,37 @@ clean() {
21
21
 
22
22
  getAddressBalance() {
23
23
  cardano-cli query utxo \
24
- --address "$1" \
25
- --testnet-magic 888 > fullUtxo.out
24
+ --address "$1" \
25
+ --testnet-magic 888 >fullUtxo.out
26
26
 
27
- tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
27
+ tail -n +3 fullUtxo.out | sort -k3 -nr >balance.out
28
28
 
29
29
  total_balance=0
30
30
  while read -r utxo; do
31
- utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
32
- total_balance=$(("$total_balance"+"$utxo_balance"))
33
- done < balance.out
31
+ utxo_balance=$(awk '{ print $3 }' <<<"${utxo}")
32
+ total_balance=$(("$total_balance" + "$utxo_balance"))
33
+ done <balance.out
34
34
 
35
35
  echo ${total_balance}
36
36
  }
37
37
 
38
38
  getBiggestUtxo() {
39
39
  cardano-cli query utxo \
40
- --address "$1" \
41
- --testnet-magic 888 > fullUtxo.out
40
+ --address "$1" \
41
+ --testnet-magic 888 >fullUtxo.out
42
42
 
43
- tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
43
+ tail -n +3 fullUtxo.out | sort -k3 -nr >balance.out
44
44
 
45
45
  current_biggest=0
46
46
  utxo_id=''
47
47
  while read -r utxo; do
48
- utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
48
+ utxo_balance=$(awk '{ print $3 }' <<<"${utxo}")
49
49
 
50
- if [[ "$utxo_balance" -ge "$current_biggest" ]];
51
- then
50
+ if [[ $utxo_balance -ge $current_biggest ]]; then
52
51
  current_biggest=$utxo_balance
53
- utxo_id=$(awk '{printf("%s#%s", $1, $2)}' <<< "${utxo}")
52
+ utxo_id=$(awk '{printf("%s#%s", $1, $2)}' <<<"${utxo}")
54
53
  fi
55
- done < balance.out
54
+ done <balance.out
56
55
 
57
56
  echo "${utxo_id} ${current_biggest}"
58
57
  }
@@ -67,7 +66,7 @@ done
67
66
  # LOCK REFERENCE UTXO
68
67
 
69
68
  genesisAddr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo2.vkey --testnet-magic 888)
70
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
69
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
71
70
  currentBalance=$(getAddressBalance "$REFERENCE_INPUT_ADDR")
72
71
 
73
72
  echo "Locking reference UTXO..."
@@ -95,8 +94,7 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file tx-script.signed
95
94
 
96
95
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_ADDR")
97
96
 
98
- while [ "$currentBalance" -eq "$updatedBalance" ]
99
- do
97
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
100
98
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_ADDR")
101
99
  sleep 1
102
100
  done
@@ -105,7 +103,7 @@ echo "Locked"
105
103
  # LOCK REFERENCE SCRIPT UTXO
106
104
 
107
105
  genesisAddr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo2.vkey --testnet-magic 888)
108
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
106
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
109
107
  currentBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
110
108
 
111
109
  echo "Locking reference script UTXO (Multisignature)..."
@@ -130,15 +128,14 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file tx-script.signed
130
128
 
131
129
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
132
130
 
133
- while [ "$currentBalance" -eq "$updatedBalance" ]
134
- do
131
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
135
132
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
136
133
  sleep 1
137
134
  done
138
135
  echo "Locked"
139
136
 
140
137
  genesisAddr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo2.vkey --testnet-magic 888)
141
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
138
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
142
139
  currentBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
143
140
 
144
141
  echo "Locking reference script UTXO (Timelock)..."
@@ -163,15 +160,14 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file tx-script.signed
163
160
 
164
161
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
165
162
 
166
- while [ "$currentBalance" -eq "$updatedBalance" ]
167
- do
163
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
168
164
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
169
165
  sleep 1
170
166
  done
171
167
  echo "Locked"
172
168
 
173
169
  genesisAddr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo2.vkey --testnet-magic 888)
174
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
170
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
175
171
  currentBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
176
172
 
177
173
  echo "Locking reference script UTXO (Plutus V1)..."
@@ -196,15 +192,14 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file tx-script.signed
196
192
 
197
193
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
198
194
 
199
- while [ "$currentBalance" -eq "$updatedBalance" ]
200
- do
195
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
201
196
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
202
197
  sleep 1
203
198
  done
204
199
  echo "Locked"
205
200
 
206
201
  genesisAddr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo2.vkey --testnet-magic 888)
207
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
202
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
208
203
  currentBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
209
204
 
210
205
  echo "Locking reference script UTXO (Plutus V2)..."
@@ -229,8 +224,7 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file tx-script.signed
229
224
 
230
225
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
231
226
 
232
- while [ "$currentBalance" -eq "$updatedBalance" ]
233
- do
227
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
234
228
  updatedBalance=$(getAddressBalance "$REFERENCE_SCRIPT_ADDR")
235
229
  sleep 1
236
230
  done
@@ -238,7 +232,7 @@ echo "Locked"
238
232
 
239
233
  # LOCK FUNDS IN SCRIPT
240
234
  echo "Locking funds in script..."
241
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
235
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
242
236
  currentBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
243
237
 
244
238
  cardano-cli transaction build \
@@ -261,8 +255,7 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file test-babbage.signed
261
255
 
262
256
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
263
257
 
264
- while [ "$currentBalance" -eq "$updatedBalance" ]
265
- do
258
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
266
259
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
267
260
  sleep 1
268
261
  done
@@ -270,10 +263,10 @@ echo "Locked"
270
263
 
271
264
  # UNLOCK FUNDS
272
265
  echo "Unlocking funds from script..."
273
- utxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$genesisAddr")")
274
- utxoVal=$(awk '{printf("%s", $2)}' <<< "$(getBiggestUtxo "$genesisAddr")")
275
- referenceInputUtxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$REFERENCE_INPUT_ADDR")")
276
- scriptUtxo=$(awk '{printf("%s", $1)}' <<< "$(getBiggestUtxo "$REFERENCE_INPUT_SCRIPT_ADDR")")
266
+ utxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$genesisAddr")")
267
+ utxoVal=$(awk '{printf("%s", $2)}' <<<"$(getBiggestUtxo "$genesisAddr")")
268
+ referenceInputUtxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$REFERENCE_INPUT_ADDR")")
269
+ scriptUtxo=$(awk '{printf("%s", $1)}' <<<"$(getBiggestUtxo "$REFERENCE_INPUT_SCRIPT_ADDR")")
277
270
  currentBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
278
271
  returnCollateralVal=$(("$utxoVal" - 1450000))
279
272
 
@@ -303,8 +296,7 @@ cardano-cli transaction submit --testnet-magic 888 --tx-file test-babbage2.signe
303
296
 
304
297
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
305
298
 
306
- while [ "$currentBalance" -eq "$updatedBalance" ]
307
- do
299
+ while [ "$currentBalance" -eq "$updatedBalance" ]; do
308
300
  updatedBalance=$(getAddressBalance "$REFERENCE_INPUT_SCRIPT_ADDR")
309
301
  sleep 1
310
302
  done
@@ -23,8 +23,7 @@ echo "Run"
23
23
  ./network-files/run/all.sh &
24
24
 
25
25
  for ID in ${SP_NODES_ID}; do
26
- if [ -f "./scripts/pools/update-node-sp$ID.sh" ]; # Only update the pool if a script exists for that pool.
27
- then
26
+ if [ -f "./scripts/pools/update-node-sp$ID.sh" ]; then # Only update the pool if a script exists for that pool.
28
27
  CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp"$ID"/node.sock ./scripts/pools/update-node-sp"$ID".sh
29
28
  fi
30
29
  done
@@ -3,16 +3,15 @@
3
3
  ############### Cardano Byron Node Configuration #########
4
4
  ##########################################################
5
5
 
6
-
7
6
  ##### Locations #####
8
7
 
9
8
  GenesisFile: genesis.json
10
9
 
11
10
  ##### Hashes Protocol
12
11
 
13
- ByronGenesisHash: "576a1b4687c7668b2f1d734fecaa7ca994b597f37177606d4942d339875009d6"
14
- ShelleyGenesisHash: "4315428096763404ae322ce69eea7323c94dead3281cd306b5be7e80288626ce"
15
- AlonzoGenesisHash: "eaa32942a4f2b3028928cb47be679bb36fa128f6d7dddc04ae592d27f2818c16"
12
+ ByronGenesisHash: '576a1b4687c7668b2f1d734fecaa7ca994b597f37177606d4942d339875009d6'
13
+ ShelleyGenesisHash: '4315428096763404ae322ce69eea7323c94dead3281cd306b5be7e80288626ce'
14
+ AlonzoGenesisHash: 'eaa32942a4f2b3028928cb47be679bb36fa128f6d7dddc04ae592d27f2818c16'
16
15
 
17
16
  ##### Blockfetch Protocol
18
17
 
@@ -48,7 +47,6 @@ LastKnownBlockVersion-Alt: 0
48
47
  ApplicationName: cardano-sl
49
48
  ApplicationVersion: 1
50
49
 
51
-
52
50
  ##### Logging configuration #####
53
51
 
54
52
  # Enable or disable logging overall
@@ -120,7 +118,7 @@ defaultBackends:
120
118
  # be specified in the defaults below or overridden on a per-scribe basis here.
121
119
  setupScribes:
122
120
  - scKind: FileSK
123
- scName: "logs/testnet.log"
121
+ scName: 'logs/testnet.log'
124
122
  scFormat: ScText
125
123
 
126
124
  - scKind: StdoutSK
@@ -131,7 +129,7 @@ setupScribes:
131
129
  # output is sent to if it is not configured to be sent to other scribes.
132
130
  defaultScribes:
133
131
  - - FileSK
134
- - "logs/testnet.log"
132
+ - 'logs/testnet.log'
135
133
  - - StdoutSK
136
134
  - stdout
137
135
 
@@ -139,9 +137,8 @@ defaultScribes:
139
137
  # in the setupScribes above for specific scribes.
140
138
  rotation:
141
139
  rpLogLimitBytes: 5000000
142
- rpKeepFilesNum: 3
143
- rpMaxAgeHours: 24
144
-
140
+ rpKeepFilesNum: 3
141
+ rpMaxAgeHours: 24
145
142
 
146
143
  ##### Coarse grained logging control #####
147
144
 
@@ -258,7 +255,6 @@ TraceTxOutbound: False
258
255
  # Trace TxSubmission protocol messages.
259
256
  TraceTxSubmissionProtocol: False
260
257
 
261
-
262
258
  ##### Fine grained logging control #####
263
259
 
264
260
  # It is also possible to have more fine grained control over filtering of
@@ -267,7 +263,6 @@ TraceTxSubmissionProtocol: False
267
263
  # much more precise control.
268
264
 
269
265
  options:
270
-
271
266
  # This routes metrics matching specific names to particular backends.
272
267
  # This overrides the 'defaultBackends' listed above. And note that it is
273
268
  # an override and not an extension so anything matched here will not
@@ -280,11 +275,11 @@ options:
280
275
  # type and its name, separated by "::":
281
276
  mapScribes:
282
277
  cardano.node.metrics:
283
- - "FileSK::logs/testnet.log"
278
+ - 'FileSK::logs/testnet.log'
284
279
 
285
280
  # apply a filter on message severity on messages in a specific named context.
286
281
  # this filter is applied additionally to the global 'minSeverity' and thus
287
282
  # needs to be at least as high.
288
283
  mapSeverity:
289
284
  cardano.node.ChainDB: Notice
290
- cardano.node.DnsSubscription: Debug
285
+ cardano.node.DnsSubscription: Debug
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@cardano-sdk/e2e",
3
- "version": "0.17.2-patch.0",
3
+ "version": "0.19.0",
4
4
  "description": "End to end tests for the cardano-js-sdk packages.",
5
5
  "engines": {
6
- "node": ">=16.0"
6
+ "node": ">=16.20.1"
7
7
  },
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",
@@ -81,19 +81,19 @@
81
81
  "dependencies": {
82
82
  "@cardano-foundation/ledgerjs-hw-app-cardano": "^6.0.0",
83
83
  "@cardano-ogmios/client": "5.6.0",
84
- "@cardano-sdk/cardano-services": "~0.14.8",
85
- "@cardano-sdk/cardano-services-client": "~0.10.6",
86
- "@cardano-sdk/core": "~0.15.4",
87
- "@cardano-sdk/crypto": "~0.1.9",
88
- "@cardano-sdk/hardware-ledger": "~0.2.17",
89
- "@cardano-sdk/input-selection": "~0.11.4",
90
- "@cardano-sdk/key-management": "~0.8.2",
91
- "@cardano-sdk/ogmios": "~0.12.13",
92
- "@cardano-sdk/tx-construction": "~0.9.4",
93
- "@cardano-sdk/util": "~0.13.0",
94
- "@cardano-sdk/util-dev": "~0.13.9",
95
- "@cardano-sdk/util-rxjs": "~0.5.5",
96
- "@cardano-sdk/wallet": "~0.18.6-patch.0",
84
+ "@cardano-sdk/cardano-services": "~0.16.0",
85
+ "@cardano-sdk/cardano-services-client": "~0.12.0",
86
+ "@cardano-sdk/core": "~0.17.0",
87
+ "@cardano-sdk/crypto": "~0.1.11",
88
+ "@cardano-sdk/hardware-ledger": "~0.3.1",
89
+ "@cardano-sdk/input-selection": "~0.11.6",
90
+ "@cardano-sdk/key-management": "~0.10.0",
91
+ "@cardano-sdk/ogmios": "~0.12.15",
92
+ "@cardano-sdk/tx-construction": "~0.11.0",
93
+ "@cardano-sdk/util": "~0.13.2",
94
+ "@cardano-sdk/util-dev": "~0.15.0",
95
+ "@cardano-sdk/util-rxjs": "~0.5.7",
96
+ "@cardano-sdk/wallet": "~0.20.0",
97
97
  "@vespaiach/axios-fetch-adapter": "^0.3.0",
98
98
  "axios": "^0.27.2",
99
99
  "bunyan": "^1.8.15",
@@ -122,10 +122,10 @@
122
122
  "@babel/core": "^7.18.2",
123
123
  "@babel/preset-env": "^7.18.2",
124
124
  "@babel/preset-typescript": "^7.17.12",
125
- "@cardano-sdk/dapp-connector": "~0.9.11",
126
- "@cardano-sdk/projection": "~0.6.17",
127
- "@cardano-sdk/projection-typeorm": "~0.3.13",
128
- "@cardano-sdk/web-extension": "~0.14.2-patch.0",
125
+ "@cardano-sdk/dapp-connector": "~0.9.13",
126
+ "@cardano-sdk/projection": "~0.7.1",
127
+ "@cardano-sdk/projection-typeorm": "~0.4.1",
128
+ "@cardano-sdk/web-extension": "~0.14.3",
129
129
  "@dcspark/cardano-multiplatform-lib-browser": "^3.1.1",
130
130
  "@emurgo/cardano-message-signing-asmjs": "^1.0.1",
131
131
  "@types/bunyan": "^1.8.8",
@@ -177,5 +177,5 @@
177
177
  "webpack-cli": "^4.9.2",
178
178
  "webpack-merge": "^5.8.0"
179
179
  },
180
- "gitHead": "4a3952383c68e4c3aaeeab25ae209c53b1cc50eb"
180
+ "gitHead": "5f05daf2c6756dc6f084ffe47ff6ca63998cea39"
181
181
  }
package/src/factories.ts CHANGED
@@ -309,7 +309,7 @@ const patchInitializeTxToRespectEpochBoundary = <T extends ObservableWallet>(
309
309
  * @returns an object containing the wallet and providers passed to it
310
310
  */
311
311
  export const getWallet = async (props: GetWalletProps) => {
312
- const { env, idx, logger, name, polling, handlePolicyIds, stores, customKeyParams, keyAgent } = props;
312
+ const { env, idx, logger, name, polling, stores, customKeyParams, keyAgent } = props;
313
313
  const providers = {
314
314
  addressDiscovery: await addressDiscoveryFactory.create(
315
315
  env.ADDRESS_DISCOVERY,
@@ -328,18 +328,7 @@ export const getWallet = async (props: GetWalletProps) => {
328
328
  env.CHAIN_HISTORY_PROVIDER_PARAMS,
329
329
  logger
330
330
  ),
331
- handleProvider: await handleProviderFactory.create(
332
- env.HANDLE_PROVIDER,
333
- {
334
- ...env.HANDLE_PROVIDER_PARAMS,
335
- networkInfoProvider: await networkInfoProviderFactory.create(
336
- env.NETWORK_INFO_PROVIDER,
337
- env.NETWORK_INFO_PROVIDER_PARAMS,
338
- logger
339
- )
340
- },
341
- logger
342
- ),
331
+ handleProvider: await handleProviderFactory.create(env.HANDLE_PROVIDER, env.HANDLE_PROVIDER_PARAMS, logger),
343
332
  networkInfoProvider: await networkInfoProviderFactory.create(
344
333
  env.NETWORK_INFO_PROVIDER,
345
334
  env.NETWORK_INFO_PROVIDER_PARAMS,
@@ -368,7 +357,7 @@ export const getWallet = async (props: GetWalletProps) => {
368
357
  ? () => Promise.resolve(keyAgent)
369
358
  : await keyManagementFactory.create(env.KEY_MANAGEMENT_PROVIDER, keyManagementParams, logger),
370
359
  createWallet: async (asyncKeyAgent: AsyncKeyAgent) =>
371
- new PersonalWallet({ handlePolicyIds, name, polling }, { ...providers, keyAgent: asyncKeyAgent, logger, stores }),
360
+ new PersonalWallet({ name, polling }, { ...providers, keyAgent: asyncKeyAgent, logger, stores }),
372
361
  logger
373
362
  });
374
363
 
package/test/k6/README.md CHANGED
@@ -4,18 +4,17 @@
4
4
 
5
5
  1. [K6 installed locally](https://k6.io/docs/get-started/installation/). Needed for `k6 run the-test.js`.
6
6
  1. Metrics dashboards & reports: install [K6 Dashboards extension](https://github.com/szkiba/xk6-dashboard#download)
7
- - **Make sure you are using `k6` binary downloaded/built from `xk6-dashboard` project** when running or replaying**.
7
+ - **Make sure you are using `k6` binary downloaded/built from `xk6-dashboard` project** when running or replaying\*\*.
8
8
  Otherwise the command will fail with `invalid output type 'dashboard', available types are`.
9
- - K6 dashboards are available by default in: http://127.0.0.1:5665
9
+ - K6 dashboards are available by default in: http://127.0.0.1:5665
10
10
 
11
11
  ## Running
12
12
 
13
13
  - Without K6 dashboards:
14
- ```k6 run test-file.js --out json=test-file-out.json --out csv=test-file-out.csv```
14
+ `k6 run test-file.js --out json=test-file-out.json --out csv=test-file-out.csv`
15
15
 
16
16
  - With K6 dashboards while test is running.
17
17
  `k6 run test-file.js --out json=test-file-out.json --out csv=test-file-out.csv --out dashboard`
18
18
 
19
19
  - Open K6 dashboards for a previous run. The `json` out file is needed.
20
20
  `k6 dashboard replay test-file-out.json`
21
-
@@ -1,4 +1,4 @@
1
- import { Cardano } from '@cardano-sdk/core';
1
+ import { Cardano, StakePoolProvider } from '@cardano-sdk/core';
2
2
  import { PersonalWallet } from '@cardano-sdk/wallet';
3
3
  import {
4
4
  TestWallet,
@@ -16,6 +16,64 @@ import { waitForWalletStateSettle } from '../../../wallet/test/util';
16
16
 
17
17
  const env = getEnv(walletVariables);
18
18
 
19
+ const submitDelegationTx = async (wallet: PersonalWallet, pools: Cardano.PoolId[]) => {
20
+ logger.info(`Creating delegation tx at epoch #${(await firstValueFrom(wallet.currentEpoch$)).epochNo}`);
21
+ const { tx: signedTx } = await wallet
22
+ .createTxBuilder()
23
+ .delegatePortfolio({
24
+ pools: pools.map((poolId) => ({ id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolId)), weight: 1 }))
25
+ })
26
+ .build()
27
+ .sign();
28
+ await wallet.submitTx(signedTx);
29
+ const { epochNo } = await firstValueFrom(wallet.currentEpoch$);
30
+ logger.info(`Delegation tx ${signedTx.id} submitted at epoch #${epochNo}`);
31
+
32
+ return signedTx;
33
+ };
34
+
35
+ const generateTxs = async (sendingWallet: PersonalWallet, receivingWallet: PersonalWallet) => {
36
+ logger.info('Sending 100 txs to generate reward fees');
37
+
38
+ const tAdaToSend = 5_000_000n;
39
+ const [{ address: receivingAddress }] = await firstValueFrom(receivingWallet.addresses$);
40
+
41
+ for (let i = 0; i < 100; i++) {
42
+ const txBuilder = sendingWallet.createTxBuilder();
43
+ const txOut = await txBuilder.buildOutput().address(receivingAddress).coin(tAdaToSend).build();
44
+ const { tx: signedTx } = await txBuilder.addOutput(txOut).build().sign();
45
+ await sendingWallet.submitTx(signedTx);
46
+ }
47
+ };
48
+
49
+ const buildSpendRewardTx = async (sendingWallet: PersonalWallet, receivingWallet: PersonalWallet) => {
50
+ const tAdaToSend = 5_000_000n;
51
+ const [{ address: receivingAddress }] = await firstValueFrom(receivingWallet.addresses$);
52
+ const txBuilder = sendingWallet.createTxBuilder();
53
+ const txOut = await txBuilder.buildOutput().address(receivingAddress).coin(tAdaToSend).build();
54
+ const tx = txBuilder.addOutput(txOut).build();
55
+ const { body } = await tx.inspect();
56
+ logger.debug('Body of tx before sign');
57
+ logger.debug(body);
58
+ const { tx: signedTx } = await tx.sign();
59
+ logger.debug('Body of tx after sign');
60
+ logger.debug(signedTx.body);
61
+
62
+ return signedTx;
63
+ };
64
+
65
+ const getPoolIds = async (stakePoolProvider: StakePoolProvider, count: number) => {
66
+ const activePools = await stakePoolProvider.queryStakePools({
67
+ filters: { pledgeMet: true, status: [Cardano.StakePoolStatus.Active] },
68
+ pagination: { limit: count, startAt: 0 }
69
+ });
70
+ expect(activePools.totalResultCount).toBeGreaterThanOrEqual(count);
71
+ const poolIds = activePools.pageResults.map(({ id }) => id);
72
+ expect(poolIds.every((poolId) => poolId !== undefined)).toBeTruthy();
73
+ logger.info('Wallet funds will be staked to pools:', poolIds);
74
+ return poolIds;
75
+ };
76
+
19
77
  describe('delegation rewards', () => {
20
78
  let providers: TestWallet['providers'];
21
79
  let wallet1: PersonalWallet;
@@ -51,64 +109,11 @@ describe('delegation rewards', () => {
51
109
  await initializeWallets();
52
110
 
53
111
  // Arrange
54
- const activePools = await providers.stakePoolProvider.queryStakePools({
55
- filters: { pledgeMet: true, status: [Cardano.StakePoolStatus.Active] },
56
- pagination: { limit: 1, startAt: 0 }
57
- });
58
- expect(activePools.totalResultCount).toBeGreaterThan(0);
59
- const poolId = activePools.pageResults[0].id;
60
- expect(poolId).toBeDefined();
61
- logger.info(`Wallet funds will be staked to pool ${poolId}.`);
62
-
63
- const submitDelegationTx = async () => {
64
- logger.info(`Creating delegation tx at epoch #${(await firstValueFrom(wallet1.currentEpoch$)).epochNo}`);
65
- const { tx: signedTx } = await wallet1
66
- .createTxBuilder()
67
- .delegatePortfolio({
68
- pools: [{ id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolId)), weight: 1 }]
69
- })
70
- .build()
71
- .sign();
72
- await wallet1.submitTx(signedTx);
73
- const { epochNo } = await firstValueFrom(wallet1.currentEpoch$);
74
- logger.info(`Delegation tx ${signedTx.id} submitted at epoch #${epochNo}`);
75
-
76
- return signedTx;
77
- };
78
-
79
- const generateTxs = async () => {
80
- logger.info('Sending 100 txs to generate reward fees');
81
-
82
- const tAdaToSend = 5_000_000n;
83
- const [{ address: receivingAddress }] = await firstValueFrom(wallet2.addresses$);
84
-
85
- for (let i = 0; i < 100; i++) {
86
- const txBuilder = wallet1.createTxBuilder();
87
- const txOut = await txBuilder.buildOutput().address(receivingAddress).coin(tAdaToSend).build();
88
- const { tx: signedTx } = await txBuilder.addOutput(txOut).build().sign();
89
- await wallet1.submitTx(signedTx);
90
- }
91
- };
92
-
93
- const buildSpendRewardTx = async () => {
94
- const tAdaToSend = 5_000_000n;
95
- const [{ address: receivingAddress }] = await firstValueFrom(wallet2.addresses$);
96
- const txBuilder = wallet1.createTxBuilder();
97
- const txOut = await txBuilder.buildOutput().address(receivingAddress).coin(tAdaToSend).build();
98
- const tx = await txBuilder.addOutput(txOut).build();
99
- const { body } = await tx.inspect();
100
- logger.debug('Body of tx before sign');
101
- logger.debug(body);
102
- const { tx: signedTx } = await tx.sign();
103
- logger.debug('Body of tx after sign');
104
- logger.debug(signedTx.body);
105
-
106
- return signedTx;
107
- };
112
+ const [poolId] = await getPoolIds(providers.stakePoolProvider, 1);
108
113
 
109
114
  // Stake and wait for reward
110
115
 
111
- const signedTx = await submitDelegationTx();
116
+ const signedTx = await submitDelegationTx(wallet1, [poolId]);
112
117
 
113
118
  const delegationTxConfirmedAtEpoch = await getTxConfirmationEpoch(wallet1, signedTx);
114
119
 
@@ -116,7 +121,7 @@ describe('delegation rewards', () => {
116
121
 
117
122
  await waitForEpoch(wallet1, delegationTxConfirmedAtEpoch + 2);
118
123
 
119
- await generateTxs();
124
+ await generateTxs(wallet1, wallet2);
120
125
  await waitForEpoch(wallet1, delegationTxConfirmedAtEpoch + 4);
121
126
 
122
127
  // Check reward
@@ -127,8 +132,49 @@ describe('delegation rewards', () => {
127
132
  logger.info(`Generated rewards: ${rewards} tLovelace`);
128
133
 
129
134
  // Spend reward
130
- const spendRewardTx = await buildSpendRewardTx();
135
+ const spendRewardTx = await buildSpendRewardTx(wallet1, wallet2);
131
136
  expect(spendRewardTx.body.withdrawals?.length).toBeGreaterThan(0);
132
137
  await submitAndConfirm(wallet1, spendRewardTx);
133
138
  });
139
+
140
+ it('can spend rewards from multiple accounts', async () => {
141
+ if (!(await runningAgainstLocalNetwork())) {
142
+ return logger.fatal(
143
+ "Skipping test 'will receive rewards for delegated tADA' as it should only run with a fast test network"
144
+ );
145
+ }
146
+
147
+ // This has to be done inside the test (instead of beforeAll)
148
+ // so that it doesn't fail when running against non-local networks
149
+ await initializeWallets();
150
+
151
+ const [poolId1, poolId2] = await getPoolIds(providers.stakePoolProvider, 2);
152
+ const signedTx = await submitDelegationTx(wallet1, [poolId1, poolId2]);
153
+
154
+ const delegationTxConfirmedAtEpoch = await getTxConfirmationEpoch(wallet1, signedTx);
155
+
156
+ logger.info(`Delegation tx confirmed at epoch #${delegationTxConfirmedAtEpoch}`);
157
+
158
+ await waitForEpoch(wallet1, delegationTxConfirmedAtEpoch + 2);
159
+
160
+ await generateTxs(wallet1, wallet2);
161
+ await waitForEpoch(wallet1, delegationTxConfirmedAtEpoch + 4);
162
+
163
+ // Check reward
164
+ await waitForWalletStateSettle(wallet1);
165
+ const rewardsPerAcct = await firstValueFrom(wallet1.delegation.rewardAccounts$);
166
+ const rewards = await firstValueFrom(wallet1.balance.rewardAccounts.rewards$);
167
+
168
+ logger.info(`Generated rewards: ${rewards} tLovelace`);
169
+ logger.info('Generated rewards per account:', rewardsPerAcct);
170
+
171
+ expect(rewards).toBeGreaterThan(0n);
172
+
173
+ // Spend reward
174
+ const spendRewardTx = await buildSpendRewardTx(wallet1, wallet2);
175
+ logger.info('transaction Withdrawals', spendRewardTx.body.withdrawals);
176
+
177
+ expect(spendRewardTx.body.withdrawals?.length).toBeGreaterThanOrEqual(2);
178
+ await submitAndConfirm(wallet1, spendRewardTx);
179
+ });
134
180
  });
@@ -121,7 +121,7 @@ describe('resuming projection when intersection is not local tip', () => {
121
121
  buffer: StabilityWindowBuffer,
122
122
  into: ProjectionOperator<Mappers.WithStakeKeys>
123
123
  ) =>
124
- Bootstrap.fromCardanoNode({ buffer, cardanoNode, logger }).pipe(
124
+ Bootstrap.fromCardanoNode({ blocksBufferLength: 10, buffer, cardanoNode, logger }).pipe(
125
125
  Mappers.withCertificates(),
126
126
  Mappers.withStakeKeys(),
127
127
  into,
@@ -100,7 +100,7 @@ describe('single-tenant utxo projection', () => {
100
100
  afterEach(async () => cleanup());
101
101
 
102
102
  const projectMultiTenant = () =>
103
- Bootstrap.fromCardanoNode({ buffer, cardanoNode, logger }).pipe(
103
+ Bootstrap.fromCardanoNode({ blocksBufferLength: 10, buffer, cardanoNode, logger }).pipe(
104
104
  Mappers.withMint(),
105
105
  Mappers.withUtxo(),
106
106
  Postgres.withTypeormTransaction({ dataSource$: of(dataSource), logger }),
@@ -123,7 +123,7 @@ describe('single-tenant utxo projection', () => {
123
123
  );
124
124
 
125
125
  const projectSingleTenant = (addresses: Cardano.PaymentAddress[]) =>
126
- Bootstrap.fromCardanoNode({ buffer, cardanoNode, logger }).pipe(
126
+ Bootstrap.fromCardanoNode({ blocksBufferLength: 10, buffer, cardanoNode, logger }).pipe(
127
127
  Mappers.withMint(),
128
128
  Mappers.withUtxo(),
129
129
  Mappers.filterProducedUtxoByAddresses({ addresses }),
@@ -4,6 +4,7 @@
4
4
  "baseUrl": "."
5
5
  },
6
6
  "exclude": ["./web-extension"],
7
+ "include": ["./**/*.ts"],
7
8
  "references": [
8
9
  {
9
10
  "path": "../src"
@@ -8,7 +8,11 @@ import { wallet$ } from './walletManager';
8
8
  import { walletName } from '../const';
9
9
 
10
10
  // this should come from remote api
11
- const confirmationCallback: walletCip30.CallbackConfirmation = async () => true;
11
+ const confirmationCallback: walletCip30.CallbackConfirmation = {
12
+ signData: async () => true,
13
+ signTx: async () => true,
14
+ submitTx: async () => true
15
+ };
12
16
 
13
17
  const walletApi = walletCip30.createWalletApi(wallet$, confirmationCallback, { logger });
14
18
  cip30.initializeBackgroundScript({ walletName }, { authenticator, logger, runtime, walletApi });