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

Commit

Permalink
fix(tests) Update tests for latest release
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Apr 10, 2020
1 parent 54a6070 commit d5ac0ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions packages/ergo-compiler/test/logicmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
});

it('should succeed creating a dispatch call for a JS logic file with a contract class (ES6)', () => {
Expand Down Expand Up @@ -194,9 +194,9 @@ describe('LogicManager', () => {
logicManager.compileLogic(false).then((logicCode) => {
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
});
});

Expand All @@ -213,16 +213,16 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
});

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

it('should set the contract name', () => {
Expand All @@ -238,15 +238,15 @@ describe('LogicManager', () => {
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('cicero');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
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.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(234);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36708);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36709);
});

it('should fail to create init and dispatch for ES6 without a contract name', () => {
Expand All @@ -256,37 +256,37 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(234);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36708);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36709);
});

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

it('should set the compilation target to ES5', () => {
const logicManager = new LogicManager('cicero');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('cicero');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.setTarget('es5', true);
logicManager.getTarget().should.equal('es5');
logicManager.getInvokeCall('helloworld').length.should.equal(174);
logicManager.getDispatchCall().length.should.equal(158);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36562);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36563);
});

it('should fail to create init code for Java', () => {
const logicManager = new LogicManager('java');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('java');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(10718);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(10719);
(() => logicManager.getInvokeCall('helloworld')).should.throw('Unsupported target: java');
(() => logicManager.getDispatchCall()).should.throw('Unsupported target: java');
});
Expand All @@ -312,7 +312,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(45965);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(45966);
});

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

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(45965);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(45966);
});

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

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

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

Expand Down Expand Up @@ -436,15 +436,15 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.updateLogic(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.updateLogic(ergoSample,'testNEW.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
logicManager.updateLogic(ergoSample3,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38403);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(38404);
});

});
Expand Down
12 changes: 6 additions & 6 deletions packages/ergo-compiler/test/scriptmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ 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(38403);
scriptManager.getCompiledJavaScript().length.should.equal(38403);
scriptManager.getCompiledScript().getContents().length.should.equal(38404);
scriptManager.getCompiledJavaScript().length.should.equal(38404);
scriptManager.allFunctionDeclarations().length.should.equal(114);
scriptManager.allFunctionDeclarations().filter(x => x.name === '__init').length.should.equal(1);
expect(scriptManager.hasInit()).to.not.throw;
Expand All @@ -76,8 +76,8 @@ describe('ScriptManager', () => {
const script2 = scriptManager.createScript('test.ergo','.ergo',ergoSample);
scriptManager.addScript(script1);
scriptManager.addScript(script2);
scriptManager.compileLogic().getContents().length.should.equal(38403);
scriptManager.getCompiledScript().getContents().length.should.equal(38403);
scriptManager.compileLogic().getContents().length.should.equal(38404);
scriptManager.getCompiledScript().getContents().length.should.equal(38404);
scriptManager.getAllScripts().length.should.equal(3);
});

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

0 comments on commit d5ac0ad

Please sign in to comment.