Skip to content

Commit

Permalink
Adds functional (typescript) tests for Eth RPC (#74)
Browse files Browse the repository at this point in the history
* Adds functional (typescript) tests for Eth RPC

* Adds not supported for compilers rpc methods

* Adds tests for compilers, estimateGas and contract

* Fix formatting

* Adds more tests

* Use editorconfig instead of prettier for TS

* Adds test for gas recomputation

* Adds log documentation for ts tests

* More tests + formatting

* draft for CI functional test integration

* Better support for nodejs in rust CI

* testing CI integration for NodeJs
  • Loading branch information
crystalin committed Jul 23, 2020
1 parent 5f1ad2b commit e1e984b
Show file tree
Hide file tree
Showing 31 changed files with 5,582 additions and 36 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ jobs:
run: cargo build --verbose --all
- name: Run tests
run: cargo test --verbose --all
- name: Use Node.js 10
uses: actions/setup-node@v1
with:
node-version: 10
- name: Install functional tests typescript
run: cd ts-tests && npm install
- name: Run functional tests
run: cd ts-tests && npm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/target/
**/node_modules/
**/*.rs.bk
*.swp
.wasm-binaries
Expand Down
144 changes: 114 additions & 30 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ members = [
"template/node",
"template/runtime",
"template/test-utils/client",
"ts-tests/frontier-test-node/node",
"ts-tests/frontier-test-node/runtime",
]
exclude = ["vendor"]

[patch.crates-io]
ethereum = { path = "vendor/ethereum" }
ethereum = { path = "vendor/ethereum" }
15 changes: 11 additions & 4 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ fn internal_err(message: &str) -> Error {
data: None
}
}
fn not_supported_err(message: &str) -> Error {
Error {
code: ErrorCode::InvalidRequest,
message: message.to_string(),
data: None
}
}

pub struct EthApi<B: BlockT, C, SC, P, CT, BE> {
pool: Arc<P>,
Expand Down Expand Up @@ -649,19 +656,19 @@ impl<B, C, SC, P, CT, BE> EthApiT for EthApi<B, C, SC, P, CT, BE> where
}

fn compilers(&self) -> Result<Vec<String>> {
unimplemented!("compilers");
Err(not_supported_err("Method eth_getCompilers not supported."))
}

fn compile_lll(&self, _: String) -> Result<Bytes> {
unimplemented!("compile_lll");
Err(not_supported_err("Method eth_compileLLL not supported."))
}

fn compile_solidity(&self, _: String) -> Result<Bytes> {
unimplemented!("compile_solidity");
Err(not_supported_err("Method eth_compileSolidity not supported."))
}

fn compile_serpent(&self, _: String) -> Result<Bytes> {
unimplemented!("compile_serpent");
Err(not_supported_err("Method eth_compileSerpent not supported."))
}

fn logs(&self, _: Filter) -> BoxFuture<Vec<Log>> {
Expand Down
2 changes: 1 addition & 1 deletion template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ ENV PROFILE ${PROFILE}
# The execution will re-compile the project to run it
# This allows to modify the code and not have to re-compile the
# dependencies.
CMD cargo run "--$PROFILE" -- --dev
CMD cargo run --bin frontier-template-node "--$PROFILE" -- --dev
2 changes: 2 additions & 0 deletions ts-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
frontier-test-tmp
30 changes: 30 additions & 0 deletions ts-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Functional testing for Substrate Frontier Node RPC

This folder contains a set of functional tests desgined to perform functional testing on the Frontier Eth RPC.

It is written in typescript, using Mocha/Chai as Test framework.

## Test flow

Tests are separated depending of their genesis requirements.
Each group will start a [frontier test node](frontier-test-node) with a given [spec](substrate-specs) before executing the tests.

## Installation

```
npm install
```

## Run the tests

```
npm run test
```

You can also add the Frontier Node logs to the output using the `FRONTIER_LOG` env variable. Ex:

```
FRONTIER_LOG="warn,rpc=trace" npm run test
```

(The frontier node be listening for RPC on port 19933, mostly to avoid conflict with already running substrate node)
3 changes: 3 additions & 0 deletions ts-tests/frontier-test-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Substrate Frontier Node for functional testing

**Warning**: This node is only used to run tests.
Loading

0 comments on commit e1e984b

Please sign in to comment.