Skip to content
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn install
- run: npm install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn ava --timeout=60s --concurrency=1
- run: npm test
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: install dependencies
run: npm install

- name: run tests
run: npm test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ws": "^8.18.1"
},
"scripts": {
"test": "yarn ava --timeout=60s --concurrency=1 --fail-fast --verbose",
"test": "npx ava --timeout=60s --concurrency=1 --fail-fast --verbose",
"compileGrammar:oscript": "nearleyc ./formula/grammars/oscript.ne -o ./formula/grammars/oscript.js",
"compileGrammar:ojson": "nearleyc ./formula/grammars/ojson.ne -o ./formula/grammars/ojson.js"
},
Expand Down
22 changes: 22 additions & 0 deletions test/_testdata_fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*jslint node: true */
"use strict";
var fs = require("fs");

/**
* Remove a test data directory (cross-platform; replaces rm -rf).
*/
function removeTestdataDir(dir) {
fs.rmSync(dir, { recursive: true, force: true });
}

/**
* Copy a test data tree (cross-platform; replaces cp -r). Requires Node 16.7+.
*/
function copyTestdataDir(src, dest) {
fs.cpSync(src, dest, { recursive: true });
}

module.exports = {
removeTestdataDir: removeTestdataDir,
copyTestdataDir: copyTestdataDir
};
4 changes: 2 additions & 2 deletions test/aa.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var shell = require('child_process').execSync;
var path = require('path');
var testdataFs = require('./_testdata_fs.js');
var fs = require('fs');
var async = require('async');
var crypto = require('crypto');
Expand All @@ -17,7 +17,7 @@ desktop_app.getAppDataDir = function() { return __dirname + '/.testdata-' + path

// cleanup, if last time failed
var dst_dir = __dirname + '/.testdata-' + path.basename(__filename);
shell('rm -rf ' + dst_dir);
testdataFs.removeTestdataDir(dst_dir);

var Decimal = require('decimal.js');
var formulaParser = require('../formula/index');
Expand Down
7 changes: 3 additions & 4 deletions test/aa_composer.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var path = require('path');
var shell = require('child_process').execSync;
var _ = require('lodash');
var testdataFs = require('./_testdata_fs.js');

process.env.devnet = 1;
var constants = require("../constants.js");
Expand All @@ -10,9 +10,8 @@ desktop_app.getAppDataDir = function () { return __dirname + '/.testdata-' + pat

var src_dir = __dirname + '/initial-testdata-' + path.basename(__filename);
var dst_dir = __dirname + '/.testdata-' + path.basename(__filename);
//shell('mkdir ' + dst_dir);
shell('rm -rf ' + dst_dir);
shell('cp -r ' + src_dir + '/ ' + dst_dir);
testdataFs.removeTestdataDir(dst_dir);
testdataFs.copyTestdataDir(src_dir, dst_dir);

var db = require('../db.js');
var aa_validation = require('../aa_validation.js');
Expand Down
4 changes: 2 additions & 2 deletions test/formula.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var shell = require('child_process').execSync;
var path = require('path');
var testdataFs = require('./_testdata_fs.js');
var crypto = require('crypto');
var Mnemonic = require('bitcore-mnemonic');

Expand All @@ -17,7 +17,7 @@ desktop_app.getAppDataDir = function() { return __dirname + '/.testdata-' + path

// cleanup, if last time failed
var dst_dir = __dirname + '/.testdata-' + path.basename(__filename);
shell('rm -rf ' + dst_dir);
testdataFs.removeTestdataDir(dst_dir);

var Decimal = require('decimal.js');
var formulaParser = require('../formula/index');
Expand Down
4 changes: 2 additions & 2 deletions test/formulas_in_contracts.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var shell = require('child_process').execSync;
var path = require('path');
var testdataFs = require('./_testdata_fs.js');
var desktop_app = require('../desktop_app.js');
desktop_app.getAppDataDir = function() { return __dirname + '/.testdata-' + path.basename(__filename); }

// cleanup, if last time failed
var dst_dir = __dirname + '/.testdata-' + path.basename(__filename);
shell('rm -rf ' + dst_dir);
testdataFs.removeTestdataDir(dst_dir);

var definition = require("../definition");
var formulaParser = require("../formula/index");
Expand Down
4 changes: 2 additions & 2 deletions test/pem_sig.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var shell = require('child_process').execSync;
var path = require('path');
var testdataFs = require('./_testdata_fs.js');
var asymSig = require('../signature.js');
var desktop_app = require('../desktop_app.js');
desktop_app.getAppDataDir = function() { return __dirname + '/.testdata-' + path.basename(__filename); }

// cleanup, if last time failed
var dst_dir = __dirname + '/.testdata-' + path.basename(__filename);
shell('rm -rf ' + dst_dir);
testdataFs.removeTestdataDir(dst_dir);

var formulaParser = require('../formula/index');
var test = require('ava');
Expand Down