@algorandfoundation/algokit-utils 8.0.3 → 8.1.0-beta.2

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/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "**"
7
7
  ],
8
8
  "name": "@algorandfoundation/algokit-utils",
9
- "version": "8.0.3",
9
+ "version": "8.1.0-beta.2",
10
10
  "private": false,
11
11
  "description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
12
12
  "author": "Algorand Foundation",
@@ -8,29 +8,41 @@ import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
8
8
  * and/or kmd (or their respective config) if you want to test against
9
9
  * an explicitly defined network.
10
10
  *
11
- * @example No config
11
+ * @example No config (per-test isolation)
12
12
  * ```typescript
13
- * const algorand = algorandFixture()
13
+ * const fixture = algorandFixture()
14
14
  *
15
- * beforeEach(algorand.beforeEach, 10_000)
15
+ * beforeEach(fixture.newScope, 10_000)
16
16
  *
17
17
  * test('My test', async () => {
18
- * const {algod, indexer, testAccount, ...} = algorand.context
18
+ * const {algod, indexer, testAccount, ...} = fixture.context
19
+ * // test things...
20
+ * })
21
+ * ```
22
+ *
23
+ * @example No config (test suite isolation)
24
+ * ```typescript
25
+ * const fixture = algorandFixture()
26
+ *
27
+ * beforeAll(fixture.newScope, 10_000)
28
+ *
29
+ * test('My test', async () => {
30
+ * const {algod, indexer, testAccount, ...} = fixture.context
19
31
  * // test things...
20
32
  * })
21
33
  * ```
22
34
  *
23
35
  * @example With config
24
36
  * ```typescript
25
- * const algorand = algorandFixture({
37
+ * const fixture = algorandFixture({
26
38
  * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
27
39
  * // ...
28
40
  * })
29
41
  *
30
- * beforeEach(algorand.beforeEach, 10_000)
42
+ * beforeEach(fixture.newScope, 10_000)
31
43
  *
32
44
  * test('My test', async () => {
33
- * const {algod, indexer, testAccount, ...} = algorand.context
45
+ * const {algod, indexer, testAccount, ...} = fixture.context
34
46
  * // test things...
35
47
  * })
36
48
  * ```
@@ -48,18 +60,6 @@ export declare function algorandFixture(fixtureConfig?: AlgorandFixtureConfig):
48
60
  * a default LocalNet instance, but you can pass in an algod, indexer
49
61
  * and/or kmd if you want to test against an explicitly defined network.
50
62
  *
51
- * @example
52
- * ```typescript
53
- * const algorand = algorandFixture(undefined, getConfigFromEnvOrDefaults())
54
- *
55
- * beforeEach(algorand.beforeEach, 10_000)
56
- *
57
- * test('My test', async () => {
58
- * const {algod, indexer, testAccount, ...} = algorand.context
59
- * // test things...
60
- * })
61
- * ```
62
- *
63
63
  * @param fixtureConfig The fixture configuration
64
64
  * @param config The fixture configuration
65
65
  * @returns The fixture
@@ -18,19 +18,18 @@ function algorandFixture(fixtureConfig, config$1) {
18
18
  const kmd = fixtureConfig.kmd ?? types_clientManager.ClientManager.getKmdClient(fixtureConfig.kmdConfig);
19
19
  let context;
20
20
  let algorand;
21
- const beforeEach = async () => {
21
+ const newScope = async () => {
22
22
  config.Config.configure({ debug: true });
23
23
  const transactionLogger$1 = new transactionLogger.TransactionLogger();
24
24
  const transactionLoggerAlgod = transactionLogger$1.capture(algod);
25
- algorand = types_algorandClient.AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer: indexer$1, kmd });
25
+ algorand = types_algorandClient.AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer: indexer$1, kmd }).setSuggestedParamsCacheTimeout(0);
26
26
  const testAccount = await account.getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? amount.algos(10), suppressLog: true }, algorand);
