Skip to content

Commit

Permalink
Merge pull request #2 from smartcontractkit/gauntlet-start
Browse files Browse the repository at this point in the history
Gauntlet starter
  • Loading branch information
RodrigoAD authored May 19, 2022
2 parents 2fd8eec + 47b3817 commit 7035f66
Show file tree
Hide file tree
Showing 78 changed files with 21,371 additions and 9 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/gauntlet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: gauntlet

on:
push:

jobs:
gauntlet_build:
name: Gauntlet Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f25a3a9f25bd5f4c5d77189cab02ff357b5aedeb # v2.4.1
- uses: smartcontractkit/[email protected]
id: tool-versions
- name: Setup Node ${{ steps.tool-versions.outputs.nodejs_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.tool-versions.outputs.nodejs_version }}
- name: Install
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Run Gauntlet
run: yarn gauntlet

gauntlet_format:
name: Gauntlet Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f25a3a9f25bd5f4c5d77189cab02ff357b5aedeb # v2.4.1
- uses: smartcontractkit/[email protected]
id: tool-versions
- name: Setup Node ${{ steps.tool-versions.outputs.nodejs_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.tool-versions.outputs.nodejs_version }}
- name: Install
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint:format

gauntlet_run_tests:
name: Gauntlet Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f25a3a9f25bd5f4c5d77189cab02ff357b5aedeb # v2.4.1
- uses: smartcontractkit/[email protected]
id: tool-versions
- name: Setup Node ${{ steps.tool-versions.outputs.nodejs_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.tool-versions.outputs.nodejs_version }}
- name: Install
run: yarn install --frozen-lockfile
- name: test:ci
run: yarn test:ci
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ accounts.json
node.json
package-lock.json
node_modules/
flow-report.json
.env
report.json
bin
**/tsconfig.tsbuildinfo

.DS_Store
.temp/
Expand All @@ -24,7 +29,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
./lib/
lib64/
parts/
sdist/
Expand Down
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
migrations
programs
tests
ops
packages-rs
relay
target
*.json
dist
*.yml
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 120,
"endOfLine": "auto",
"trailingComma": "all"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022 SmartContract ChainLink, Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions docs/gauntlet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Table of Contents

