Salad: Some integration tests fail

I have just cloned enigmampc/salad. I am following the steps in the README to start the project. Everything works fine until I run yarn start.

After a few minutes when the script gets to integrationTests/01_init.spec.js, some of the tests fail:

    ✓ initializes (149ms)
    ✓ should generate and save key/pair (1ms)
    ✓ initializes Sample contract (4ms)
    ✓ should distribute ENG tokens (1187ms)
    ✕ should check that 1 worker(s) and the principal node, and only them, are registered (1374ms)
    ✓ should check worker's stake balance is empty (89ms)
    ✓ should get the worker parameters for the current block (133ms)
    ✕ should deposit tokens in worker banks (202ms)
    ✓ should check workers balances have been filled
    ✕ should login the worker(s) (20010ms)
    ✕ should check that 1 worker(s), and only them, are logged in (559ms)
    ✓ should move forward epochSize blocks by calling dummy contract (2780ms)
    ✕ should get the worker parameters for the current block (1115ms)
    ✕ should create getTaskEncryptionKey from core (with call to P2P) (4969ms)

More detailed output:

client_1    |
  ● Init tests › should check that 1 worker(s) and the principal node, and only them, are registered
client_1    |
client_1    |     expect(received).toEqual(expected) // deep equality
client_1    |
client_1    |     - Expected
client_1    |     + Received
client_1    |
client_1    |     @@ -1,7 +1,7 @@
client_1    |       Array [
client_1    |     -   2,
client_1    |     +   0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |
client_1    |       92 |       workerAddress[i] = await enigma.admin.getWorkerSignerAddr(accounts[i]);
client_1    |       93 |     }
client_1    |     > 94 |     expect(workerStatuses).toEqual(arrayResults);
client_1    |          |                            ^
client_1    |       95 |   }, constants.TIMEOUT_INIT);
client_1    |       96 |
client_1    |       97 |   it('should check worker\'s stake balance is empty', async () => {
client_1    |
client_1    |       at _callee4$ (test/integrationTests/01_init.spec.js:94:28)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
client_1    |       at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
client_1    |       at node_modules/regenerator-runtime/runtime.js:145:13
client_1    |
client_1    |   ● Init tests › should deposit tokens in worker banks
client_1    |
client_1    |     Failed: "Returned error: VM Exception while processing transaction: revert Unregistered worker"
client_1    |
client_1    |       108 |
client_1    |       109 |   const deposit = 900;
client_1    |     > 110 |   it('should deposit tokens in worker banks', async () => {
client_1    |           |   ^
client_1    |       111 |     let promises = [];
client_1    |       112 |       for (let i = 0; i < nodes; i++) {
client_1    |       113 |         let promise = new Promise((resolve, reject) => {
client_1    |
client_1    |       at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:91:24)
client_1    |       at Suite.<anonymous> (test/integrationTests/01_init.spec.js:110:3)
client_1    |       at Object.<anonymous> (test/integrationTests/01_init.spec.js:18:1)
client_1    |
client_1    |   ● Init tests › should login the worker(s)
client_1    |
client_1    |     : Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.Error:
client_1    |
client_1    |       134 |   });
client_1    |       135 |
client_1    |     > 136 |   it('should login the worker(s)', async () => {
client_1    |           |   ^
client_1    |       137 |     let promises = [];
client_1    |       138 |     for (let i = 0; i < nodes; i++) {
client_1    |       139 |       let promise = new Promise((resolve, reject) => {
client_1    |
client_1    |       at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
client_1    |       at Suite.<anonymous> (test/integrationTests/01_init.spec.js:136:3)
client_1    |       at Object.<anonymous> (test/integrationTests/01_init.spec.js:18:1)
client_1    |
client_1    |   ● Init tests › should check that 1 worker(s), and only them, are logged in
client_1    |
client_1    |     expect(received).toEqual(expected) // deep equality
client_1    |
client_1    |     - Expected
client_1    |     + Received
client_1    |
client_1    |     @@ -1,7 +1,7 @@
client_1    |       Array [
client_1    |     -   1,
client_1    |     +   0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |         0,
client_1    |
client_1    |       158 |       arrayResults[i]=1;
client_1    |       159 |     }
client_1    |     > 160 |     expect(workerStatuses).toEqual(arrayResults);
client_1    |           |                            ^
client_1    |       161 |   });
client_1    |       162 |
client_1    |       163 |   it('should move forward epochSize blocks by calling dummy contract', async () => {
client_1    |
client_1    |       at _callee10$ (test/integrationTests/01_init.spec.js:160:28)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
client_1    |       at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
client_1    |       at node_modules/regenerator-runtime/runtime.js:145:13
client_1    |
client_1    |   ● Init tests › should get the worker parameters for the current block
client_1    |
client_1    |     expect(received).toEqual(expected) // deep equality
client_1    |
client_1    |     - Expected
client_1    |     + Received
client_1    |
client_1    |     - Array [
client_1    |     -   "0x0000000000000000000000000000000000000000",
client_1    |     - ]
client_1    |     + Array []
client_1    |
client_1    |       178 |       await sleep(1000);
client_1    |       179 |     } while (!workerParams)
client_1    |     > 180 |     expect(workerParams.workers.sort()).toEqual(workerAddress.sort());  // they may come in a different order
client_1    |           |                                         ^
client_1    |       181 |     expect(workerParams.stakes).toEqual(new Array(nodes).fill(JSBI.BigInt(900 * 10 ** 8)));
client_1    |       182 |   });
client_1    |       183 |
client_1    |
client_1    |       at _callee12$ (test/integrationTests/01_init.spec.js:180:41)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
client_1    |       at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
client_1    |       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
client_1    |       at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
client_1    |       at node_modules/regenerator-runtime/runtime.js:145:13
client_1    |
client_1    |   ● Init tests › should create getTaskEncryptionKey from core (with call to P2P)
client_1    |
client_1    |     : Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:
client_1    |
client_1    |       184 |   const userPubKey = '2ea8e4cefb78efd0725ed12b23b05079a0a433cc8a656f212accf58672fee44a20cfcaa50466237273e762e49ec'+
client_1    |       185 |     '912be61358d5e90bff56a53a0ed42abfe27e3';
client_1    |     > 186 |   it('should create getTaskEncryptionKey from core (with call to P2P)', async () => {
client_1    |           |   ^
client_1    |       187 |     const encryptionKeyResult = await new Promise((resolve, reject) => {
client_1    |       188 |         enigma.client.request('getWorkerEncryptionKey',
client_1    |       189 |           {workerAddress: workerAddress[0].toLowerCase().slice(-40), userPubKey: userPubKey}, (err, response) => {
client_1    |
client_1    |       at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
client_1    |       at Suite.<anonymous> (test/integrationTests/01_init.spec.js:186:3)
client_1    |       at Object.<anonymous> (test/integrationTests/01_init.spec.js:18:1)
client_1    |
Test Suites: 1 failed, 1 total
client_1    | Tests:       6 failed, 8 passed, 14 total
client_1    | Snapshots:   0 total
client_1    | Time:        40.263s
client_1    | Ran all test suites matching /01_init.spec.js/i.
contract_1  | eth_blockNumber
client_1    | Jest did not exit one second after the test run has completed.
client_1    |
client_1    | This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

I haven’t changed anything in the project after I cloned it except for what was in README, so I am not sure what the problem is. When creating a new dummy project with discovery init all these integration tests pass.

1 Like

Hi @mayak,

I’ll take a look. In the meantime can you post any changes you made to your .env file(s), or other? I’ve seen this before when I first started working with salad, and I recall it was an environment issue, but not sure if that’s the case for you.

Hi @laura,

I haven’t changed anything in the env files; they are set up using scripts/configure.sh when I run yarn configure-sw.

Here’s .env:

COMPOSE_PROJECT_NAME=enigma
SGX_MODE=SW
BUILD_CONTRACTS_PATH=./build/enigma_contracts
DOCKER_TAG=develop
WS_PORT=8080
ETH_NETWORK_ID=4447
ETH_HOST=localhost
ETH_PORT=9545
ENIGMA_HOST=localhost
ENIGMA_PORT=3333
DEPOSIT_LOCK_PERIOD_IN_BLOCKS=2
DEAL_INTERVAL_IN_BLOCKS=100
RELAYER_FEE_PERCENT=0
PARTICIPATION_THRESHOLD=3
MONGO_URL=mongodb://localhost:27017
DB_NAME=salad
DEBUG=operator* client test deploy
OPERATOR_HOST=localhost

Here’s operator/.env:

WS_PORT=8080
ETH_HOST=localhost
ETH_PORT=9545
ETH_NETWORK_ID=4447
ENIGMA_HOST=localhost
ENIGMA_PORT=3346
RELAYER_FEE_PERCENT=0
PARTICIPATION_THRESHOLD=2
MONGO_URL=mongodb://localhost:27017
DB_NAME=salad
DEBUG=operator* client test

Here’s docker-compose.yml:

version: '3'

services:

  contract:
    image: enigmampc/enigma_contract:${DOCKER_TAG}
    stdin_open: true
    tty: true
    networks:
      - net
    hostname: contract
    entrypoint:
      - /bin/bash
      - -c
      - ./launch_ganache.bash; bash
    environment:
      - SGX_MODE
    volumes:
      - "${BUILD_CONTRACTS_PATH}:/root/enigma-contract/build/contracts"
      - "shared:/root/.enigma"
    ports:
      - "9545:9545"

  p2p:
    image: enigmampc/enigma_p2p:${DOCKER_TAG}
    stdin_open: true
    tty: true
    networks:
      - net
    hostname: p2p
    entrypoint:
      - /bin/bash
      - -c
      - ./start_worker.bash; bash
    environment:
      - NETWORK=${COMPOSE_PROJECT_NAME}
      - NODES
    volumes:
        - "${BUILD_CONTRACTS_PATH}:/root/enigma-p2p/test/ethereum/scripts/build/contracts"
    expose:
      - "3346"

  client:
    image: enigmampc/enigma_contract:${DOCKER_TAG}
    stdin_open: true
    tty: true
    networks:
      - net
    hostname: client
    entrypoint:
      - /bin/bash
      - -c
      - ./login_workers.bash; bash
    environment:
      - NETWORK=${COMPOSE_PROJECT_NAME}
      - NODES
      - SGX_MODE
    volumes:
      - "${BUILD_CONTRACTS_PATH}:/root/enigma-contract/build/contracts"

  core:
    image: enigmampc/enigma_core_sw:${DOCKER_TAG}
    stdin_open: true
    tty: true
    hostname: core
    networks:
      - net

  km:
    image: enigmampc/enigma_km_sw:${DOCKER_TAG}
    stdin_open: true
    tty: true
    hostname: km
    networks:
      - net
    volumes:
      - "shared:/root/.enigma"

  nginx:
    image: nginx:latest
    hostname: nginx
    volumes:
      - "./config/nginx.conf:/etc/nginx/nginx.conf:ro"
    depends_on:
      - p2p
    ports:
      - "3333:3333"
    networks:
      - net

  mongo:
    container_name: mongo
    hostname: mongo
    image: mongo
    ports:
      - "27017:27017"
    networks:
      - net
    volumes:
      - "db:/data/db"

networks:
    net:

volumes:
  shared:
    driver: local
  db:
    driver: local
1 Like

@mayak, I’ve definitely reproduced your issue with the develop branch and will update the enigmampc/dev-help issue I created for this.

I was going to say to use the master branch for now, in order to try Salad, but I couldn’t get that working either with a fresh pull.

I’ll follow-up when I have something for you. Thanks for pointing this out!

1 Like

Hi @mayak,

UPDATE:

@mayak,

I was able to resolve this issue by changing the docker tag in the .env file to latest instead of develop:

COMPOSE_PROJECT_NAME=enigma
SGX_MODE=SW
BUILD_CONTRACTS_PATH=./build/enigma_contracts
DOCKER_TAG=latest
WS_PORT=8080
ETH_NETWORK_ID=4447
ETH_HOST=localhost
ETH_PORT=9545
ENIGMA_HOST=localhost
ENIGMA_PORT=3333
DEPOSIT_LOCK_PERIOD_IN_BLOCKS=2
DEAL_INTERVAL_IN_BLOCKS=100
RELAYER_FEE_PERCENT=0
PARTICIPATION_THRESHOLD=3
MONGO_URL=mongodb://localhost:27017
DB_NAME=salad
DEBUG=operator* client test deploy
OPERATOR_HOST=localhost

Can you try that? First, remove the sub-directories under your salad/build directory.

Then, try yarn start

I’ll make a note on the issue too.

Let me know if that helps!


CORRECTION
The issue seems to be related to using the discovery-cli “develop” docker tag so the following issue was closed:

=================

Just following-up to let you know I’ve added this issue to the salad repo here: https://github.com/enigmampc/salad/issues/50

=================

I also tried cleaning up my docker images, but that didn’t resolve the issue for me. I don’t know if you want to give it a try? Here’s the link I used: https://getintodevops.com/blog/keeping-the-whale-happy-how-to-clean-up-after-docker

1 Like