27
- algorand.setSignerFromAccount(testAccount).setSuggestedParamsCacheTimeout(0);
27
+ algorand.setSignerFromAccount(testAccount);
28
28
  // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window
29
29
  // otherwise we are more likely to get invalid transactions.
30
30
  if (await algorand.client.isLocalNet()) {
31
31
  algorand.setDefaultValidityWindow(1000);
32
32
  }
33
- algorand.account.setSignerFromAccount(testAccount);
34
33
  context = {
35
34
  algorand,
36
35
  algod: transactionLoggerAlgod,
@@ -49,12 +48,15 @@ function algorandFixture(fixtureConfig, config$1) {
49
48
  };
50
49
  return {
51
50
  get context() {
51
+ if (!context)
52
+ throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.');
52
53
  return context;
53
54
  },
54
55
  get algorand() {
55
56
  return algorand;
56
57
  },
57
- beforeEach,
58
+ beforeEach: newScope,
59
+ newScope,
58
60
  };
59
61
  }
60
62
 
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-fixture.js","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config\n * ```typescript\n * const algorand = algorandFixture()\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const algorand = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @example\n * ```typescript\n * const algorand = algorandFixture(undefined, getConfigFromEnvOrDefaults())\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const beforeEach = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd })\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount).setSuggestedParamsCacheTimeout(0)\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n algorand.account.setSignerFromAccount(testAccount)\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach,\n }\n}\n"],"names":["config","ClientManager","indexer","Config","transactionLogger","TransactionLogger","AlgorandClient","getTestAccount","algos","account","runWhenIndexerCaughtUp"],"mappings":";;;;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAEA,QAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAGA,QAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAGC,iCAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAIA,iCAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAMC,SAAO,GAAG,aAAa,CAAC,OAAO,IAAID,iCAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAIA,iCAAa,CA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iB;YACpC,cAAc,EAAE,MAAMA,mBAAiB,CAAC,cAAc,CAACF,SAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,KAAKQ,8BAAsB,CAAC,MAAMR,SAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC;SACtI;AACH,KAAC;IAED,OAAO;AACL,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,OAAO,OAAO;SACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,QAAQ;SAChB;QACD,UAAU;KACX;AACH;;;;"}
1
+ {"version":3,"file":"algorand-fixture.js","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"names":["config","ClientManager","indexer","Config","transactionLogger","TransactionLogger","AlgorandClient","getTestAccount","algos","account","runWhenIndexerCaughtUp"],"mappings":";;;;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAEA,QAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAGA,QAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAGC,iCAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAIA,iCAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAMC,SAAO,GAAG,aAAa,CAAC,OAAO,IAAID,iCAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAIA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ACF,SAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,KAAKQ,8BAAsB,CAAC,MAAMR,SAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC;SACtI;AACH,KAAC;IAED,OAAO;AACL,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,IAAI,CAAC,OAAO;AAAE,gBAAA,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC;AACxH,YAAA,OAAO,OAAO;SACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,QAAQ;SAChB;AACD,QAAA,UAAU,EAAE,QAAQ;QACpB,QAAQ;KACT;AACH;;;;"}
@@ -16,19 +16,18 @@ function algorandFixture(fixtureConfig, config) {
16
16
  const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig);
17
17
  let context;
18
18
  let algorand;
19
- const beforeEach = async () => {
19
+ const newScope = async () => {
20
20
  Config.configure({ debug: true });
21
21
  const transactionLogger = new TransactionLogger();
22
22
  const transactionLoggerAlgod = transactionLogger.capture(algod);
23
- algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd });
23
+ algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0);
24
24
  const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand);
25
- algorand.setSignerFromAccount(testAccount).setSuggestedParamsCacheTimeout(0);
25
+ algorand.setSignerFromAccount(testAccount);
26
26
  // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window
27
27
  // otherwise we are more likely to get invalid transactions.
28
28
  if (await algorand.client.isLocalNet()) {
29
29
  algorand.setDefaultValidityWindow(1000);
30
30
  }
