From 9ac12bf95d4b8d3b8760e3c70059ba47ddeb18c7 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 21 Jun 2022 12:17:34 -0400 Subject: [PATCH 01/20] adding source map decoder --- src/logic/sourcemap.ts | 133 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/logic/sourcemap.ts diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts new file mode 100644 index 000000000..fe996f7dd --- /dev/null +++ b/src/logic/sourcemap.ts @@ -0,0 +1,133 @@ +/* eslint-disable no-bitwise */ + +// Adapted from https://github.com/Rich-Harris/vlq, thanks! + +const alphabet = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + +const charToInt = {}; +const intToChar = {}; +alphabet.split('').forEach((char, i) => { + charToInt[char] = i; + intToChar[i] = char; +}); + +export function base64VLQDecode(VLQVal: string) { + const result: number[] = []; + + let shift = 0; + let value = 0; + + for (let i = 0; i < VLQVal.length; i += 1) { + let intVal = charToInt[VLQVal[i]]; + + if (intVal === undefined) + throw new Error(`Invalid character (${VLQVal[i]})`); + + const hasContinueBit = intVal & 32; + + intVal &= 31; + value += intVal << shift; + + if (hasContinueBit) { + shift += 5; + } else { + const shouldNegate = value & 1; + + value >>>= 1; + + if (shouldNegate) { + result.push(value === 0 ? -0x80000000 : -value); + } else { + result.push(value); + } + + value = 0; + shift = 0; + } + } + + return result; +} + +function encodeInteger(n: number) { + let result = ''; + + let num = n; + + if (num < 0) num = (-num << 1) | 1; + else num <<= 1; + + do { + let clamped = num & 31; + num >>>= 5; + + if (num > 0) clamped |= 32; + + result += intToChar[clamped]; + } while (num > 0); + + return result; +} + +export function base64VLQEncode(val: number | number[]) { + if (typeof val === 'number') return encodeInteger(val); + return val.map((i) => encodeInteger(i)).join(); +} + +export class SourceMap { + version: number; + sources: string[]; + names: string[]; + mapping: string; + delimiter: string; + comments: string[]; + + pcToLine: { [key: number]: number }; + lineToPc: { [key: number]: number[] }; + + constructor( + version: number, + sources: string[], + names: string[], + mapping: string, + delimiter: string = ';', + comments?: string[] + ) { + this.version = version; + this.sources = sources; + this.names = names; + this.mapping = mapping; + this.delimiter = delimiter; + this.comments = comments === undefined ? [] : comments; + + const rawMapping = this.mapping.split(this.delimiter); + const pcList = rawMapping.map((m) => { + const decoded = base64VLQDecode(m); + if (decoded.length > 1) return decoded[2]; + return undefined; + }); + + let lastLine = 0; + for (const [idx, val] of pcList.entries()) { + if (val !== undefined) { + if (!(val in this.lineToPc)) this.lineToPc[val] = []; + this.lineToPc[val].push(idx); + lastLine = val; + } + this.pcToLine[idx] = lastLine; + } + } + + getLineForPc(pc: number): number { + return this.pcToLine[pc]; + } + + getPcsForLine(line: number): number[] { + return this.lineToPc[line]; + } + + getCommentForLine(line: number): string { + return this.comments[line]; + } +} From 2344ed6a8ee37d391953b1a7b247e1c30034b4cb Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 22 Jun 2022 08:23:12 -0400 Subject: [PATCH 02/20] replace implemented funcs with vlq dep --- package-lock.json | 13 ++++++- package.json | 3 +- src/logic/sourcemap.ts | 88 ++---------------------------------------- 3 files changed, 17 insertions(+), 87 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e7c16c46..91b03c86c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,8 @@ "json-bigint": "^1.0.0", "superagent": "^6.1.0", "tweetnacl": "^1.0.3", - "url-parse": "^1.5.1" + "url-parse": "^1.5.1", + "vlq": "^2.0.4" }, "devDependencies": { "@types/json-bigint": "^1.0.0", @@ -7783,6 +7784,11 @@ "extsprintf": "^1.2.0" } }, + "node_modules/vlq": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-2.0.4.tgz", + "integrity": "sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA==" + }, "node_modules/vscode-oniguruma": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.6.2.tgz", @@ -14311,6 +14317,11 @@ "extsprintf": "^1.2.0" } }, + "vlq": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-2.0.4.tgz", + "integrity": "sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA==" + }, "vscode-oniguruma": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.6.2.tgz", diff --git a/package.json b/package.json index 1cef3a9b7..ca0c69f0b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "json-bigint": "^1.0.0", "superagent": "^6.1.0", "tweetnacl": "^1.0.3", - "url-parse": "^1.5.1" + "url-parse": "^1.5.1", + "vlq": "^2.0.4" }, "devDependencies": { "@types/json-bigint": "^1.0.0", diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index fe996f7dd..4f101890b 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -1,79 +1,4 @@ -/* eslint-disable no-bitwise */ - -// Adapted from https://github.com/Rich-Harris/vlq, thanks! - -const alphabet = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - -const charToInt = {}; -const intToChar = {}; -alphabet.split('').forEach((char, i) => { - charToInt[char] = i; - intToChar[i] = char; -}); - -export function base64VLQDecode(VLQVal: string) { - const result: number[] = []; - - let shift = 0; - let value = 0; - - for (let i = 0; i < VLQVal.length; i += 1) { - let intVal = charToInt[VLQVal[i]]; - - if (intVal === undefined) - throw new Error(`Invalid character (${VLQVal[i]})`); - - const hasContinueBit = intVal & 32; - - intVal &= 31; - value += intVal << shift; - - if (hasContinueBit) { - shift += 5; - } else { - const shouldNegate = value & 1; - - value >>>= 1; - - if (shouldNegate) { - result.push(value === 0 ? -0x80000000 : -value); - } else { - result.push(value); - } - - value = 0; - shift = 0; - } - } - - return result; -} - -function encodeInteger(n: number) { - let result = ''; - - let num = n; - - if (num < 0) num = (-num << 1) | 1; - else num <<= 1; - - do { - let clamped = num & 31; - num >>>= 5; - - if (num > 0) clamped |= 32; - - result += intToChar[clamped]; - } while (num > 0); - - return result; -} - -export function base64VLQEncode(val: number | number[]) { - if (typeof val === 'number') return encodeInteger(val); - return val.map((i) => encodeInteger(i)).join(); -} +import vlq from 'vlq'; export class SourceMap { version: number; @@ -81,7 +6,6 @@ export class SourceMap { names: string[]; mapping: string; delimiter: string; - comments: string[]; pcToLine: { [key: number]: number }; lineToPc: { [key: number]: number[] }; @@ -91,19 +15,17 @@ export class SourceMap { sources: string[], names: string[], mapping: string, - delimiter: string = ';', - comments?: string[] + delimiter: string = ';' ) { this.version = version; this.sources = sources; this.names = names; this.mapping = mapping; this.delimiter = delimiter; - this.comments = comments === undefined ? [] : comments; const rawMapping = this.mapping.split(this.delimiter); const pcList = rawMapping.map((m) => { - const decoded = base64VLQDecode(m); + const decoded = vlq.decode(m); if (decoded.length > 1) return decoded[2]; return undefined; }); @@ -126,8 +48,4 @@ export class SourceMap { getPcsForLine(line: number): number[] { return this.lineToPc[line]; } - - getCommentForLine(line: number): string { - return this.comments[line]; - } } From 033972cef8cf1c62ffa6584030539e198713a76f Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 22 Jun 2022 08:49:20 -0400 Subject: [PATCH 03/20] tweak sourcemap to accept obj init --- src/logic/sourcemap.ts | 30 +++++++++++++++++++----------- src/main.ts | 2 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index 4f101890b..002348d7f 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -1,4 +1,4 @@ -import vlq from 'vlq'; +import * as vlq from 'vlq'; export class SourceMap { version: number; @@ -10,26 +10,34 @@ export class SourceMap { pcToLine: { [key: number]: number }; lineToPc: { [key: number]: number[] }; - constructor( - version: number, - sources: string[], - names: string[], - mapping: string, - delimiter: string = ';' - ) { + constructor({ + version, + sources, + names, + mapping, + delimiter, + }: { + version: number; + sources: string[]; + names: string[]; + mapping: string; + delimiter?: string; + }) { this.version = version; this.sources = sources; this.names = names; this.mapping = mapping; - this.delimiter = delimiter; + this.delimiter = delimiter === undefined ? ';' : delimiter; - const rawMapping = this.mapping.split(this.delimiter); - const pcList = rawMapping.map((m) => { + const pcList = this.mapping.split(this.delimiter).map((m) => { const decoded = vlq.decode(m); if (decoded.length > 1) return decoded[2]; return undefined; }); + this.pcToLine = {}; + this.lineToPc = {}; + let lastLine = 0; for (const [idx, val] of pcList.entries()) { if (val !== undefined) { diff --git a/src/main.ts b/src/main.ts index 4d1c80611..12d853485 100644 --- a/src/main.ts +++ b/src/main.ts @@ -168,6 +168,8 @@ export { appendSignMultisigTransaction, multisigAddress, } from './multisig'; +export { SourceMap } from './logic/sourcemap'; + export const LogicTemplates = LogicTemplatesCommonJSExport.default; export * from './dryrun'; From 12e19f28e504ba588b6c2e4213c1ad031b128eb6 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 10:57:14 -0400 Subject: [PATCH 04/20] add sourcemmap query param --- src/client/client.ts | 5 +++-- src/client/v2/algod/compile.ts | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 2fc35b085..8f7ece2e8 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -250,7 +250,8 @@ export default class HTTPClient { async post( relativePath: string, data: any, - requestHeaders: Record = {} + requestHeaders: Record = {}, + query?: Query ): Promise { const fullHeaders = { 'content-type': 'application/json', @@ -261,7 +262,7 @@ export default class HTTPClient { const res = await this.bc.post( relativePath, HTTPClient.serializeData(data, fullHeaders), - undefined, + query, fullHeaders ); diff --git a/src/client/v2/algod/compile.ts b/src/client/v2/algod/compile.ts index f24a94f42..85f02f182 100644 --- a/src/client/v2/algod/compile.ts +++ b/src/client/v2/algod/compile.ts @@ -28,6 +28,11 @@ export default class Compile extends JSONRequest { return `/v2/teal/compile`; } + sourcemap(map: boolean = true) { + this.query.sourcemap = map; + return this; + } + /** * Executes compile * @param headers - A headers object @@ -37,7 +42,8 @@ export default class Compile extends JSONRequest { const res = await this.c.post( this.path(), Buffer.from(this.source), - txHeaders + txHeaders, + this.query ); return res.body; } From d57e0353019b7a6d92ddad3b19e4078a54efa10b Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 12:11:31 -0400 Subject: [PATCH 05/20] implement tests --- Makefile | 3 ++- src/logic/sourcemap.ts | 5 +++-- tests/cucumber/docker/run_docker.sh | 4 +++- tests/cucumber/steps/steps.js | 26 ++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bf31b7975..1248aef01 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ unit: - node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + #node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + node_modules/.bin/cucumber-js --tags "@unit.sourcemap.linetopc or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js integration: node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index 002348d7f..e0bac033d 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -35,8 +35,9 @@ export class SourceMap { return undefined; }); - this.pcToLine = {}; - this.lineToPc = {}; + // Init to 0,0 + this.pcToLine = { 0: 0 }; + this.lineToPc = { 0: [0] }; let lastLine = 0; for (const [idx, val] of pcList.entries()) { diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index 72e6bb977..3cf91769a 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -7,11 +7,13 @@ rm -rf test-harness rm -rf tests/cucumber/features # clone test harness -git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch sourcemap https://github.com/algorand/algorand-sdk-testing.git test-harness # move feature files and example files to destination mv test-harness/features tests/cucumber/features +exit + if [ $TEST_BROWSER == "chrome" ]; then # use latest version of chromedriver for compatability with the current Chrome version npm install chromedriver@latest diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 8f03544f6..130cfdc42 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -5341,6 +5341,32 @@ module.exports = function getSteps(options) { } ); + Given('a source map json file {string}', async function (srcmap) { + const js = parseJSON(await loadResource(srcmap)); + this.sourcemap = new algosdk.SourceMap(js); + }); + + Then( + 'getting the line that corresponds to the PC {string} produces {string}', + function (_pc, _line) { + const pc = parseInt(_pc); + const line = parseInt(_line); + + const actualLine = this.sourcemap.getLineForPc(pc); + assert.equal(actualLine, line); + } + ); + + Then( + 'getting the first PC that corresponds to the line {string} produces {string}', + function (_line, _pc) { + const pc = parseInt(_pc); + const line = parseInt(_line); + const actualPcs = this.sourcemap.getPcsForLine(line); + assert.equal(actualPcs[0], pc); + } + ); + if (!options.ignoreReturn) { return steps; } From cfeb9a14378239770c625ae59bba33bb9f7324a1 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 12:13:28 -0400 Subject: [PATCH 06/20] fix makefile --- Makefile | 3 +-- tests/cucumber/docker/run_docker.sh | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1248aef01..18a5fbdb8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ unit: - #node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js - node_modules/.bin/cucumber-js --tags "@unit.sourcemap.linetopc or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap.linetopc or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js integration: node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index 3cf91769a..ef64a794f 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -12,8 +12,6 @@ git clone --single-branch --branch sourcemap https://github.com/algorand/algoran # move feature files and example files to destination mv test-harness/features tests/cucumber/features -exit - if [ $TEST_BROWSER == "chrome" ]; then # use latest version of chromedriver for compatability with the current Chrome version npm install chromedriver@latest From 5392e25f37bcac6071cfc0b4dc5a8aa55a1a614e Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 12:30:52 -0400 Subject: [PATCH 07/20] use new tests --- tests/cucumber/docker/run_docker.sh | 2 ++ tests/cucumber/steps/steps.js | 24 +++++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index ef64a794f..3cf91769a 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -12,6 +12,8 @@ git clone --single-branch --branch sourcemap https://github.com/algorand/algoran # move feature files and example files to destination mv test-harness/features tests/cucumber/features +exit + if [ $TEST_BROWSER == "chrome" ]; then # use latest version of chromedriver for compatability with the current Chrome version npm install chromedriver@latest diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 130cfdc42..5b1bdfb5d 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -5347,23 +5347,13 @@ module.exports = function getSteps(options) { }); Then( - 'getting the line that corresponds to the PC {string} produces {string}', - function (_pc, _line) { - const pc = parseInt(_pc); - const line = parseInt(_line); - - const actualLine = this.sourcemap.getLineForPc(pc); - assert.equal(actualLine, line); - } - ); - - Then( - 'getting the first PC that corresponds to the line {string} produces {string}', - function (_line, _pc) { - const pc = parseInt(_pc); - const line = parseInt(_line); - const actualPcs = this.sourcemap.getPcsForLine(line); - assert.equal(actualPcs[0], pc); + 'the string composed of pc:line number equals {string}', + function (mapping) { + const buff = []; + for (const [pc, line] of Object.entries(this.sourcemap.pcToLine)) { + buff.push(`${pc}:${line}`); + } + assert.equal(buff.join(';'), mapping); } ); From 97b571645b25f1352336e7a7ed83df3dd1b599f0 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 12:36:39 -0400 Subject: [PATCH 08/20] Remove undefined test --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 18a5fbdb8..f67f5f8dc 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ unit: - node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap.linetopc or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js integration: node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js From 626a246f119e0aa440134e1c55d8f22dd9fc4308 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 24 Jun 2022 14:35:00 -0400 Subject: [PATCH 09/20] revert docker shell script --- tests/cucumber/docker/run_docker.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index 3cf91769a..41f93de0b 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -7,12 +7,11 @@ rm -rf test-harness rm -rf tests/cucumber/features # clone test harness -git clone --single-branch --branch sourcemap https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness # move feature files and example files to destination mv test-harness/features tests/cucumber/features -exit if [ $TEST_BROWSER == "chrome" ]; then # use latest version of chromedriver for compatability with the current Chrome version From de180d98e6715384a1532a3a68f50de05d30338f Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 28 Jun 2022 09:20:13 -0400 Subject: [PATCH 10/20] adding backwards compat for mapping and version check --- src/logic/sourcemap.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index e0bac033d..7f9dc69c0 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -4,8 +4,7 @@ export class SourceMap { version: number; sources: string[]; names: string[]; - mapping: string; - delimiter: string; + mappings: string; pcToLine: { [key: number]: number }; lineToPc: { [key: number]: number[] }; @@ -14,22 +13,30 @@ export class SourceMap { version, sources, names, + mappings, mapping, - delimiter, }: { version: number; sources: string[]; names: string[]; - mapping: string; - delimiter?: string; + mappings?: string; + mapping?: string; }) { this.version = version; this.sources = sources; this.names = names; - this.mapping = mapping; - this.delimiter = delimiter === undefined ? ';' : delimiter; + // Backwards compat + this.mappings = mapping !== undefined ? mapping : mappings; - const pcList = this.mapping.split(this.delimiter).map((m) => { + if (this.version !== 3) + throw new Error(`Only version 3 is supported, got ${this.version}`); + + if (this.mappings === undefined) + throw new Error( + 'mapping undefined, please specify in key `mapping` or `mappings`' + ); + + const pcList = this.mappings.split(';').map((m) => { const decoded = vlq.decode(m); if (decoded.length > 1) return decoded[2]; return undefined; From 5567bdb4f595d5b89c6ca9b75ac6d9c8268da835 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 5 Jul 2022 10:57:48 -0400 Subject: [PATCH 11/20] update with correct mapping --- src/logic/sourcemap.ts | 26 ++++++++++++-------------- tests/cucumber/docker/run_docker.sh | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index 7f9dc69c0..41000f7a5 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -14,19 +14,16 @@ export class SourceMap { sources, names, mappings, - mapping, }: { version: number; sources: string[]; names: string[]; - mappings?: string; - mapping?: string; + mappings: string; }) { this.version = version; this.sources = sources; this.names = names; - // Backwards compat - this.mappings = mapping !== undefined ? mapping : mappings; + this.mappings = mappings; if (this.version !== 3) throw new Error(`Only version 3 is supported, got ${this.version}`); @@ -42,18 +39,19 @@ export class SourceMap { return undefined; }); - // Init to 0,0 - this.pcToLine = { 0: 0 }; - this.lineToPc = { 0: [0] }; + this.pcToLine = {}; + this.lineToPc = {}; let lastLine = 0; - for (const [idx, val] of pcList.entries()) { - if (val !== undefined) { - if (!(val in this.lineToPc)) this.lineToPc[val] = []; - this.lineToPc[val].push(idx); - lastLine = val; + for (const [pc, lineDelta] of pcList.entries()) { + if (lineDelta !== undefined) { + const lineNum = lastLine + lineDelta; + if (!(lineNum in this.lineToPc)) this.lineToPc[lineNum] = []; + + this.lineToPc[lineNum].push(pc); + lastLine = lineNum; } - this.pcToLine[idx] = lastLine; + this.pcToLine[pc] = lastLine; } } diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index 41f93de0b..c1eb2ac0a 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -7,7 +7,7 @@ rm -rf test-harness rm -rf tests/cucumber/features # clone test harness -git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch sourcemap https://github.com/algorand/algorand-sdk-testing.git test-harness # move feature files and example files to destination mv test-harness/features tests/cucumber/features From 2bc3ee63df2f82bcfefb0d88e986d63b1c6aa2af Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Mon, 11 Jul 2022 08:18:53 -0400 Subject: [PATCH 12/20] tweak logic, add comments about undefined lineDelta --- src/logic/sourcemap.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index 41000f7a5..5e0fb1eef 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -30,7 +30,7 @@ export class SourceMap { if (this.mappings === undefined) throw new Error( - 'mapping undefined, please specify in key `mapping` or `mappings`' + 'mapping undefined, cannot build source map without `mapping`' ); const pcList = this.mappings.split(';').map((m) => { @@ -44,13 +44,15 @@ export class SourceMap { let lastLine = 0; for (const [pc, lineDelta] of pcList.entries()) { + // If the delta is not undefined, the lastLine should be updated with + // lastLine + the delta if (lineDelta !== undefined) { - const lineNum = lastLine + lineDelta; - if (!(lineNum in this.lineToPc)) this.lineToPc[lineNum] = []; - - this.lineToPc[lineNum].push(pc); - lastLine = lineNum; + lastLine += lineDelta; } + + if (!(lastLine in this.lineToPc)) this.lineToPc[lastLine] = []; + + this.lineToPc[lastLine].push(pc); this.pcToLine[pc] = lastLine; } } From d8c22e7115fa2a956176df35bf50f485f677164b Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Mon, 11 Jul 2022 09:11:54 -0400 Subject: [PATCH 13/20] maybe? --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index a9adddb18..ee8fb0f72 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,9 @@ "webpack": "^5.38.1", "webpack-cli": "^4.7.2" }, + "optionalDependencies": { + "fsevents": "2.1.2" + }, "scripts": { "test": "node -r ts-node/register tests/mocha.js", "prepare": "npm run build", From 7034948481e76e8ae9d1b93c5e694253d14e1daa Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Mon, 11 Jul 2022 09:13:33 -0400 Subject: [PATCH 14/20] re-up package-lock --- package-lock.json | 94 +++++++++++++++++++++++------------------------ package.json | 6 +-- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2af4676d7..81e6147a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,6 +56,9 @@ "typescript": "^4.2.3", "webpack": "^5.38.1", "webpack-cli": "^4.7.2" + }, + "optionalDependencies": { + "fsevents": "2.1.2" } }, "node_modules/@babel/code-frame": { @@ -1494,6 +1497,20 @@ "fsevents": "~2.3.1" } }, + "node_modules/chokidar/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -3338,6 +3355,20 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "node_modules/fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "deprecated": "\"Please update to latest v2.3 or v2.2\"", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -5770,12 +5801,6 @@ "node": ">= 0.8" } }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true - }, "node_modules/path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -5985,11 +6010,6 @@ "node": ">=0.6" } }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -6240,11 +6260,6 @@ "node": ">=0.10.0" } }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" - }, "node_modules/resolve": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", @@ -7685,15 +7700,6 @@ "punycode": "^2.1.0" } }, - "node_modules/url-parse": { - "version": "1.5.8", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.8.tgz", - "integrity": "sha512-9JZ5zDrn9wJoOy/t+rH00HHejbU8dq9VsOYVu272TYDrCiyVAgHKUSpPh3ruZIpv8PMVR+NXLZvfRPJv8xAcQw==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "node_modules/util": { "version": "0.12.4", "resolved": "https://registry.npmjs.org/util/-/util-0.12.4.tgz", @@ -9494,6 +9500,15 @@ "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.5.0" + }, + "dependencies": { + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + } } }, "chownr": { @@ -10959,6 +10974,12 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "optional": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -12749,11 +12770,6 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, - "path-browserify": { - "version": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -12915,11 +12931,6 @@ "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", "dev": true }, - "querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -13107,11 +13118,6 @@ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" - }, "resolve": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", @@ -14223,14 +14229,6 @@ "punycode": "^2.1.0" } }, - "url-parse": { - "version": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.8.tgz", - "integrity": "sha512-9JZ5zDrn9wJoOy/t+rH00HHejbU8dq9VsOYVu272TYDrCiyVAgHKUSpPh3ruZIpv8PMVR+NXLZvfRPJv8xAcQw==", - "requires": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "util": { "version": "0.12.4", "resolved": "https://registry.npmjs.org/util/-/util-0.12.4.tgz", diff --git a/package.json b/package.json index ee8fb0f72..aaff3a56f 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,9 @@ "tweetnacl": "^1.0.3", "vlq": "^2.0.4" }, + "optionalDependencies": { + "fsevents": "2.1.2" + }, "devDependencies": { "@types/json-bigint": "^1.0.0", "@types/mocha": "^8.2.2", @@ -65,9 +68,6 @@ "webpack": "^5.38.1", "webpack-cli": "^4.7.2" }, - "optionalDependencies": { - "fsevents": "2.1.2" - }, "scripts": { "test": "node -r ts-node/register tests/mocha.js", "prepare": "npm run build", From c2a342173985c60813a19c499bad1f973c820652 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 12 Jul 2022 11:23:20 -0400 Subject: [PATCH 15/20] adding new tests --- Makefile | 2 +- src/logic/sourcemap.ts | 4 ++-- tests/cucumber/docker/run_docker.sh | 1 - tests/cucumber/steps/steps.js | 36 +++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f67f5f8dc..f8b1f681e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ unit: - node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap.pctoline" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js integration: node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index 5e0fb1eef..d0fd2ca3b 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -57,11 +57,11 @@ export class SourceMap { } } - getLineForPc(pc: number): number { + getLineForPc(pc: number): number | undefined { return this.pcToLine[pc]; } - getPcsForLine(line: number): number[] { + getPcsForLine(line: number): number[] | undefined { return this.lineToPc[line]; } } diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index c1eb2ac0a..ef64a794f 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -12,7 +12,6 @@ git clone --single-branch --branch sourcemap https://github.com/algorand/algoran # move feature files and example files to destination mv test-harness/features tests/cucumber/features - if [ $TEST_BROWSER == "chrome" ]; then # use latest version of chromedriver for compatability with the current Chrome version npm install chromedriver@latest diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 5b1bdfb5d..7977791b8 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -5357,6 +5357,42 @@ module.exports = function getSteps(options) { } ); + Then( + 'getting the line associated with a pc {string} equals {string}', + function (pc, expectedLine) { + const actualLine = this.sourcemap.getLineForPc(parseInt(pc)); + assert.equal(actualLine, parseInt(expectedLine)); + } + ); + + Then( + 'getting the last pc associated with a line {string} equals {string}', + function (line, expectedPc) { + const actualPcs = this.sourcemap.getPcsForLine(parseInt(line)); + assert.equal(actualPcs.pop(), parseInt(expectedPc)); + } + ); + + When( + 'I compile a teal program {string} with mapping enabled', + async function (teal) { + const tealSrc = await loadResource(teal); + const compiledResponse = await this.v2Client + .compile(tealSrc) + .sourcemap(true) + .do(); + this.rawSourceMap = JSON.stringify(compiledResponse.sourcemap); + } + ); + + Then( + 'the resulting source map is the same as the json {string}', + async function (expectedJsonPath) { + const expected = await loadResource(expectedJsonPath); + assert.equal(this.rawSourceMap, expected.toString().trim()); + } + ); + if (!options.ignoreReturn) { return steps; } From fde8bcb46564ec1f7b7c0610b45d8376bdd742ca Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 13 Jul 2022 04:45:09 -0400 Subject: [PATCH 16/20] adding source map tag to integration tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f8b1f681e..c0dbe8307 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ unit: node_modules/.bin/cucumber-js --tags "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.keyreg or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.responses.unlimited_assets or @unit.indexer.ledger_refactoring or @unit.algod.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js integration: - node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js + node_modules/.bin/cucumber-js --tags "@algod or @assets or @auction or @kmd or @send or @indexer or @rekey or @send.keyregtxn or @dryrun or @compile or @applications or @indexer.applications or @applications.verified or @indexer.231 or @abi or @c2c or @compile.sourcemap" tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js docker-test: ./tests/cucumber/docker/run_docker.sh From b7c1631aa3ce5754eaacc742dbe04504000c8a11 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 13 Jul 2022 09:22:00 -0400 Subject: [PATCH 17/20] update to master branch of sdk testing repo --- tests/cucumber/docker/run_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index ef64a794f..72e6bb977 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -7,7 +7,7 @@ rm -rf test-harness rm -rf tests/cucumber/features # clone test harness -git clone --single-branch --branch sourcemap https://github.com/algorand/algorand-sdk-testing.git test-harness +git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness # move feature files and example files to destination mv test-harness/features tests/cucumber/features From 5e94b7bd47d3924c6aec314b6a33d53dcb614bef Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 15 Jul 2022 08:08:07 -0400 Subject: [PATCH 18/20] fix conditional --- src/logic/sourcemap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logic/sourcemap.ts b/src/logic/sourcemap.ts index d0fd2ca3b..b00564911 100644 --- a/src/logic/sourcemap.ts +++ b/src/logic/sourcemap.ts @@ -35,7 +35,7 @@ export class SourceMap { const pcList = this.mappings.split(';').map((m) => { const decoded = vlq.decode(m); - if (decoded.length > 1) return decoded[2]; + if (decoded.length > 2) return decoded[2]; return undefined; }); From d708c35ed3f1ffa6c7c8f5e716b11e2ea1e8baa0 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 15 Jul 2022 09:02:25 -0400 Subject: [PATCH 19/20] Update tests/cucumber/steps/steps.js Co-authored-by: Michael Diamant --- tests/cucumber/steps/steps.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 7977791b8..a46d7da32 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -5349,10 +5349,7 @@ module.exports = function getSteps(options) { Then( 'the string composed of pc:line number equals {string}', function (mapping) { - const buff = []; - for (const [pc, line] of Object.entries(this.sourcemap.pcToLine)) { - buff.push(`${pc}:${line}`); - } + const buff = Object.entries(this.sourcemap.pcToLine).map(([pc, line]) => `${pc}:${line}`); assert.equal(buff.join(';'), mapping); } ); From 8489632b730774229e70b7ac20fd5e554b62259a Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 15 Jul 2022 11:52:49 -0400 Subject: [PATCH 20/20] prettier? --- tests/cucumber/steps/steps.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 7977791b8..5f0607ee5 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -5349,10 +5349,9 @@ module.exports = function getSteps(options) { Then( 'the string composed of pc:line number equals {string}', function (mapping) { - const buff = []; - for (const [pc, line] of Object.entries(this.sourcemap.pcToLine)) { - buff.push(`${pc}:${line}`); - } + const buff = Object.entries(this.sourcemap.pcToLine).map( + ([pc, line]) => `${pc}:${line}` + ); assert.equal(buff.join(';'), mapping); } );