From 4ae9d1945043fc6bbd9ae312d72c3315cff475ef Mon Sep 17 00:00:00 2001 From: "Gomez Goiri, Aitor" <aitor.gomez@tecnalia.com> Date: Wed, 13 Apr 2022 13:08:47 +0200 Subject: [PATCH] Creating several individual assets in the simulation --- apps/batch-sim/index.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/batch-sim/index.js b/apps/batch-sim/index.js index a4e3428..e6fabc5 100644 --- a/apps/batch-sim/index.js +++ b/apps/batch-sim/index.js @@ -42,26 +42,34 @@ const simulateCycle = async (arg1, cmd) => { await signInAs(apiClient, otherArgs.sidenorUser, password) - let batchId = await createAssetAndSendToCone(apiClient, "simulated asset 1") - //batchId = await createAssetAndSendToCone(apiClient, "simulated asset 2") - //batchId = await createAssetAndSendToCone(apiClient, "simulated asset 3") + let stockId + for (let simId of [1, 2, 3]) { + const batchId = await createAssetAndSendToCone( + apiClient, + `simulated asset ${simId}` + ) + let mergedStock = await sendToStock(apiClient, { + assetId: batchId, + // The first time the user should select the stock as it is not provided + stockId + }) + stockId = mergedStock.id + } - const mergedStock = await sendToStock(apiClient, { assetId: batchId }) - const selectedStockId = await discardStock(apiClient, { - assetId: mergedStock.id - }) + const selectedStockId = await discardStock(apiClient, { assetId: stockId }) const selectedStock = await apiClient.getAsset(selectedStockId) await signInAs(apiClient, otherArgs.cement1User, password) await bidAsset(apiClient, { assetId: selectedStockId, + quantity: faker.datatype.number({ min: 200, max: selectedStock.quantity }), price: faker.datatype.number({ min: 50, max: 150 }) }) await signInAs(apiClient, otherArgs.cement2User, password) await bidAsset(apiClient, { assetId: selectedStockId, - quantity: selectedStock.quantity - 500, + quantity: faker.datatype.number({ min: 100, max: selectedStock.quantity }), price: faker.datatype.number({ min: 25, max: 200 }) }) -- GitLab