31
- algorand.account.setSignerFromAccount(testAccount);
32
31
  context = {
33
32
  algorand,
34
33
  algod: transactionLoggerAlgod,
@@ -47,12 +46,15 @@ function algorandFixture(fixtureConfig, config) {
47
46
  };
48
47
  return {
49
48
  get context() {
49
+ if (!context)
50
+ throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.');
50
51
  return context;
51
52
  },
52
53
  get algorand() {
53
54
  return algorand;
54
55
  },
55
- beforeEach,
56
+ beforeEach: newScope,
57
+ newScope,
56
58
  };
57
59
  }
58
60
 
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-fixture.mjs","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config\n * ```typescript\n * const algorand = algorandFixture()\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const algorand = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @example\n * ```typescript\n * const algorand = algorandFixture(undefined, getConfigFromEnvOrDefaults())\n *\n * beforeEach(algorand.beforeEach, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = algorand.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const beforeEach = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd })\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount).setSuggestedParamsCacheTimeout(0)\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n algorand.account.setSignerFromAccount(testAccount)\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAE,MAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAG,aAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,aAAa,CAAC,SAAU,CAAC;AACrF,IAAA,IAAI,OAAsC;AAC1C,IAAA,IAAI,QAAwB;AAE5B,IAAA,MAAM,UAAU,GAAG,YAAW;QAC5B,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjC,QAAA,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;Q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ACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,QAAQ;SAChB;QACD,UAAU;KACX;AACH;;;;"}
1
+ {"version":3,"file":"algorand-fixture.mjs","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new Algodv2('localhost', 12345, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AA4EgB,SAAA,eAAe,CAAC,aAAqC,EAAE,MAAmB,EAAA;IACxF,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE;AAC/C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QACxE,aAAa,GAAG,EAAE,GAAG,aAAa,CAAC,kCAAkC,EAAE,EAAE,GAAG,aAAa,EAAE;;AAG7F,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,WAAY,CAAC;AAC7F,IAAA,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAc,CAAC;AACrG,IAAA,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,aAAa,CAAC,SAAU,CAAC;AACrF,IAAA,IAAI,OAAsC;AAC1C,IAAA,IAAI,QAAwB;AAE5B,IAAA,MAAM,QAAQ,GAAG,YAAW;QAC1B,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjC,QAAA,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;QACjD,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;QAE/D,QAAQ,GAAG,cAAc,CAAC,WAAW,C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,QAAQ;QACpB,QAAQ;KACT;AACH;;;;"}
@@ -49,7 +49,10 @@ class TransactionLogger {
49
49
  }
50
50
  /** Wait until all logged transactions IDs appear in the given `Indexer`. */
51
51
  async waitForIndexer(indexer$1) {
52
- await Promise.all(this._sentTransactionIds.map((txnId) => indexer.runWhenIndexerCaughtUp(() => indexer$1.lookupTransactionByID(txnId).do())));
52
+ if (this._sentTransactionIds.length === 0)
53
+ return;
54
+ const lastTxId = this._sentTransactionIds[this._sentTransactionIds.length - 1];
55
+ await indexer.runWhenIndexerCaughtUp(() => indexer$1.lookupTransactionByID(lastTxId).do());
53
56
  }
54
57
  }
