Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate user friendly test zols and actions tests zols #164

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- name: run zappify
run: |
npm ci && ./bin/start
zappify -i test/contracts/Assign.zol -o temp-zapps
zappify -i test/contracts/If-Statement.zol -o temp-zapps
zappify -i test/contracts/internalFunctionCallTest1.zol -o temp-zapps
zappify -i test/contracts/User-Friendly-tests/Assign.zol -o temp-zapps
zappify -i test/contracts/User-Friendly-tests/If-Statement.zol -o temp-zapps
zappify -i test/contracts/User-Friendly-tests/internalFunctionCallTest1.zol -o temp-zapps

- name: replace zokrates image for actions test
uses: jacobtomlinson/gha-find-replace@v2
Expand Down
10 changes: 5 additions & 5 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
npm i solc@^0.8.0 -g
cd zapps/
echo “$(tput setaf 3) SHIELDCONTRACTS”
echo “$(tput setaf 3) SHIELDCONTRACTS”
SOLFILES=$(find . -type f -name "*Shield*.sol" -maxdepth 3 -mindepth 3)
solarray=($SOLFILES)
for solelement in "${solarray[@]}"
do
DIR="$(dirname "${solelement}")"
solelement="${solelement:2}"
echo “$(tput setaf 7) $solelement compiling”
echo “$(tput setaf 7) $solelement compiling”
solcjs --abi -o $DIR --include-path node_modules/ --base-path . $solelement || echo “$(tput setaf 1) $solelement failed”
done

echo “$(tput setaf 3) CIRCUITS”
echo “$(tput setaf 3) CIRCUITS”
ZOKFILES=$(find . -type f -name "*.zok" -maxdepth 3 -mindepth 3)
zokarray=($ZOKFILES)
for zokelement in "${zokarray[@]}"
do
zokelement="${zokelement:1}"
echo “$(tput setaf 7) $zokelement compiling”
echo “$(tput setaf 7) $zokelement compiling”
docker run -v $PWD:/app/code --name testcircuits -ti ghcr.io/eyblockchain/zokrates-worker-m1 ./zokrates compile -i code$zokelement || echo “$(tput setaf 1) $zokelement failed”
docker rm testcircuits
done
done
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 25 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,38 @@ import mkdirs from '../bin/mkdirs.mjs';
import zappify from '../built/index.js';
import logger from "../built/utils/logger.js";

var files = fs.readdirSync('./test/contracts/')
let options = {}
let files = [] ;

function getFiles(dir) {

// get all 'files' in this directory
var all = fs.readdirSync(dir);

// process each checking directories and saving files
return all.map(file => {
// am I a directory?
if (fs.statSync(`${dir}/${file}`).isDirectory()) {
// recursively scan me for my files
return getFiles(`${dir}/${file}`);
}
// WARNING! I could be something else here!!!
return `${dir}/${file}`; // file name (see warning)
});
}

files = getFiles('./test/contracts').flat(Infinity);
let options = {}

describe("AST testing", function () {

describe("#testing zappify", function () {
it("zappifies each contract", function () {
this.timeout(100000);
files.forEach((file) => {
logger.info('zappifying', file);
options.inputFilePath = './test/contracts/'+file;
options.modifyAST = 'n';
options.inputFileName = path.parse(options.inputFilePath).name;
logger.info('zappifying', options.inputFileName);
options.inputFilePath = file;
options.modifyAST = 'n';
// commander converts 'zapp-name' to 'zappName'
options.zappName = options.inputFileName;
options.outputDirPath = `./temp-zapps/${options.zappName}`;
Expand All @@ -35,7 +53,7 @@ describe("AST testing", function () {
});

let chosenFile = files[Math.floor(Math.random() * files.length)]
const inputFilePath = './test/contracts/'+chosenFile;
const inputFilePath = chosenFile;
const modifyAST = 'n';
const inputFileName = path.parse(inputFilePath).name;
// commander converts 'zapp-name' to 'zappName'
Expand All @@ -46,7 +64,7 @@ describe("AST testing", function () {
const contractsDirPath = `${outputDirPath}/contracts`;
const orchestrationDirPath = `${outputDirPath}/orchestration`;

logger.info('Testing', chosenFile);
logger.info('Testing', inputFileName);

options = {
zappName,
Expand Down