Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
fix(tests) Fixes broken tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Aug 19, 2020
1 parent 93e2cf6 commit 10c7a91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
42 changes: 21 additions & 21 deletions packages/ergo-compiler/test/logicmanager.js
Expand Up @@ -74,9 +74,9 @@ describe('LogicManager', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should succeed creating a dispatch call for a JS logic file with a contract class (ES6)', () => {
Expand Down Expand Up @@ -160,9 +160,9 @@ describe('LogicManager', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.compileLogic(false).then((logicCode) => {
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});
});

Expand All @@ -177,16 +177,16 @@ describe('LogicManager', () => {
logicManager.addErgoBuiltin();
logicManager.addLogicFile(ergoSample,'test3.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should load a logic file (without extension) to the script manager', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should set the contract name', () => {
Expand All @@ -202,30 +202,30 @@ describe('LogicManager', () => {
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('es6');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.setTarget('es6', true);
logicManager.getTarget().should.equal('es6');
const contractName = 'org.accordproject.helloemit.HelloWorld';
logicManager.setContractName(contractName);
logicManager.getContractName().should.equal(ErgoCompiler.contractCallName(contractName));
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should fail to create init and dispatch for ES6 without a contract name', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('es6');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should set the compilation target to ES6 but not recompile the logic', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.setTarget('es6', false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

it('should fail to create init code for Java', () => {
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(138438);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(137212);
});

it('should load a directory with grammar', async function () {
Expand All @@ -271,7 +271,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(69507);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(68281);
});
});

Expand All @@ -288,7 +288,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(138438);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(137212);
});

it('should load a Zip with formula', async function () {
Expand All @@ -303,7 +303,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(68139);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(66913);
});
});

Expand All @@ -324,7 +324,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(138438);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(137212);
});

it('should load a Zip with formula', async function () {
Expand All @@ -343,7 +343,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(69507);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(68281);
});
});

Expand Down Expand Up @@ -379,15 +379,15 @@ describe('LogicManager', () => {
const logicManager = new LogicManager('es6');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.updateLogic(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.updateLogic(ergoSample,'testNEW.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
logicManager.updateLogic(ergoSample3,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(50125);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(48899);
});

});
Expand Down
14 changes: 7 additions & 7 deletions packages/ergo-compiler/test/scriptmanager.js
Expand Up @@ -59,9 +59,9 @@ describe('ScriptManager', () => {
scriptManager.getLogic().map(x => x.name).should.deep.equal(['test.ergo']);
scriptManager.allFunctionDeclarations().length.should.equal(2);
scriptManager.allFunctionDeclarations().map(x => x.getName()).should.deep.equal(['paymentClause','__dispatch']);
scriptManager.getCompiledScript().getContents().length.should.equal(50125);
scriptManager.getCompiledModule().length.should.equal(50125);
scriptManager.allFunctionDeclarations().length.should.equal(150);
scriptManager.getCompiledScript().getContents().length.should.equal(48899);
scriptManager.getCompiledModule().length.should.equal(48899);
scriptManager.allFunctionDeclarations().length.should.equal(149);
});

it('should compile Ergo scripts', async function() {
Expand All @@ -70,8 +70,8 @@ describe('ScriptManager', () => {
const script2 = scriptManager.createScript('test.ergo','.ergo',ergoSample);
scriptManager.addScript(script1);
scriptManager.addScript(script2);
scriptManager.compileLogic().getContents().length.should.equal(50125);
scriptManager.getCompiledScript().getContents().length.should.equal(50125);
scriptManager.compileLogic().getContents().length.should.equal(48899);
scriptManager.getCompiledScript().getContents().length.should.equal(48899);
scriptManager.getAllScripts().length.should.equal(3);
});

Expand Down Expand Up @@ -176,8 +176,8 @@ describe('ScriptManager', () => {
const script2 = scriptManager.createScript('test.ergo','.ergo',ergoSample);
scriptManager.addScript(script1);
scriptManager.addScript(script2);
scriptManager.compileLogic().getContents().length.should.equal(50125);
scriptManager.getCompiledModule().length.should.equal(50125);
scriptManager.compileLogic().getContents().length.should.equal(48899);
scriptManager.getCompiledModule().length.should.equal(48899);
scriptManager.clearScripts();
return (() => scriptManager.getCompiledModule()).should.throw('Did not find any compiled logic');
});
Expand Down

0 comments on commit 10c7a91

Please sign in to comment.