Skip to content

Commit

Permalink
E2E Attestations test + various e2e improvements (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcewen authored and celo-ci-bot-user committed Oct 22, 2019
1 parent 3805194 commit 21f8cdc
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 144 deletions.
161 changes: 43 additions & 118 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

version: 2
reference:
workspace: &workspace
~/src
workspace: &workspace ~/src
## Configurations
android_config: &android_config
working_directory: *workspace
Expand All @@ -15,7 +14,6 @@ reference:
TERM: dumb
JVM_OPTS: -Xmx3200m


defaults: &defaults
working_directory: ~/app
docker:
Expand All @@ -32,6 +30,11 @@ android-defaults: &android-defaults
_JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError"'

e2e-defaults: &e2e-defaults
<<: *defaults
docker:
- image: celohq/circleci

general:
artifacts:
- "mobile/coverage"
Expand Down Expand Up @@ -161,7 +164,7 @@ jobs:
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-platform-tools
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask-versions
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install homebrew/cask-versions/adoptopenjdk8
- run:
- run:
name: Creace Android Virtual Device (AVD)
command: |
avdmanager create avd -n Nexus_5X_API_28_x86 -k "system-images;android-26;google_apis;x86" -g google_apis -d "Nexus 5"
Expand All @@ -182,7 +185,7 @@ jobs:
name: install miscellaneous
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install tree
# Currently not used
# - run: npm install --global react-native-kill-packager
# - run: npm install --global react-native-kill-packager
- run:
# need to run this because it's another OS than install_dependecies job
name: yarn
Expand All @@ -196,7 +199,7 @@ jobs:
# yarn postinstall
# fi
yarn
yarn build
yarn build
- save_cache:
key: yarn-v4-macos-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
Expand All @@ -212,7 +215,7 @@ jobs:
name: Start emulator
command: cd ~/src/packages/mobile && bash ./scripts/start_emulator.sh
background: true
- run:
- run:
name: Start metro
command: cd ~/src/packages/mobile && yarn start
background: true
Expand All @@ -237,7 +240,7 @@ jobs:
paths:
- ~/src/packages/mobile/android/app/build/outputs/apk/
- ~/.gradle/

lint-checks:
<<: *defaults
steps:
Expand Down Expand Up @@ -460,7 +463,7 @@ jobs:
steps:
- attach_workspace:
at: ~/app

- run:
name: Install and test the npm package
command: |
Expand All @@ -475,7 +478,7 @@ jobs:
steps:
- attach_workspace:
at: ~/app

- run:
name: Install and test the npm package
command: |
Expand All @@ -486,7 +489,7 @@ jobs:
npm install ~/app/packages/utils/*.tgz
end-to-end-geth-transfer-test:
<<: *defaults
<<: *e2e-defaults
steps:
- attach_workspace:
at: ~/app
Expand All @@ -495,37 +498,16 @@ jobs:
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Setup Go language
command: |
set -e
set -v
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar xf go1.11.5.linux-amd64.tar.gz -C /tmp
ls /tmp/go/bin/go
/tmp/go/bin/go version
- run:
name: Setup Rust language
command: |
set -e
set -v
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
rustup install 1.36.0
rustup default 1.36.0
- run:
name: Run test
no_output_timeout: 20m
command: |
set -e
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
go version
cd packages/celotool
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
./ci_test_transfers.sh checkout master
end-to-end-geth-exit-test:
<<: *defaults
<<: *e2e-defaults
steps:
- attach_workspace:
at: ~/app
Expand All @@ -534,37 +516,16 @@ jobs:
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Setup Go language
command: |
set -e
set -v
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar xf go1.11.5.linux-amd64.tar.gz -C /tmp
ls /tmp/go/bin/go
/tmp/go/bin/go version
- run:
name: Setup Rust language
command: |
set -e
set -v
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
rustup install 1.36.0
rustup default 1.36.0
- run:
name: Run test
no_output_timeout: 20m
command: |
set -e
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
go version
cd packages/celotool
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
./ci_test_exit.sh checkout master
end-to-end-geth-governance-test:
<<: *defaults
<<: *e2e-defaults
# Source: https://circleci.com/docs/2.0/configuration-reference/#resource_class
resource_class: medium+
steps:
Expand All @@ -575,37 +536,16 @@ jobs:
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Setup Go language
command: |
set -e
set -v
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar xf go1.11.5.linux-amd64.tar.gz -C /tmp
ls /tmp/go/bin/go
/tmp/go/bin/go version
- run:
name: Setup Rust language
command: |
set -e
set -v
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
rustup install 1.36.0
rustup default 1.36.0
- run:
name: Run test
no_output_timeout: 20m
command: |
set -e
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
go version
cd packages/celotool
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
./ci_test_governance.sh checkout master
end-to-end-geth-sync-test:
<<: *defaults
<<: *e2e-defaults
# Source: https://circleci.com/docs/2.0/configuration-reference/#resource_class
resource_class: medium+
steps:
Expand All @@ -616,36 +556,15 @@ jobs:
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Setup Go language
command: |
set -e
set -v
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar xf go1.11.5.linux-amd64.tar.gz -C /tmp
ls /tmp/go/bin/go
/tmp/go/bin/go version
- run:
name: Setup Rust language
command: |
set -e
set -v
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
rustup install 1.36.0
rustup default 1.36.0
- run:
name: Run test
command: |
set -e
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
go version
cd packages/celotool
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
./ci_test_sync.sh checkout master
end-to-end-geth-integration-sync-test:
<<: *defaults
<<: *e2e-defaults
steps:
- attach_workspace:
at: ~/app
Expand All @@ -655,27 +574,29 @@ jobs:
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Setup Go language
name: Run test
command: |
set -e
set -v
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar xf go1.11.5.linux-amd64.tar.gz -C /tmp
ls /tmp/go/bin/go
/tmp/go/bin/go version
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
rustup install 1.36.0
rustup default 1.36.0
cd packages/celotool
./ci_test_sync_with_network.sh checkout master
end-to-end-geth-attestations-test:
<<: *e2e-defaults
resource_class: medium+
steps:
- attach_workspace:
at: ~/app
- run:
name: Check if the test should run
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Run test
command: |
set -e
export PATH=${PATH}:~/.cargo/bin:/tmp/go/bin
go version
cd packages/celotool
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
./ci_test_sync_with_network.sh checkout master
./ci_test_attestations.sh checkout master
web:
working_directory: ~/app
Expand Down Expand Up @@ -788,23 +709,27 @@ workflows:
- end-to-end-geth-transfer-test:
requires:
- lint-checks
- walletkit-test
- contractkit-test
- end-to-end-geth-exit-test:
requires:
- lint-checks
- walletkit-test
- contractkit-test
- end-to-end-geth-governance-test:
requires:
- lint-checks
- walletkit-test
- contractkit-test
- end-to-end-geth-sync-test:
requires:
- lint-checks
- walletkit-test
- contractkit-test
- end-to-end-geth-integration-sync-test:
requires:
- lint-checks
- walletkit-test
- contractkit-test
- end-to-end-geth-attestations-test:
requires:
- lint-checks
- contractkit-test
npm-install-testing-cron-workflow:
triggers:
- schedule:
Expand Down
14 changes: 14 additions & 0 deletions dockerfiles/circleci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
sudo apt-get update -y && sudo apt-get install google-cloud-sdk -y

RUN sudo wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz && \
sudo tar xf go1.11.5.linux-amd64.tar.gz -C /usr/local

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH="/usr/local/go/bin:/home/circleci/.cargo/bin:${PATH}"

RUN go version

RUN rustup install 1.36.0 && \
rustup default 1.36.0

RUN mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config

CMD ["/bin/sh"]
20 changes: 20 additions & 0 deletions packages/celotool/ci_test_attestations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

# This test starts a standalone Geth node and runs transactions on it.

# For testing a particular branch of Geth repo (usually, on Circle CI)
# Usage: ci_test_attestations.sh checkout <branch_of_geth_repo_to_test>
# For testing the local Geth dir (usually, for manual testing)
# Usage: ci_test_attestations.sh local <location_of_local_geth_dir>

if [ "${1}" == "checkout" ]; then
# Test master by default.
BRANCH_TO_TEST=${2:-"master"}
echo "Checking out geth at branch ${BRANCH_TO_TEST}..."
../../node_modules/.bin/mocha -r ts-node/register src/e2e-tests/attestations_tests.ts --branch ${BRANCH_TO_TEST}
elif [ "${1}" == "local" ]; then
export GETH_DIR="${2}"
echo "Testing using local geth dir ${GETH_DIR}..."
../../node_modules/.bin/mocha -r ts-node/register src/e2e-tests/attestations_tests.ts --localgeth ${GETH_DIR}
fi
6 changes: 3 additions & 3 deletions packages/celotool/src/cmds/account/verify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountArgv } from '@celo/celotool/src/cmds/account'
import { portForwardAnd } from '@celo/celotool/src/lib/port_forward'
import { CeloContract, newKit } from '@celo/contractkit'
import { newKit } from '@celo/contractkit'
import { AttestationsWrapper } from '@celo/contractkit/lib/wrappers/Attestations'
import { ActionableAttestation, decodeAttestationCode } from '@celo/walletkit'
import prompts from 'prompts'
Expand Down Expand Up @@ -100,10 +100,10 @@ async function requestMoreAttestations(
attestationsRequested: number
) {
await attestations
.approveAttestationFee(CeloContract.StableToken, attestationsRequested)
.approveAttestationFee(attestationsRequested)
.then((txo) => txo.sendAndWaitForReceipt())
await attestations
.request(phoneNumber, attestationsRequested, CeloContract.StableToken)
.request(phoneNumber, attestationsRequested)
.then((txo) => txo.sendAndWaitForReceipt())
}

Expand Down
Loading

0 comments on commit 21f8cdc

Please sign in to comment.