-
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
5 changed files
with
41 additions
and
35 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
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
37 changes: 37 additions & 0 deletions
37
src/test/java/com/algorand/algosdk/unit/ProgramSanityCheck.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,37 @@ | ||
package com.algorand.algosdk.unit; | ||
|
||
import com.algorand.algosdk.logic.Logic; | ||
import com.algorand.algosdk.util.Encoder; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ProgramSanityCheck { | ||
byte[] seeminglyProgram; | ||
String actualErrMsg; | ||
|
||
@Given("a base64 encoded program bytes for heuristic sanity check {string}") | ||
public void takeB64encodedBytes(String b64encodedBytes) { | ||
seeminglyProgram = Encoder.decodeFromBase64(b64encodedBytes); | ||
} | ||
|
||
@When("I start heuristic sanity check over the bytes") | ||
public void heuristicCheckOverBytes() { | ||
try { | ||
Logic.sanityCheckProgram(seeminglyProgram); | ||
} catch (Exception e) { | ||
actualErrMsg = e.getMessage(); | ||
} | ||
} | ||
|
||
@Then("if there exists an error, the error contains {string}") | ||
public void checkErrorIfMatching(String errMsg) { | ||
if (errMsg != null && !errMsg.isEmpty()) | ||
assertThat(actualErrMsg).contains(errMsg); | ||
else | ||
assertThat(actualErrMsg).isNullOrEmpty(); | ||
} | ||
} |
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