-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
534 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- Skip-Release-Notes | ||
categories: | ||
- title: Bugfixes | ||
labels: | ||
- Bug-Fix | ||
- title: New Features | ||
labels: | ||
- New Feature | ||
- title: Enhancements | ||
labels: | ||
- Enhancement | ||
- title: Not Yet Enabled | ||
labels: | ||
- Not-Yet-Enabled | ||
- title: Other | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Check PR category and type | ||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
types: [opened, synchronize, reopened, labeled, unlabeled, edited] | ||
jobs: | ||
check_label: | ||
runs-on: ubuntu-latest | ||
name: Check PR Category and Type | ||
steps: | ||
- name: Checking for correct number of required github pr labels | ||
uses: mheap/github-action-required-labels@v2 | ||
with: | ||
mode: exactly | ||
count: 1 | ||
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes" | ||
|
||
- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'." | ||
run: | | ||
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then | ||
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
unit: | ||
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application" | ||
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap" | ||
|
||
integration: | ||
mvn test -Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c" | ||
mvn test \ | ||
-Dtest=com.algorand.algosdk.integration.RunCucumberIntegrationTest \ | ||
-Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey_v1 or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap" | ||
|
||
docker-test: | ||
./run_integration_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/main/java/com/algorand/algosdk/logic/SourceMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package com.algorand.algosdk.logic; | ||
|
||
import java.lang.Integer; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* SourceMap class provides parser for source map from | ||
* algod compile endpoint | ||
*/ | ||
public class SourceMap { | ||
|
||
public int version; | ||
public String file; | ||
public String[] sources; | ||
public String[] names; | ||
public String mappings; | ||
|
||
public HashMap<Integer, Integer> pcToLine; | ||
public HashMap<Integer, ArrayList<Integer>> lineToPc; | ||
|
||
public SourceMap(HashMap<String,Object> sourceMap) { | ||
int version = (int) sourceMap.get("version"); | ||
if(version != 3){ | ||
throw new IllegalArgumentException("Only source map version 3 is supported"); | ||
} | ||
this.version = version; | ||
|
||
this.file = (String) sourceMap.get("file"); | ||
this.mappings = (String) sourceMap.get("mappings"); | ||
|
||
this.lineToPc = new HashMap<>(); | ||
this.pcToLine = new HashMap<>(); | ||
|
||
Integer lastLine = 0; | ||
String[] vlqs = this.mappings.split(";"); | ||
for(int i=0; i<vlqs.length; i++){ | ||
ArrayList<Integer> vals = VLQDecoder.decodeSourceMapLine(vlqs[i]); | ||
|
||
// If the vals length >= 3 the lineDelta | ||
if(vals.size() >= 3){ | ||
lastLine = lastLine + vals.get(2); | ||
} | ||
|
||
if(!this.lineToPc.containsKey(lastLine)){ | ||
this.lineToPc.put(lastLine, new ArrayList<Integer>()); | ||
} | ||
|
||
ArrayList<Integer> currList = this.lineToPc.get(lastLine); | ||
currList.add(i); | ||
this.lineToPc.put(lastLine, currList); | ||
|
||
this.pcToLine.put(i, lastLine); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Returns the Integer line number for the passed PC or null if not found | ||
* @param pc the pc (program counter) of the assembled file | ||
* @return the line number or null if not found | ||
*/ | ||
public Integer getLineForPc(Integer pc) { | ||
return this.pcToLine.get(pc); | ||
} | ||
|
||
/** | ||
* Returns the List of PCs for the passed line number | ||
* @param line the line number of the source file | ||
* @return the list of PCs that line generated or empty array if not found | ||
*/ | ||
public ArrayList<Integer> getPcsForLine(Integer line) { | ||
if(!this.pcToLine.containsKey(line)){ | ||
return new ArrayList<Integer>(); | ||
} | ||
return this.lineToPc.get(line); | ||
} | ||
|
||
private static class VLQDecoder { | ||
// VLQDecoder for decoding the VLQ values returned for source map | ||
// based on the decoder implementation here: https://github.com/algorand/go-algorand-sdk/blob/develop/logic/source_map.go | ||
|
||
private static final String b64table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
private static final int vlqShiftSize = 5; | ||
private static final int vlqFlag = 1 << vlqShiftSize; | ||
private static final int vlqMask = vlqFlag - 1; | ||
|
||
public static ArrayList<Integer> decodeSourceMapLine(String vlq) { | ||
|
||
ArrayList<Integer> results = new ArrayList<>(); | ||
int value = 0; | ||
int shift = 0; | ||
|
||
for(int i=0; i<vlq.length(); i++){ | ||
int digit = b64table.indexOf(vlq.charAt(i)); | ||
|
||
value |= (digit & vlqMask) << shift; | ||
|
||
if((digit & vlqFlag) > 0) { | ||
shift += vlqShiftSize; | ||
continue; | ||
} | ||
|
||
if((value&1)>0){ | ||
value = (value >> 1) * -1; | ||
}else{ | ||
value = value >> 1; | ||
} | ||
|
||
results.add(value); | ||
|
||
// Reset | ||
value = 0; | ||
shift = 0; | ||
} | ||
|
||
return results; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.