- Use Gauntlet
- [Local Install](./getting_started.md#setup)
- [Binary](./getting_started.md#binary)
- [Basic Setup](./getting_started.md#basic-setup)
- [CLI](../../packages-ts/gauntlet-starknet-cli/README.md)
- [Example Contract](../../packages-ts/gauntlet-starknet-example/README.md)
- [Account Contract](../../packages-ts/gauntlet-starknet-account/README.md)
- [OCR2 Contracts](../../packages-ts/gauntlet-starknet-ocr2/README.md)
- Contribute
73 changes: 73 additions & 0 deletions docs/gauntlet/getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Getting started

## Setup

Make sure you have Node and Yarn installed

Node: https://nodejs.org/es/download/

Yarn:

```
npm install --global yarn
```

### Install

```
yarn
```

### Run

To see the available commands, run:

```
yarn gauntlet
```

## Binary

To easily use Gauntlet, we recommend to use the binary. To generate it, run:

```
yarn bundle
```

It will generate 2 binaries, for Linux and MacOS distributions. To use them, replace `yarn gauntlet` with `./bin/chainlink-starknet-<linux|macos>`

```bash
./bin/chainlink-starknet-macos

🧤 gauntlet 0.2.0
ℹ️ Available gauntlet commands:

example:
example:deploy
example:increase_balance
example:inspect

account:
account:deploy


ℹ️ Available global flags:

--help, -h Display information about command usage
--network The network to connect to
```

## Basic Setup

To deploy or query contracts you do not need any configuration. If you want to execute some contract method, you will need a wallet configured. The details should be added into a `.env` file in the root of the project.

```bash
## Public key of the account contract
ACCOUNT=0x...
## Private key of the wallet configured on the account contract
PRIVATE_KEY=0x...
```

In order to get this configuration, go to [how to setup an account](../../packages-ts/gauntlet-starknet-account/README.md#setup-an-account)

If you are interacting with a local network and do not want to use any wallet, execute every command with the flag `--noWallet`
3 changes: 2 additions & 1 deletion docs/integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## Integration tests
See examples [here](testing.md)

See examples [here](testing.md)
15 changes: 14 additions & 1 deletion docs/integration-tests/testing.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
## Integration tests usage

Setup k8s context, if you don't have k8s, spin up a local cluster using [this](../kubernetes.md) guide

### Run tests using ephemeral envs

```
make e2e_test
```

### Run tests on a standalone local env

1. Spin up an env, for example, see yaml file for more options with a stark-devnet/pathfinder real node

```
envcli new -p ops/chainlink-starknet.yaml
```

2. Check created file in a previous command output, example `Environment setup and written to file environmentFile=chainlink-stark-k42hp.yaml`
3. Run the tests

```
ENVIRONMENT_FILE="$(pwd)/chainlink-stark-k42hp.yaml" KEEP_ENVIRONMENTS="Always" make e2e_test
```

4. Check the env file or connect command logs for a forwarded `local_ports` and try it in the browser
5. Destroy the env

```
envcli rm -e chainlink-stark-b7mt9.yaml
```

### Interact with an env using other scripts

1. Spin up an env, for example, see yaml file for more options with a stark-devnet/pathfinder real node

```
envcli new -p ops/chainlink-starknet.yaml
```

2. Check created file in a previous command output, example `Environment setup and written to file environmentFile=chainlink-stark-mx7rg.yaml`
3. Connect to your env

```
envcli connect -e ${your_env_file_yaml}
```

4. Check the env file or connect command logs for a forwarded `local_ports` and try it in the browser
5. Interact using other scripts
6. Destroy the env

```
envcli rm -e chainlink-stark-b7mt9.yaml
```
```
6 changes: 4 additions & 2 deletions docs/kubernetes.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Kubernetes

We run our software in Kubernetes.

### Local k3d setup

1. `make install`
2. (Optional) Install `Lens` from [here](https://k8slens.dev/) or use `k9s` as a low resource consumption alternative from [here](https://k9scli.io/topics/install/)
or from source [here](https://github.com/smartcontractkit/helmenv)
or from source [here](https://github.com/smartcontractkit/helmenv)
3. Setup your docker resources, 6vCPU/10Gb RAM are enough for most CL related tasks
4. `k3d cluster create local`
5. Check your contexts with `kubectl config get-contexts`
6. Switch context `kubectl config use-context k3d-local`
7. Run any tests, use a guide [here](integration-tests/README.md)
8. Stop the cluster

```
k3d cluster stop local
```
```
5 changes: 4 additions & 1 deletion integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Local k8s run

See [there](../docs/integration-tests/README.md)

# Integration Tests
For more information, see the [Chainlink StarkNet Documentation | Integration Tests](../docs/integration-tests).

For more information, see the [Chainlink StarkNet Documentation | Integration Tests](../docs/integration-tests).
2 changes: 1 addition & 1 deletion integration-tests/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ environment_file:
# Specify the image and version of the chainlink image you want to run tests against. Leave blank for default.
chainlink_image:
chainlink_version:
chainlink_env_values:
chainlink_env_values:
4 changes: 2 additions & 2 deletions integration-tests/networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ networks:
name: 'StarkNet dev simulator'
chain_id: 2020
type: l2_starknet_dev
l1_bridge_addr: "0x83D76591560d9CD02CE16c060c92118d19F996b3"
l1_bridge_addr: '0x83D76591560d9CD02CE16c060c92118d19F996b3'
ethereum_kovan: &common_ethereum_testnet
name: 'Ethereum Kovan'
chain_id: 42
Expand All @@ -64,4 +64,4 @@ networks:
chain_id: 5
private_url: goerli_private_url
private_keys:
- goerli_testnet_1
- goerli_testnet_1
38 changes: 38 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
rootDir: '.',
projects: [
{
displayName: 'gauntlet-starknet',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages-ts/gauntlet-starknet/**/*.test.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/packages-ts/gauntlet-starknet/tsconfig.json',
},
},
},
{
displayName: 'gauntlet-starknet-account',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages-ts/gauntlet-starknet-account/**/*.test.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/packages-ts/gauntlet-starknet-account/tsconfig.json',
},
},
},
{
displayName: 'gauntlet-starknet-ocr2',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages-ts/gauntlet-starknet-ocr2/**/*.test.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/packages-ts/gauntlet-starknet-ocr2/tsconfig.json',
},
},
},
],
}
Loading

0 comments on commit 7035f66

Please sign in to comment.