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

Commit

Permalink
fix(wasm) Update to latest Q*cert WASM backend/runtime + pyth test
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 21, 2020
1 parent d53e5cd commit 04c7ccf
Show file tree
Hide file tree
Showing 12 changed files with 11,997 additions and 11,740 deletions.
8,362 changes: 4,199 additions & 4,163 deletions packages/ergo-cli/extracted/ergoccore.js

Large diffs are not rendered by default.

7,250 changes: 3,643 additions & 3,607 deletions packages/ergo-cli/extracted/ergotopcore.js

Large diffs are not rendered by default.

7,966 changes: 4,001 additions & 3,965 deletions packages/ergo-compiler/extracted/compilercore.js

Large diffs are not rendered by default.

Binary file modified packages/ergo-engine/lib/untouched.wasm
Binary file not shown.
42 changes: 42 additions & 0 deletions packages/ergo-engine/test/workload_es6.json
Expand Up @@ -438,5 +438,47 @@
"test3": 0
}
}
},
{
"name": "pyth",
"dir": "../../../tests/pyth",
"ergo": ["logic/logic.ergo"],
"models": ["model/model.cto"],
"contract": "data.json",
"request": "request.json",
"state": "state.json",
"contractName": "org.accordproject.pyth.PythContract",
"currentTime": null,
"expected": {
"response": {
"$class": "org.accordproject.pyth.Response",
"triples": [
{
"$class": "org.accordproject.pyth.Triple",
"a": 3,
"b": 4,
"c": 5
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 4,
"b": 3,
"c": 5
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 6,
"b": 8,
"c": 10
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 8,
"b": 6,
"c": 10
}
]
}
}
}
]
42 changes: 42 additions & 0 deletions packages/ergo-engine/test/workload_wasm.json
Expand Up @@ -146,5 +146,47 @@
"test3": 0
}
}
},
{
"name": "pyth",
"dir": "../../../tests/pyth",
"ergo": ["logic/logic.ergo"],
"models": ["model/model.cto"],
"contract": "data.json",
"request": "request.json",
"state": "state.json",
"contractName": "org.accordproject.pyth.PythContract",
"currentTime": null,
"expected": {
"response": {
"$class": "org.accordproject.pyth.Response",
"triples": [
{
"$class": "org.accordproject.pyth.Triple",
"a": 3,
"b": 4,
"c": 5
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 4,
"b": 3,
"c": 5
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 6,
"b": 8,
"c": 10
},
{
"$class": "org.accordproject.pyth.Triple",
"a": 8,
"b": 6,
"c": 10
}
]
}
}
}
]
3 changes: 3 additions & 0 deletions tests/pyth/data.json
@@ -0,0 +1,3 @@
{
"$class": "org.accordproject.pyth.TemplateModel"
}
25 changes: 25 additions & 0 deletions tests/pyth/logic/logic.ergo
@@ -0,0 +1,25 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace org.accordproject.pyth

contract PythContract over TemplateModel {
// Simple Clause
clause findTriples(request : Request) : Response {
let nums = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];
let pyth = (foreach x in nums foreach y in nums foreach z in nums where (x^2.0 + y^2.0 = z^2.0) return Triple{a: x, b: y, c: z});

return Response{ triples: pyth }
}
}
33 changes: 33 additions & 0 deletions tests/pyth/model/model.cto
@@ -0,0 +1,33 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace org.accordproject.pyth

transaction Request {
}

concept Triple {
o Double a
o Double b
o Double c
}
transaction Response {
o Triple[] triples
}

/**
* The template model
*/
concept TemplateModel {
}
3 changes: 3 additions & 0 deletions tests/pyth/request.json
@@ -0,0 +1,3 @@
{
"$class": "org.accordproject.pyth.Request"
}
2 changes: 2 additions & 0 deletions tests/pyth/state.json
@@ -0,0 +1,2 @@
{ "$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId" : "1" }
9 changes: 4 additions & 5 deletions tests/smoke/pyth.ergo
Expand Up @@ -12,15 +12,14 @@
* limitations under the License.
*/

namespace org.accordproject.helloworld
namespace org.accordproject.pyth

contract HelloWorld over TemplateModel {
contract PythContract over TemplateModel {
// Simple Clause
clause helloworld(request : Request) : Response {
let nums = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0];
let pyth = (foreach x in nums foreach y in nums foreach z in nums where (x^2.0 + y^2.0 = z^2.0) return {a: x, b: y, c: z});
let pyth = (foreach x in nums foreach y in nums foreach z in nums where (x^2.0 + y^2.0 = z^2.0) return Triple{a: x, b: y, c: z});

//let pyth = (foreach x in persons foreach y in x.children where y != "frank" return {p: x.name, c: y});
return Response{ output: "Hello " ++ contract.name ++ " (" ++ request.input ++ ")", now : pyth }
return Response{ triples: pyth }
}
}

0 comments on commit 04c7ccf

Please sign in to comment.