55
58
  class TransactionLoggingAlgodv2ProxyHandler {
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-logger.js","sources":["../../src/testing/transaction-logger.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { runWhenIndexerCaughtUp } from './indexer'\nimport Algodv2 = algosdk.Algodv2\nimport decodeSignedTransaction = algosdk.decodeSignedTransaction\nimport Indexer = algosdk.Indexer\n\n/**\n * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.\n * Useful for automated tests.\n */\nexport class TransactionLogger {\n private _sentTransactionIds: string[] = []\n\n /**\n * The list of transaction IDs that has been logged thus far.\n */\n get sentTransactionIds(): Readonly<string[]> {\n return this._sentTransactionIds\n }\n\n /**\n * Clear all logged IDs.\n */\n clear() {\n this._sentTransactionIds = []\n }\n\n /**\n * The method that captures raw transactions and stores the transaction IDs.\n */\n logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]) {\n if (Array.isArray(signedTransactions)) {\n for (const stxn of signedTransactions) {\n const decoded = decodeSignedTransaction(stxn)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n } else {\n const decoded = decodeSignedTransaction(signedTransactions)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n }\n\n /** Return a proxy that wraps the given Algodv2 with this transaction logger.\n *\n * @param algod The `Algodv2` to wrap\n * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger\n */\n capture(algod: Algodv2): Algodv2 {\n return new Proxy<Algodv2>(algod, new TransactionLoggingAlgodv2ProxyHandler(this))\n }\n\n /** Wait until all logged transactions IDs appear in the given `Indexer`. */\n async waitForIndexer(indexer: Indexer) {\n await Promise.all(this._sentTransactionIds.map((txnId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())))\n }\n}\n\nclass TransactionLoggingAlgodv2ProxyHandler implements ProxyHandler<Algodv2> {\n private transactionLogger: TransactionLogger\n\n constructor(transactionLogger: TransactionLogger) {\n this.transactionLogger = transactionLogger\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(target: Algodv2, property: string | symbol, receiver: any) {\n if (property === 'sendRawTransaction') {\n return (stxOrStxs: Uint8Array | Uint8Array[]) => {\n this.transactionLogger.logRawTransaction(stxOrStxs)\n return target[property].call(receiver, stxOrStxs)\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (target as any)[property]\n }\n}\n"],"names":["indexer","runWhenIndexerCaughtUp"],"mappings":";;;;;AAGA,IAAO,uBAAuB,GAAG,OAAO,CAAC,uBAAuB;AAGhE;;;AAGG;MACU,iBAAiB,CAAA;AAA9B,IAAA,WAAA,GAAA;QACU,IAAmB,CAAA,mBAAA,GAAa,EAAE;;AAE1C;;AAEG;AACH,IAAA,IAAI,kBAAkB,GAAA;QACpB,OAAO,IAAI,CAAC,mBAAmB;;AAGjC;;AAEG;IACH,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,mBAAmB,GAAG,EAAE;;AAG/B;;AAEG;AACH,IAAA,iBAAiB,CAAC,kBAA6C,EAAA;AAC7D,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACrC,YAAA,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE;AACrC,gBAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC;AAC7C,gBAAA,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;aAE9C;AACL,YAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,kBAAkB,CAAC;AAC3D,YAAA,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;AAIrD;;;;AAIG;AACH,IAAA,OAAO,CAAC,KAAc,EAAA;QACpB,OAAO,IAAI,KAAK,CAAU,KAAK,EAAE,IAAI,qCAAqC,CAAC,IAAI,CAAC,CAAC;;;IAInF,MAAM,cAAc,CAACA,SAAgB,EAAA;AACnC,QAAA,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,KAAK,KAAKC,8BAAsB,CAAC,MAAMD,SAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;;AAEtI;AAED,MAAM,qCAAqC,CAAA;AAGzC,IAAA,WAAA,CAAY,iBAAoC,EAAA;AAC9C,QAAA,IAAI,CAAC,iBAAiB,GAAG,iBAAiB;;;AAI5C,IAAA,GAAG,CAAC,MAAe,EAAE,QAAyB,EAAE,QAAa,EAAA;AAC3D,QAAA,IAAI,QAAQ,KAAK,oBAAoB,EAAE;YACrC,OAAO,CAAC,SAAoC,KAAI;AAC9C,gBAAA,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;AACnD,aAAC;;;AAGH,QAAA,OAAQ,MAAc,CAAC,QAAQ,CAAC;;AAEnC;;;;"}
1
+ {"version":3,"file":"transaction-logger.js","sources":["../../src/testing/transaction-logger.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { runWhenIndexerCaughtUp } from './indexer'\nimport Algodv2 = algosdk.Algodv2\nimport decodeSignedTransaction = algosdk.decodeSignedTransaction\nimport Indexer = algosdk.Indexer\n\n/**\n * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.\n * Useful for automated tests.\n */\nexport class TransactionLogger {\n private _sentTransactionIds: string[] = []\n\n /**\n * The list of transaction IDs that has been logged thus far.\n */\n get sentTransactionIds(): Readonly<string[]> {\n return this._sentTransactionIds\n }\n\n /**\n * Clear all logged IDs.\n */\n clear() {\n this._sentTransactionIds = []\n }\n\n /**\n * The method that captures raw transactions and stores the transaction IDs.\n */\n logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]) {\n if (Array.isArray(signedTransactions)) {\n for (const stxn of signedTransactions) {\n const decoded = decodeSignedTransaction(stxn)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n } else {\n const decoded = decodeSignedTransaction(signedTransactions)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n }\n\n /** Return a proxy that wraps the given Algodv2 with this transaction logger.\n *\n * @param algod The `Algodv2` to wrap\n * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger\n */\n capture(algod: Algodv2): Algodv2 {\n return new Proxy<Algodv2>(algod, new TransactionLoggingAlgodv2ProxyHandler(this))\n }\n\n /** Wait until all logged transactions IDs appear in the given `Indexer`. */\n async waitForIndexer(indexer: Indexer) {\n if (this._sentTransactionIds.length === 0) return\n const lastTxId = this._sentTransactionIds[this._sentTransactionIds.length - 1]\n await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(lastTxId).do())\n }\n}\n\nclass TransactionLoggingAlgodv2ProxyHandler implements ProxyHandler<Algodv2> {\n private transactionLogger: TransactionLogger\n\n constructor(transactionLogger: TransactionLogger) {\n this.transactionLogger = transactionLogger\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(target: Algodv2, property: string | symbol, receiver: any) {\n if (property === 'sendRawTransaction') {\n return (stxOrStxs: Uint8Array | Uint8Array[]) => {\n this.transactionLogger.logRawTransaction(stxOrStxs)\n return target[property].call(receiver, stxOrStxs)\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (target as any)[property]\n }\n}\n"],"names":["indexer","runWhenIndexerCaughtUp"],"mappings":";;;;;AAGA,IAAO,uBAAuB,GAAG,OAAO,CAAC,uBAAuB;AAGhE;;;AAGG;MACU,iBAAiB,CAAA;AAA9B,IAAA,WAAA,GAAA;QACU,IAAmB,CAAA,mBAAA,GAAa,EAAE;;AAE1C;;AAEG;AACH,IAAA,IAAI,kBAAkB,GAAA;QACpB,OAAO,IAAI,CAAC,mBAAmB;;AAGjC;;AAEG;IACH,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,mBAAmB,GAAG,EAAE;;AAG/B;;AAEG;AACH,IAAA,iBAAiB,CAAC,kBAA6C,EAAA;AAC7D,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACrC,YAAA,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE;AACrC,gBAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC;AAC7C,gBAAA,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;aAE9C;AACL,YAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,kBAAkB,CAAC;AAC3D,YAAA,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;AAIrD;;;;AAIG;AACH,IAAA,OAAO,CAAC,KAAc,EAAA;QACpB,OAAO,IAAI,KAAK,CAAU,KAAK,EAAE,IAAI,qCAAqC,CAAC,IAAI,CAAC,CAAC;;;IAInF,MAAM,cAAc,CAACA,SAAgB,EAAA;AACnC,QAAA,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,KAAK,CAAC;YAAE;AAC3C,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9E,QAAA,MAAMC,8BAAsB,CAAC,MAAMD,SAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;;AAEnF;AAED,MAAM,qCAAqC,CAAA;AAGzC,IAAA,WAAA,CAAY,iBAAoC,EAAA;AAC9C,QAAA,IAAI,CAAC,iBAAiB,GAAG,iBAAiB;;;AAI5C,IAAA,GAAG,CAAC,MAAe,EAAE,QAAyB,EAAE,QAAa,EAAA;AAC3D,QAAA,IAAI,QAAQ,KAAK,oBAAoB,EAAE;YACrC,OAAO,CAAC,SAAoC,KAAI;AAC9C,gBAAA,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;AACnD,aAAC;;;AAGH,QAAA,OAAQ,MAAc,CAAC,QAAQ,CAAC;;AAEnC;;;;"}
@@ -47,7 +47,10 @@ class TransactionLogger {
47
47
  }
48
48
  /** Wait until all logged transactions IDs appear in the given `Indexer`. */
49
49
  async waitForIndexer(indexer) {
50
- await Promise.all(this._sentTransactionIds.map((txnId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())));
50
+ if (this._sentTransactionIds.length === 0)
51
+ return;
52
+ const lastTxId = this._sentTransactionIds[this._sentTransactionIds.length - 1];
53
+ await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(lastTxId).do());
51
54
  }
52
55
  }
53
56
  class TransactionLoggingAlgodv2ProxyHandler {
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-logger.mjs","sources":["../../src/testing/transaction-logger.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { runWhenIndexerCaughtUp } from './indexer'\nimport Algodv2 = algosdk.Algodv2\nimport decodeSignedTransaction = algosdk.decodeSignedTransaction\nimport Indexer = algosdk.Indexer\n\n/**\n * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.\n * Useful for automated tests.\n */\nexport class TransactionLogger {\n private _sentTransactionIds: string[] = []\n\n /**\n * The list of transaction IDs that has been logged thus far.\n */\n get sentTransactionIds(): Readonly<string[]> {\n return this._sentTransactionIds\n }\n\n /**\n * Clear all logged IDs.\n */\n clear() {\n this._sentTransactionIds = []\n }\n\n /**\n * The method that captures raw transactions and stores the transaction IDs.\n */\n logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]) {\n if (Array.isArray(signedTransactions)) {\n for (const stxn of signedTransactions) {\n const decoded = decodeSignedTransaction(stxn)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n } else {\n const decoded = decodeSignedTransaction(signedTransactions)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n }\n\n /** Return a proxy that wraps the given Algodv2 with this transaction logger.\n *\n * @param algod The `Algodv2` to wrap\n * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger\n */\n capture(algod: Algodv2): Algodv2 {\n return new Proxy<Algodv2>(algod, new TransactionLoggingAlgodv2ProxyHandler(this))\n }\n\n /** Wait until all logged transactions IDs appear in the given `Indexer`. */\n async waitForIndexer(indexer: Indexer) {\n await Promise.all(this._sentTransactionIds.map((txnId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())))\n }\n}\n\nclass TransactionLoggingAlgodv2ProxyHandler implements ProxyHandler<Algodv2> {\n private transactionLogger: TransactionLogger\n\n constructor(transactionLogger: TransactionLogger) {\n this.transactionLogger = transactionLogger\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(target: Algodv2, property: string | symbol, receiver: any) {\n if (property === 'sendRawTransaction') {\n return (stxOrStxs: Uint8Array | Uint8Array[]) => {\n this.transactionLogger.logRawTransaction(stxOrStxs)\n return target[property].call(receiver, stxOrStxs)\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (target as any)[property]\n }\n}\n"],"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,EAAA;AAC9C,QAAA,IAAI,CAAC,iBAAiB,GAAG,iBAAiB;;;AAI5C,IAAA,GAAG,CAAC,MAAe,EAAE,QAAyB,EAAE,QAAa,EAAA;AAC3D,QAAA,IAAI,QAAQ,KAAK,oBAAoB,EAAE;YACrC,OAAO,CAAC,SAAoC,KAAI;AAC9C,gBAAA,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;AACnD,aAAC;;;AAGH,QAAA,OAAQ,MAAc,CAAC,QAAQ,CAAC;;AAEnC;;;;"}
1
+ {"version":3,"file":"transaction-logger.mjs","sources":["../../src/testing/transaction-logger.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { runWhenIndexerCaughtUp } from './indexer'\nimport Algodv2 = algosdk.Algodv2\nimport decodeSignedTransaction = algosdk.decodeSignedTransaction\nimport Indexer = algosdk.Indexer\n\n/**\n * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.\n * Useful for automated tests.\n */\nexport class TransactionLogger {\n private _sentTransactionIds: string[] = []\n\n /**\n * The list of transaction IDs that has been logged thus far.\n */\n get sentTransactionIds(): Readonly<string[]> {\n return this._sentTransactionIds\n }\n\n /**\n * Clear all logged IDs.\n */\n clear() {\n this._sentTransactionIds = []\n }\n\n /**\n * The method that captures raw transactions and stores the transaction IDs.\n */\n logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]) {\n if (Array.isArray(signedTransactions)) {\n for (const stxn of signedTransactions) {\n const decoded = decodeSignedTransaction(stxn)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n } else {\n const decoded = decodeSignedTransaction(signedTransactions)\n this._sentTransactionIds.push(decoded.txn.txID())\n }\n }\n\n /** Return a proxy that wraps the given Algodv2 with this transaction logger.\n *\n * @param algod The `Algodv2` to wrap\n * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger\n */\n capture(algod: Algodv2): Algodv2 {\n return new Proxy<Algodv2>(algod, new TransactionLoggingAlgodv2ProxyHandler(this))\n }\n\n /** Wait until all logged transactions IDs appear in the given `Indexer`. */\n async waitForIndexer(indexer: Indexer) {\n if (this._sentTransactionIds.length === 0) return\n const lastTxId = this._sentTransactionIds[this._sentTransactionIds.length - 1]\n await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(lastTxId).do())\n }\n}\n\nclass TransactionLoggingAlgodv2ProxyHandler implements ProxyHandler<Algodv2> {\n private transactionLogger: TransactionLogger\n\n constructor(transactionLogger: TransactionLogger) {\n this.transactionLogger = transactionLogger\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(target: Algodv2, property: string | symbol, receiver: any) {\n if (property === 'sendRawTransaction') {\n return (stxOrStxs: Uint8Array | Uint8Array[]) => {\n this.transactionLogger.logRawTransaction(stxOrStxs)\n return target[property].call(receiver, stxOrStxs)\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (target as any)[property]\n }\n}\n"],"names":[],"mappings":";;;AAGA,IAAO,uBAAuB,GAAG,OAAO,CAAC,uBAAuB;AAGhE;;;AAGG;MACU,iBAAiB,CAAA;AAA9B,IAAA,WAAA,GAAA;QACU,IAAmB,CAAA,mBAAA,GAAa,EAAE;;AAE1C;;AAEG;AACH,IAAA,IAAI,kBAAkB,GAAA;QACpB,OAAO,IAAI,CAAC,mBAAmB;;AAGjC;;AAEG;IACH,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,mBAAmB,GAAG,EAAE;;AAG/B;;AAEG;AACH,IAAA,iBAAiB,CAAC,kBAA6C,EAAA;AAC7D,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACrC,YAAA,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE;AACrC,gBAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC;AAC7C,gBAAA,IAAI,CAA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ch (e) {
859
- throw await this.exposeLogicError(e);
859
+ const logicError = await this.exposeLogicError(e);
860
+ if (logicError instanceof types_logicError.LogicError) {
861
+ let currentLine = logicError.teal_line - logicError.lines - 1;
862
+ const stackWithLines = logicError.stack
863
+ ?.split('\n')
864
+ .map((line) => `${(currentLine += 1)}: ${line}`)
865
+ .join('\n');
866
+ config.Config.logger.error(`${logicError.message}\n\n${stackWithLines}`);
867
+ }
868
+ throw logicError;
860
869
  }
861
870
  }
862
871
  getBoxMethods() {