Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Tests #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
LISTEN_URL='0.0.0.0:8000'
INFURA_PROJECT_ID=
PRIVATE_KEY=
CHAIN_ID=3
SIGNER_PRIVATE_KEY=
CHAIN_ID=4
MORALIS_BASE_URL=https://deep-index.moralis.io/api/v2/
MORALIS_API_KEY=
SWAGGER_JSON=/swagger.json

# Testing envs
SIGNER_ADDRESS=
TESTING_ADDRESS=
32 changes: 12 additions & 20 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ env_logger = "0.8"
log = "0.4"
ethcontract = { version = "0.15.4" }

[dev-dependencies]
rand = "0.8.5"
actix-http = "3.0.4"

[build-dependencies]
ethcontract-generate = { version = "0.15.4" }
57 changes: 38 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@

- Install [Rust](https://www.rust-lang.org/). Using [Rustup](https://rustup.rs/)
Run the following in your terminal, then follow the onscreen instructions:

```
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

### Usage

- Clone the repository.

```bash
$ git clone [email protected]:SugarFunge/sugarfunge-integration.git
git clone [email protected]:SugarFunge/sugarfunge-integration.git
```

- Compile the truffle contracts and copy the `build/contracts` folder to the root folder of this repository

```bash
$ cd sugarfunge-integration
$ cp $TRUFFLE_ROOT/build/contracts .
cd sugarfunge-integration
cp $TRUFFLE_ROOT/build/contracts .
```

- Copy the environment file as **.env** and make the changes based on your needs

```bash
$ cp .env.example .env
cp .env.example .env
```

- Start the API

```bash
# Normal run
$ cargo run
# Auto-reload
$ cargo watch -x 'run --bin sugarfunge-integration'
```

### Testing

```bash
# Normal run
$ cargo test -- --test-threads=1
# Debugging
$ RUST_BACKTRACE=full cargo test -- --test-threads=1 --nocapture
```

## Swagger API Documentation & Prometheus Server

### Software requirements
Expand All @@ -47,33 +61,38 @@ $ cargo watch -x 'run --bin sugarfunge-integration'
### Usage

- Copy the environment file as **.env** and make the changes based on your needs (Optional if you already configured the API above)

```bash
$ cp .env.example .env
cp .env.example .env
```

- Start the docker-compose file ([Access Swagger UI](http://localhost:7000)) ([Access Prometheus Server](http://localhost:9090))

```bash
$ docker-compose up -d
docker-compose up -d
```

- Stop the docker-compose file

```bash
$ docker-compose down
docker-compose down
```

## Environment configuration

- Default environment file: **.env**
- Example environment file: **.env.example**

| Variable Name | Description |
| --------------------------- | ------------------------------------------- |
| RUST_LOG | Rust log level |
| RUST_BACKTRACE | Show Rust backtrace (0 or 1) |
| LISTEN_URL | API Listen URL |
| INFURA_PROJECT_ID | Infura Project ID |
| PRIVATE_KEY | Private Key used to interact with contracts |
| CHAIN_ID | Chain ID (Default: 3 / Ropsten testnet) |
| MORALIS_BASE_URL | Moralis API base URL |
| MORALIS_API_KEY | Moralis API Key |
| SWAGGER_JSON | Swagger json file path inside the container |
| Variable Name | Description |
| --------------------------- | --------------------------------------------------------------|
| RUST_LOG | Rust log level |
| RUST_BACKTRACE | Show Rust backtrace (0 or 1) |
| LISTEN_URL | API Listen URL |
| INFURA_PROJECT_ID | Infura Project ID |
| SIGNER_PRIVATE_KEY | Private Key used to interact with contracts |
| SIGNER_ADDRESS | Address used to interact with contracts during tests |
| TESTING_ADDRESS | Receiver Address used to interact with contracts during tests |
| CHAIN_ID | Chain ID (Default: 4 / Rinkeby testnet) |
| MORALIS_BASE_URL | Moralis API base URL |
| MORALIS_API_KEY | Moralis API Key |
| SWAGGER_JSON | Swagger json file path inside the container |
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
let dest = std::path::Path::new(&out_dir).join("SugarFungeAsset.rs");

let artifact = TruffleLoader::new()
.load_from_file("./contracts/SugarFunge/SugarFungeAsset.json")
.load_from_file("./contracts/SugarFungeAsset.json")
.unwrap();

for contract in artifact.iter() {
Expand All @@ -24,7 +24,7 @@ fn main() {
let dest = std::path::Path::new(&out_dir).join("Wrapped1155Factory.rs");

let artifact = TruffleLoader::new()
.load_from_file("./contracts/ErcWrapper/Wrapped1155Factory.json")
.load_from_file("./contracts/Wrapped1155Factory.json")
.unwrap();

for contract in artifact.iter() {
Expand Down
Loading