Tilt tests (#688)

* tests run in tilt / ci

* changed bridge_ui test process

* tests use kube proxy when in ci

* fix: allTests.sh permission

* fix: bridge_ui dockerfile sha for amd64

* fix: bridge_ui should use cra test

* fix: ci tests

Co-authored-by: Evan Gray <battledingo@gmail.com>
This commit is contained in:
chase-45 2022-02-08 03:55:10 -05:00 committed by GitHub
parent d1de172699
commit 28c713a6dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 850 additions and 135 deletions

View File

@ -39,6 +39,7 @@ config.define_bool("pyth", False, "Enable Pyth-to-Wormhole component")
config.define_bool("explorer", False, "Enable explorer component")
config.define_bool("bridge_ui", False, "Enable bridge UI component")
config.define_bool("e2e", False, "Enable E2E testing stack")
config.define_bool("ci_tests", False, "Enable tests runner component")
cfg = config.parse()
num_guardians = int(cfg.get("num", "1"))
@ -51,6 +52,7 @@ pyth = cfg.get("pyth", ci)
explorer = cfg.get("explorer", ci)
bridge_ui = cfg.get("bridge_ui", ci)
e2e = cfg.get("e2e", ci)
ci_tests = cfg.get("ci_tests", ci)
if cfg.get("manual", False):
trigger_mode = TRIGGER_MODE_MANUAL
@ -280,7 +282,7 @@ if bridge_ui:
docker_build(
ref = "bridge-ui",
context = ".",
only = ["./ethereum", "./sdk", "./bridge_ui"],
only = ["./bridge_ui"],
dockerfile = "bridge_ui/Dockerfile",
live_update = [
sync("./bridge_ui/src", "/app/bridge_ui/src"),
@ -291,13 +293,35 @@ if bridge_ui:
k8s_resource(
"bridge-ui",
resource_deps = ["proto-gen-web", "wasm-gen"],
resource_deps = [],
port_forwards = [
port_forward(3000, name = "Bridge UI [:3000]", host = webHost),
],
trigger_mode = trigger_mode,
)
if ci_tests:
docker_build(
ref = "tests-image",
context = ".",
dockerfile = "testing/Dockerfile.tests",
only = [],
live_update = [
sync("./spydk/js/src", "/app/spydk/js/src"),
sync("./sdk/js/src", "/app/sdk/js/src"),
sync("./testing", "/app/testing"),
sync("./bridge_ui/src", "/app/bridge_ui/src"),
],
)
k8s_yaml_with_ns("devnet/tests.yaml")
k8s_resource(
"ci-tests",
resource_deps = ["eth-devnet", "eth-devnet2", "terra-terrad", "terra-fcd", "solana-devnet", "spy", "guardian"],
trigger_mode = trigger_mode,
)
# algorand
k8s_yaml_with_ns("devnet/algorand.yaml")

View File

@ -1 +0,0 @@
REACT_APP_COVALENT_API_KEY=

View File

@ -1,19 +1,20 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
# Derivative of ethereum/Dockerfile, look there for an explanation on how it works.
FROM node:16-alpine@sha256:004dbac84fed48e20f9888a23e32fa7cf83c2995e174a78d41d9a9dd1e051a20
FROM node:16-alpine@sha256:f21f35732964a96306a84a8c4b5a829f6d3a0c5163237ff4b6b8b34f8d70064b
RUN mkdir -p /app
WORKDIR /app
ADD . .
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix ethereum
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix sdk/js
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm run build --prefix sdk/js
# these are only needed if you are using the local version of the sdk (npm i ../sdk/js)
# RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
# npm ci --prefix ethereum
# RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
# npm ci --prefix sdk/js
# RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
# npm run build --prefix sdk/js
WORKDIR ./bridge_ui

File diff suppressed because it is too large Load Diff

View File

@ -75,6 +75,9 @@
"@types/node": "^16.6.1",
"@types/numeral": "^2.0.2",
"@types/react-router-dom": "^5.1.8",
"babel-jest": "^26.6.0",
"jest": "^26.6.0",
"jest-watch-typeahead": "^0.6.4",
"prettier": "^2.3.2",
"truffle": "^5.4.1",
"wasm-loader": "^1.3.0"

View File

@ -0,0 +1,13 @@
const { describe, expect, it } = require("@jest/globals");
const fs = require("fs");
describe("SDK installation", () => {
it("does not import from file path", () => {
const packageFile = fs.readFileSync("./package.json");
const packageObj = JSON.parse(packageFile.toString());
const sdkInstallation =
packageObj?.dependencies?.["@certusone/wormhole-sdk"];
expect(sdkInstallation && !sdkInstallation.includes("file")).toBe(true);
});
});

24
devnet/tests.yaml Normal file
View File

@ -0,0 +1,24 @@
kind: Job
apiVersion: batch/v1
metadata:
name: ci-tests
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: ci-tests
image: tests-image
command:
- /bin/sh
- -c
- "sh /app/testing/allTests.sh && touch /app/testing/success"
readinessProbe:
exec:
command:
- test
- -e
- "/app/testing/success"
initialDelaySeconds: 5
periodSeconds: 5

3
sdk/js/ci-config.js Normal file
View File

@ -0,0 +1,3 @@
process.env.CI = true;
export default {};

View File

@ -3,5 +3,6 @@
"^.+\\.(t|j)sx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"testTimeout": 60000
}

View File

@ -1,12 +1,12 @@
{
"name": "@certusone/wormhole-sdk",
"version": "0.1.4",
"version": "0.1.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@certusone/wormhole-sdk",
"version": "0.1.4",
"version": "0.1.5",
"license": "Apache-2.0",
"dependencies": {
"@improbable-eng/grpc-web": "^0.14.0",

View File

@ -16,6 +16,7 @@
"build-lib": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node scripts/copyEthersTypes.js && node scripts/copyWasm.js",
"build-all": "npm run build-deps && npm run build-lib",
"test": "jest --config jestconfig.json --verbose",
"test-ci": "jest --config jestconfig.json --verbose --setupFiles ./ci-config.js --forceExit",
"build": "npm run build-all",
"format": "echo \"disabled: prettier --write \"src/**/*.ts\"\"",
"lint": "tslint -p tsconfig.json",

View File

@ -1,15 +1,19 @@
import { describe, expect, it } from "@jest/globals";
import { Connection, PublicKey } from "@solana/web3.js";
const ci = !!process.env.CI;
// see devnet.md
export const ETH_NODE_URL = "ws://localhost:8545";
export const ETH_NODE_URL = ci ? "ws://eth-devnet:8545" : "ws://localhost:8545";
export const ETH_PRIVATE_KEY =
"0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1"; // account 1
export const ETH_CORE_BRIDGE_ADDRESS =
"0xC89Ce4735882C9F0f0FE26686c53074E09B0D550";
export const ETH_NFT_BRIDGE_ADDRESS =
"0x26b4afb60d6c903165150c6f0aa14f8016be4aec";
export const SOLANA_HOST = "http://localhost:8899";
export const SOLANA_HOST = ci
? "http://solana-devnet:8899"
: "http://localhost:8899";
export const SOLANA_PRIVATE_KEY = new Uint8Array([
14, 173, 153, 4, 176, 224, 201, 111, 32, 237, 183, 185, 159, 247, 22, 161, 89,
84, 215, 209, 212, 137, 10, 92, 157, 49, 29, 192, 101, 164, 152, 70, 87, 65,
@ -20,9 +24,13 @@ export const SOLANA_CORE_BRIDGE_ADDRESS =
"Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o";
export const SOLANA_NFT_BRIDGE_ADDRESS =
"NFTWqJR8YnRVqPDvTJrYuLrQDitTG5AScqbeghi4zSA";
export const TERRA_NODE_URL = "http://localhost:1317";
export const TERRA_NODE_URL = ci
? "http://terra-terrad:1317"
: "http://localhost:1317";
export const TERRA_CHAIN_ID = "localterra";
export const TERRA_GAS_PRICES_URL = "http://localhost:3060/v1/txs/gas_prices";
export const TERRA_GAS_PRICES_URL = ci
? "http://terra-fcd:3060/v1/txs/gas_prices"
: "http://localhost:3060/v1/txs/gas_prices";
export const TERRA_CORE_BRIDGE_ADDRESS =
"terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5";
export const TERRA_NFT_BRIDGE_ADDRESS =
@ -33,7 +41,9 @@ export const TEST_ERC721 = "0x5b9b42d6e4B2e4Bf8d42Eba32D46918e10899B66";
export const TERRA_CW721_CODE_ID = 8;
export const TEST_CW721 = "terra1l425neayde0fzfcv3apkyk4zqagvflm6cmha9v";
export const TEST_SOLANA_TOKEN = "BVxyYhm498L79r4HMQ9sxZ5bi41DmJmeWZ7SCS7Cyvna";
export const WORMHOLE_RPC_HOSTS = ["http://localhost:7071"];
export const WORMHOLE_RPC_HOSTS = ci
? ["http://guardian:7071"]
: ["http://localhost:7071"];
describe("consts should exist", () => {
it("has Solana test token", () => {

View File

@ -1,15 +1,19 @@
import { describe, expect, it } from "@jest/globals";
import { Connection, PublicKey } from "@solana/web3.js";
const ci = !!process.env.CI;
// see devnet.md
export const ETH_NODE_URL = "ws://localhost:8545";
export const ETH_NODE_URL = ci ? "ws://eth-devnet:8545" : "ws://localhost:8545";
export const ETH_PRIVATE_KEY =
"0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d";
export const ETH_CORE_BRIDGE_ADDRESS =
"0xC89Ce4735882C9F0f0FE26686c53074E09B0D550";
export const ETH_TOKEN_BRIDGE_ADDRESS =
"0x0290FB167208Af455bB137780163b7B7a9a10C16";
export const SOLANA_HOST = "http://localhost:8899";
export const SOLANA_HOST = ci
? "http://solana-devnet:8899"
: "http://localhost:8899";
export const SOLANA_PRIVATE_KEY = new Uint8Array([
14, 173, 153, 4, 176, 224, 201, 111, 32, 237, 183, 185, 159, 247, 22, 161, 89,
84, 215, 209, 212, 137, 10, 92, 157, 49, 29, 192, 101, 164, 152, 70, 87, 65,
@ -20,9 +24,13 @@ export const SOLANA_CORE_BRIDGE_ADDRESS =
"Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o";
export const SOLANA_TOKEN_BRIDGE_ADDRESS =
"B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE";
export const TERRA_NODE_URL = "http://localhost:1317";
export const TERRA_NODE_URL = ci
? "http://terra-terrad:1317"
: "http://localhost:1317";
export const TERRA_CHAIN_ID = "localterra";
export const TERRA_GAS_PRICES_URL = "http://localhost:3060/v1/txs/gas_prices";
export const TERRA_GAS_PRICES_URL = ci
? "http://terra-fcd:3060/v1/txs/gas_prices"
: "http://localhost:3060/v1/txs/gas_prices";
export const TERRA_CORE_BRIDGE_ADDRESS =
"terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5";
export const TERRA_TOKEN_BRIDGE_ADDRESS =
@ -31,7 +39,9 @@ export const TERRA_PRIVATE_KEY =
"notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius";
export const TEST_ERC20 = "0x2D8BE6BF0baA74e0A907016679CaE9190e80dD0A";
export const TEST_SOLANA_TOKEN = "2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ";
export const WORMHOLE_RPC_HOSTS = ["http://localhost:7071"];
export const WORMHOLE_RPC_HOSTS = ci
? ["http://guardian:7071"]
: ["http://localhost:7071"];
describe("consts should exist", () => {
it("has Solana test token", () => {

3
spydk/js/ci-config.js Normal file
View File

@ -0,0 +1,3 @@
process.env.CI = true;
export default {};

View File

@ -13,6 +13,7 @@
"build-lib": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
"build-all": "npm run build-lib",
"test": "jest --config jestconfig.json --verbose",
"test-ci": "jest --config jestconfig.json --verbose --setupFiles ./ci-config.js --forceExit",
"build": "npm run build-all",
"format": "echo \"disabled: prettier --write \"src/**/*.ts\"\"",
"lint": "tslint -p tsconfig.json",

View File

@ -7,8 +7,10 @@ import { createSpyRPCServiceClient, subscribeSignedVAA } from "..";
setDefaultWasm("node");
jest.setTimeout(60000);
const SOLANA_HOST = "http://localhost:8899";
const ci = !!process.env.CI;
export const SOLANA_HOST = ci
? "http://solana-devnet:8899"
: "http://localhost:8899";
const SOLANA_PRIVATE_KEY = new Uint8Array([
14, 173, 153, 4, 176, 224, 201, 111, 32, 237, 183, 185, 159, 247, 22, 161, 89,
84, 215, 209, 212, 137, 10, 92, 157, 49, 29, 192, 101, 164, 152, 70, 87, 65,
@ -19,7 +21,7 @@ const SOLANA_CORE_BRIDGE_ADDRESS =
"Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o";
const SOLANA_TOKEN_BRIDGE_ADDRESS =
"B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE";
const SPYMASTER = "localhost:7072";
const SPYMASTER = ci ? "spy:7072" : "localhost:7072";
const TEST_SOLANA_TOKEN = "2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ";
test("Can spy on messages", (done) => {

27
testing/Dockerfile.tests Normal file
View File

@ -0,0 +1,27 @@
FROM node:16-alpine@sha256:004dbac84fed48e20f9888a23e32fa7cf83c2995e174a78d41d9a9dd1e051a20
RUN mkdir -p /app
WORKDIR /app
ADD . .
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix ethereum
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix sdk/js
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm run build --prefix sdk/js
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix spydk/js
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm run build --prefix spydk/js
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix bridge_ui
WORKDIR ./testing

5
testing/allTests.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
CI=true npm --prefix ../sdk/js run test-ci
CI=true npm --prefix ../spydk/js run test-ci
CI=true npm --prefix ../bridge_ui run test