sggc/test/Sort.js

37 lines
865 B
JavaScript
Raw Normal View History

2018-05-24 12:11:29 -04:00
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/Sort.json');
2018-07-08 12:23:36 +03:00
const Sort = require('Embark/contracts/Sort');
2018-05-24 12:11:29 -04:00
2018-07-08 12:23:36 +03:00
config({
contracts: {
Sort: {}
}
});
contract("Sort", function() {
2018-05-24 12:11:29 -04:00
this.timeout(0);
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await Sort.methods.sort(v.input[0]).call({gas: v.gas});
assert.deepEqual(result, v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await Sort.methods.sort(v.input[0]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});