Skip to content

Commit

Permalink
update test script to check output (#336)
Browse files Browse the repository at this point in the history
* formatting the test, removing old code

* new test case with less going on

* updating primops test case to use local vars not fields

* scala style, whitespace, a new util function, comments, variable declaration first cut

* updating bool literal test to refer to a local rather than a field

* no prizes for guessing where i copied this file from

* assign instead of declare; removing type annotations from declarations output with a comment about why

* whitespace

* similar enough case for decls, so might as well

* updating ifthenelse test case to use locals not fields, fixing a bug in the output code

* adding case for if, since it\'s so similar to ifthenelse

* intconst test to locals not fields

* removing sstore for local variables

* fixing scaladocs

* updating simplecall test to  not use fields

* adding a top level return to simple call so its testable

* scala style

* adding a slightly hacky script to run all the ganache tests locally in one pass, emulating what will happen in Travis without quite as much overhead

* scraps

* better shell scripting practices

* more shell tweaks

* Adding some logic to make local testing of specific files easier

* shell script hacking; this will likely break on travis beacuse of unresolved issues with jq

* moving a comment around; it's valid scala to have it where it was, but the IDE doesn't know how to parse it

* whitespace and comments in testing script

* adding a call to eth_call and a check on the result

* updating travis build to include sha3 utility

* fixed a type in a bash variable name, updated the hash implemention i'm using, now computing the right hash at least

* possibly better travis install commands

* apt command change

* adding rhash to the build, to see if that works better

* more hashing attempts

* code to pick between which hash implementation based on uname

* cutting hash to first 8 bytes in travis, adding messages

* updating call to use the contract address

* stripping quotes off the contract address, adding a dire warning about missing JSON fields, moving latest out of the dictionary part of the params object

* guarded hack for running something locally, but i still want to spin up travis for the end of the day

* Adding more gas; updating check on testexp and expected so it warns (at least textually; return value is unchanged); updating hostname check so it works

* found a duplicated 0x with michael

* checking against expected

* comments

* Adding check on getTransactionRecipt status code

* Adding check on getTransactionRecipt status code

* updating comments on testing script

* removing redundant braces, some binaries from solidity code for local testing, using an easier allocation function

* commenting out the failure count incrementer so i can check travis for all the tests

* off by one error

* removing binaries for local testing and commented line from travis script

* fixed a bug with not assigning back to the temp var in the function call case; the simplecall test now passes

* fixing Return test

* updating Travis travis script to only make a call to eth_call if the JSON describing a test includes an expression to call and to mark it as an error if eth_call gets an error back

* adding test expected values to other simple tests

* test script output

* breaking primops test up into one test per operator

* copy paste typos

* typos, small fixes

* splitting subtraction test into two cases

* typos

* adding a rough summary of what passed and failed to the output for readability in travis

* quick summary

* updating codegen to fix logical negation, which entailed fixing bugs in if-then-else and the call to translate expression from translate statement

* actually fixing the bug in if-then-else; adding a new test case that showed it to me

* removing the json file for a failing test per #337 and #335

* removing JSON per #338

* adding a simple script that tells me which tests are defined but without json so they aren't being run

* adding a warning about skipped tests

* Adding comments to convenience shell scripts
  • Loading branch information
ivoysey committed May 26, 2021
1 parent eba0ad5 commit 0c8a5cc
Show file tree
Hide file tree
Showing 53 changed files with 621 additions and 140 deletions.
2 changes: 0 additions & 2 deletions Obsidian_Runtime/src/main/yul_templates/object.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object "{{creationObject}}" {

{{! todo: is 4 a magic number or should it be generated based on the object in question? check the ABI }}
if iszero(lt(calldatasize(), 4)) {
{
{{#dispatch}}
{{! TODO 224 is a magic number offset to shift to follow the spec above; check that it's right }}
let selector := shr(224, calldataload(0))
Expand Down Expand Up @@ -95,5 +94,4 @@ object "{{creationObject}}" {
{{runtimeSubObjects}}
}
{{subObjects}}
}
}
14 changes: 14 additions & 0 deletions bin/run_obs_yul_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash


# this is a wrapper on the run_obs_yul script, which produces yul for the ganache tests programs
# without actually running them, that runs it on all of the test programs in a batch mode. it is
# kind of a hack but it works for now and saves a rewrite of the run_obs_yul script.

for f in $(run_obs_yul.sh | tail -n +2)
do
echo "---------------------------"
echo $f
echo "---------------------------"
run_obs_yul.sh "$f"
done
6 changes: 6 additions & 0 deletions bin/skipped_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# when run from the top level of the repo, this prints out the names of the obsidian files
# in the ganache tests that do not also have a json file paired with them -- that means that
# they won't be run by travis. this also appears in the output of the travis script at the very top.
comm -13 <(ls resources/tests/GanacheTests/*.json | xargs basename -s '.json') <(ls resources/tests/GanacheTests/*.obs | xargs basename -s '.obs')
4 changes: 3 additions & 1 deletion resources/tests/GanacheTests/AssignLocalAdd.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1
"numaccts" : 1,
"testexp" : "main()",
"expected" : "17"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/AssignLocalAdd.obs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ main contract AssignLocalAdd{
x = 5 + 12;
return;
}

transaction main() returns int {
int x = 5 + 12;
return x;
}
}
4 changes: 3 additions & 1 deletion resources/tests/GanacheTests/BoolLiteral.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1
"numaccts" : 1,
"testexp" : "main()",
"expected" : "0"
}
4 changes: 4 additions & 0 deletions resources/tests/GanacheTests/BoolLiteral.obs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ main contract BoolLiteral{
x = true;
x = false;
}

transaction main() returns bool {
return false;
}
}
4 changes: 3 additions & 1 deletion resources/tests/GanacheTests/If.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1
"numaccts" : 1,
"testexp" : "main()",
"expected" : "1"
}
12 changes: 10 additions & 2 deletions resources/tests/GanacheTests/If.obs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ main contract If {
transaction iftest() {
int x;
if (true) {
x = 1;
}
x = 1;
}
return;
}

transaction main() returns int {
int x = 0;
if (true) {
x = 1;
}
return x;
}
}
4 changes: 3 additions & 1 deletion resources/tests/GanacheTests/IfThenElse.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1
"numaccts" : 1,
"testexp" : "main()",
"expected" : "90"
}
10 changes: 10 additions & 0 deletions resources/tests/GanacheTests/IfThenElse.obs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ main contract IfThenElse {
}
return;
}

transaction main() returns int {
int x = 9;
if (false) {
x = 50;
} else {
x = 90;
}
return x;
}
}
4 changes: 3 additions & 1 deletion resources/tests/GanacheTests/IntConst.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1
"numaccts" : 1,
"testexp" : "main()",
"expected" : "12"
}
6 changes: 5 additions & 1 deletion resources/tests/GanacheTests/IntConst.obs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
main contract IntConst{
transaction intconst() {
int x;
x = 4;
x = 12;
return;
}

transaction main() returns int {
return 12;
}
}
28 changes: 0 additions & 28 deletions resources/tests/GanacheTests/PrimOps.obs

This file was deleted.

8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsAdd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsadd()",
"expected" : "13"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsAdd.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsAdd{
transaction primopsadd() returns int {
return(5+8);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsAnd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsand()",
"expected" : "0"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsAnd.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsAnd{
transaction primopsand() returns bool {
return(true && false);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsDiv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsdiv()",
"expected" : "2"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsDiv.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsDiv{
transaction primopsdiv() returns int {
return(4/2);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsEq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopseq()",
"expected" : "0"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsEq.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsEq{
transaction primopseq() returns bool {
return(5 == 9);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsGreater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsgreater()",
"expected" : "0"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsGreater.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsGreater{
transaction primopsgreater() returns bool {
return(12 > 19);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsGreaterEq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsgreatereq()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsGreaterEq.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsGreaterEq{
transaction primopsgreatereq() returns bool {
return(12 >= 12);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsLess.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsless()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsLess.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsLess{
transaction primopsless() returns bool {
return(9 < 10);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsLessEq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopslesseq()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsLessEq.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsLessEq{
transaction primopslesseq() returns bool {
return(9 <= 19);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsMod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsmod()",
"expected" : "5"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsMod.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsMod{
transaction primopsmod() returns int {
return(13 % 8);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsMul.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsmul()",
"expected" : "20"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsMul.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsMul{
transaction primopsmul() returns int {
return(5*4);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNEq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsneq()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNEq.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsNEq{
transaction primopsneq() returns bool {
return(5 != 9);
}
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNeg.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsNeg{
transaction primopsneg() returns int {
return(-20);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNotFalse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsnotfalse()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNotFalse.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsNotFalse{
transaction primopsnotfalse() returns bool {
return(! false);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNotTrue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsnottrue()",
"expected" : "0"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNotTrue.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsNotTrue{
transaction primopsnottrue() returns bool {
return(! true);
}
}
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsOr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsor()",
"expected" : "1"
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsOr.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsOr{
transaction primopsor() returns bool {
return(true || false);
}
}
5 changes: 5 additions & 0 deletions resources/tests/GanacheTests/PrimOpsSubNeg.obs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main contract PrimOpsSubNeg{
transaction primopssubneg() returns int {
return(5-20);
}
}

0 comments on commit 0c8a5cc

Please sign in to comment.