I'm testing the db middleware and trying to perform a simple SQL query to a Postgres database.
This is the code:
Rule check version 2.0.0
Rule caller restroom-mw
Given I have a 'string' named 'myResult'
Given I have a database uri named 'postgres'
Given I execute the SQL statement named 'sql' on the database named 'postgres' and save the result into 'myResult'
Then print 'myResult'
This are the keys:
{
"postgres": "postgres://postgres:pgsecret@postgres:5432/postgres",
"sql": "SELECT * FROM token_transfers;"
}
And this is the output:
_{
"zenroom_errors": {
"result": "",
"logs": " . Release version: 2.0.0\n . Build commit hash: 3144ca24\n . ECDH curve is SECP256K1\n . ECP curve is BLS381\n . Memory in use: 413 KB\n . Zencode version match: 2.0.0\n . Rule check version 2.0.0\n . Rule caller restroom-mw\n[W] Zencode pattern ignored: Given I have a database uri named 'postgres'\t1\n[W] Zencode pattern ignored: Given I execute the SQL statement named 'sql' on the database named postgres¡ and save the result into 'myResult'\t1\n[W] Given I have a 'string' named 'myResult'\t2\n[W] nil\n[W] [!] /zencode_given.lua:301: Cannot find 'myResult' anywhere (null value?)\n[W] {\n a_GIVEN_in = {},\n b_GIVEN_in = {\n postgres = \"postgres://postgres:pgsecret@postgres:5432/postgres\",\n sql = \"SELECT FROM token_transfers;\"\n },\n c_WHEN_ack = {},\n d_THEN_out = {}\n}\n[!] ERROR:\n[!] EXEC: /zencode.lua:630: Given I have a 'string' named 'myResult'\n[!] Execution aborted\n[!] Error detected. Execution aborted.\n[] Zenroom teardown.\n . Memory used: 431 KB\n"
},
"result": "",
"exception": "[ZENROOM EXECUTION ERROR FOR CONTRACT test]\n\n\n Please check zenroomerrors logs"
}
This is running Restroom using a Docker image defined like this:
FROM node:16-alpine
# Add dependencies
RUN apk add git python3 make g++
# Installing restroom
RUN yarn global add create-restroom@next
RUN create-restroom --all restroom-mw
WORKDIR /restroom-mw
RUN yarn add @restroom-mw/ethereum@0.13.1-4a7f9b1.35 --save
COPY contracts contracts
COPY keys keys
# Configure restroom
ENV CUSTOM_404_MESSAGE="nothing to see here"
ENV HTTP_PORT=3300
ENV HTTPS_PORT=3301
ENV OPENAPI=true
ENV ZENCODE_DIR=./contracts
ENV KEYS_DIR=./keys
ENV CHAIN_EXT=chain
ENV YML_EXT=yml
EXPOSE 3300/tcp
CMD yarn start
I'm testing the db middleware and trying to perform a simple SQL query to a Postgres database.
This is the code:
This are the keys:
And this is the output: _{ "zenroom_errors": { "result": "", "logs": " . Release version: 2.0.0\n . Build commit hash: 3144ca24\n . ECDH curve is SECP256K1\n . ECP curve is BLS381\n . Memory in use: 413 KB\n . Zencode version match: 2.0.0\n . Rule check version 2.0.0\n . Rule caller restroom-mw\n[W] Zencode pattern ignored: Given I have a database uri named 'postgres'\t1\n[W] Zencode pattern ignored: Given I execute the SQL statement named 'sql' on the database named postgres¡ and save the result into 'myResult'\t1\n[W] Given I have a 'string' named 'myResult'\t2\n[W] nil\n[W] [!] /zencode_given.lua:301: Cannot find 'myResult' anywhere (null value?)\n[W] {\n a_GIVEN_in = {},\n b_GIVEN_in = {\n postgres = \"postgres://postgres:pgsecret@postgres:5432/postgres\",\n sql = \"SELECT FROM token_transfers;\"\n },\n c_WHEN_ack = {},\n d_THEN_out = {}\n}\n[!] ERROR:\n[!] EXEC: /zencode.lua:630: Given I have a 'string' named 'myResult'\n[!] Execution aborted\n[!] Error detected. Execution aborted.\n[] Zenroom teardown.\n . Memory used: 431 KB\n" }, "result": "", "exception": "[ZENROOM EXECUTION ERROR FOR CONTRACT test]\n\n\n Please check zenroomerrors logs" }
This is running Restroom using a Docker image defined like this: