Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1357 from llorllale/1330
Browse files Browse the repository at this point in the history
chore: aries-js-worker - didexchange edgeagent/router
  • Loading branch information
George Aristy committed Feb 26, 2020
2 parents 1aef12b + 0ebe0b5 commit 2f3b78c
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 70 deletions.
2 changes: 1 addition & 1 deletion cmd/aries-js-worker/main.go
Expand Up @@ -317,7 +317,7 @@ func newErrResult(id, msg string) *result {
return &result{
ID: id,
IsErr: true,
ErrMsg: msg,
ErrMsg: "aries wasm: " + msg,
}
}

Expand Down
29 changes: 27 additions & 2 deletions cmd/aries-js-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions cmd/aries-js-worker/src/aries.js
Expand Up @@ -85,9 +85,7 @@ function newMsg(pkg, fn, payload) {
*/
export const Framework = class {
constructor(opts) {
return (async () => {
return await Aries(opts);
})();
return Aries(opts)
}
};

Expand Down Expand Up @@ -183,11 +181,16 @@ const Aries = function(opts) {
createInvitation: async function (text) {
return invoke(aw, pending, this.pkgname, "CreateInvitation", text, "timeout while creating invitation")
},
receiveInvitation: async function (text) {
return invoke(aw, pending, this.pkgname, "ReceiveInvitation", text, "timeout while receiving invitation")
receiveInvitation: async function (invitation) {
return invoke(aw, pending, this.pkgname, "ReceiveInvitation", invitation, "timeout while receiving invitation")
},
acceptInvitation: async function (text) {
return invoke(aw, pending, this.pkgname, "AcceptInvitation", text, "timeout while accepting invitation")
acceptInvitation: async function (connectionID, publicDID="") {
return new Promise((resolve, reject) => {
invoke(aw, pending, this.pkgname, "AcceptInvitation", {id: connectionID, public: publicDID}, "timeout while accepting invitation").then(
resp => resolve(resp),
err => reject(new Error("failed to accept invitation: " + err.message))
)
})
},
acceptExchangeRequest: async function (text) {
return invoke(aw, pending, this.pkgname, "AcceptExchangeRequest", text, "timeout while accepting exchange request")
Expand All @@ -198,8 +201,8 @@ const Aries = function(opts) {
removeConnection: async function (text) {
return invoke(aw, pending, this.pkgname, "RemoveConnection", text, "timeout while removing invitation")
},
queryConnectionByID: async function (text) {
return invoke(aw, pending, this.pkgname, "QueryConnectionByID", text, "timeout while querying connection by ID")
queryConnectionByID: async function (connectionID) {
return invoke(aw, pending, this.pkgname, "QueryConnectionByID", {id: connectionID}, "timeout while querying connection by ID")
},
queryConnections: async function (text) {
return invoke(aw, pending, this.pkgname, "QueryConnections", text, "timeout while querying connections")
Expand Down Expand Up @@ -279,10 +282,9 @@ const Aries = function(opts) {
notifications.set("asset-ready", async (result) => {
clearTimeout(timer)
invoke(aw, pending, "aries", "Start", opts, "timeout while starting aries").then(
resp => resolve(),
resp => resolve(instance),
err => reject(new Error(err.message))
)
resolve(instance)
})
})
}
2 changes: 1 addition & 1 deletion pkg/didcomm/protocol/didexchange/service.go
Expand Up @@ -418,7 +418,7 @@ func (s *Service) AcceptExchangeRequest(connectionID, publicDID, label string) e
func (s *Service) accept(connectionID, publicDID, label, stateID, errMsg string) error {
msg, err := s.getEventTransientData(connectionID)
if err != nil {
return fmt.Errorf("%s : %w", errMsg, err)
return fmt.Errorf("failed to accept invitation for connectionID=%s : %s : %w", connectionID, errMsg, err)
}

connRecord, err := s.connectionStore.GetConnectionRecord(connectionID)
Expand Down
27 changes: 26 additions & 1 deletion scripts/check_js_integration.sh
Expand Up @@ -8,14 +8,39 @@ set -e

ROOT=`pwd`

echo ""
echo "Running aries-js-worker integration tests..."
echo ""
echo "----> packing aries-js-worker"
echo ""
cd $ROOT/cmd/aries-js-worker
npm install
npm link
echo ""
echo "----> setting up aries-js-worker tests"
echo ""
cd $ROOT/test/aries-js-worker
npm install
npm link @hyperledger/aries-framework-go
echo ""
echo "----> starting fixtures"
echo ""
cd $ROOT/test/aries-js-worker/fixtures
docker-compose up -d
echo ""
echo "----> executing aries-js-worker tests"
npm test
echo ""
cd $ROOT/test/aries-js-worker
# capture exit code if it fails
npm test || code=$?
if [ -z ${code+x} ]; then
# set exit code because it did not fail
code=0
fi
echo ""
echo "----> stopping fixtures"
echo ""
cd $ROOT/test/aries-js-worker/fixtures
docker-compose stop
cd $ROOT
exit $code
1 change: 1 addition & 0 deletions test/aries-js-worker/.gitignore
Expand Up @@ -6,3 +6,4 @@

node_modules/
public/
environment.js
22 changes: 22 additions & 0 deletions test/aries-js-worker/fixtures/.env
@@ -0,0 +1,22 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

# Agent configurations
E2E_AGENT_REST_IMAGE=aries-framework-go/agent-rest
E2E_AGENT_REST_IMAGE_TAG=latest

# Transport Schemes
E2E_HTTP_SCHEME=http
E2E_WS_SCHEME=ws

# Router configurations
E2E_ROUTER_HOST=0.0.0.0
E2E_ROUTER_HTTP_INBOUND_PORT=10091
E2E_ROUTER_WS_INBOUND_PORT=10092
E2E_ROUTER_API_PORT=10093
E2E_ROUTER_DB_PATH=/tmp/db/aries
E2E_ROUTER_WEBHOOK_PORT=10094
E2E_ROUTER_AUTOACCEPT=true
26 changes: 26 additions & 0 deletions test/aries-js-worker/fixtures/docker-compose.yml
@@ -0,0 +1,26 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'

services:

carl.router.agent.example.com:
container_name: aries-js-worker-router.com
image: ${E2E_AGENT_REST_IMAGE}:${E2E_AGENT_REST_IMAGE_TAG}
environment:
- ARIESD_API_HOST=${E2E_ROUTER_HOST}:${E2E_ROUTER_API_PORT}
- ARIESD_INBOUND_HOST=${E2E_HTTP_SCHEME}@${E2E_ROUTER_HOST}:${E2E_ROUTER_HTTP_INBOUND_PORT},${E2E_WS_SCHEME}@${E2E_ROUTER_HOST}:${E2E_ROUTER_WS_INBOUND_PORT}
- ARIESD_INBOUND_HOST_EXTERNAL=${E2E_HTTP_SCHEME}@http://localhost:${E2E_ROUTER_HTTP_INBOUND_PORT},${E2E_WS_SCHEME}@ws://localhost:${E2E_ROUTER_WS_INBOUND_PORT}
- ARIESD_DB_PATH=${E2E_ROUTER_DB_PATH}
- ARIESD_DEFAULT_LABEL=carl-router-agent
- ARIESD_OUTBOUND_TRANSPORT=${E2E_HTTP_SCHEME},${E2E_WS_SCHEME}
- ARIESD_AUTO_ACCEPT=${E2E_ROUTER_AUTOACCEPT}
# - ARIESD_LOG_LEVEL=DEBUG
ports:
- ${E2E_ROUTER_HTTP_INBOUND_PORT}:${E2E_ROUTER_HTTP_INBOUND_PORT}
- ${E2E_ROUTER_WS_INBOUND_PORT}:${E2E_ROUTER_WS_INBOUND_PORT}
- ${E2E_ROUTER_API_PORT}:${E2E_ROUTER_API_PORT}
command: start
33 changes: 30 additions & 3 deletions test/aries-js-worker/karma.conf.js
Expand Up @@ -4,17 +4,44 @@ Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

const fs = require("fs")

process.env.CHROME_BIN = require('puppeteer').executablePath()
const ENV_CONFIG = "fixtures/.env";
const ENV_CONFIG_OUT = "test/environment.js";

(() => {
require("dotenv").config({path: ENV_CONFIG})
const util = require("util")
const config = {}
for (const attr in process.env) {
if (attr.startsWith("E2E_")) {
config[attr.replace("E2E_", "")] = process.env[attr]
}
}
fs.writeFileSync(ENV_CONFIG_OUT, "export const environment = " + util.inspect(config))
})()

module.exports = function(config) {
config.set({
frameworks: ["mocha", "chai"],
browsers: ["ChromeHeadless"],
browsers: ["ChromeHeadless_cors"],
singleRun: true,
captureConsole: true,
files: [
{pattern: "test/**/*.js", type: "module"},
{pattern: "public/aries-framework-go/assets/*", included: false},
{pattern: "node_modules/@hyperledger/aries-framework-go/dist/web/*", type: "module"}
]
{pattern: "node_modules/@hyperledger/aries-framework-go/dist/web/*", type: "module"},
"node_modules/axios/dist/axios.min.js",
{pattern: "test/common.js", included: false},
{pattern: "test/environment.js", included: false},
],
reporters: ["spec"],
customLaunchers: {
ChromeHeadless_cors: {
base: "ChromeHeadless",
flags: ["--disable-web-security"]
}
}
})
}
50 changes: 50 additions & 0 deletions test/aries-js-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions test/aries-js-worker/package.json
Expand Up @@ -10,13 +10,16 @@
"author": "hyperledger/aries",
"license": "Apache-2.0",
"devDependencies": {
"axios": "0.19.2",
"chai": "4.2.0",
"karma": "^4.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"dotenv": "8.2.0",
"karma": "4.4.1",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-mocha": "1.3.0",
"karma-spec-reporter": "0.0.32",
"mocha": "7.0.1",
"puppeteer": "^2.1.1"
"puppeteer": "2.1.1"
},
"dependencies": {}
}

0 comments on commit 2f3b78c

Please sign in to comment.