Skip to content

Commit

Permalink
iqkms: factor out Ethereum integration tests; run in CI (#23)
Browse files Browse the repository at this point in the history
Moves integration tests to a `tests` subdirectory.
  • Loading branch information
tony-iqlusion authored Nov 17, 2022
1 parent 31c0fab commit 8697013
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/iqkms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ env:
RUSTFLAGS: "-Dwarnings"

jobs:
# TODO(tarcieri): run tests in CI
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,5 +33,5 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
- run: sudo apt-get install protobuf-compiler
- run: cargo build
- run: cargo build --release
- run: cargo test
- run: cargo test --release
1 change: 0 additions & 1 deletion Cargo.lock

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

29 changes: 0 additions & 29 deletions iqkms/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,3 @@ impl From<SignerClientInner> for SignerClient {
SignerClient { inner }
}
}

#[cfg(test)]
mod tests {
use super::{Address, SignerClient, StdError, H256};

#[tokio::test]
async fn it_works() -> Result<(), StdError> {
let mut client = SignerClient::connect("http://[::1]:27100").await?;

// TODO(tarcieri): real signing key address
let address = "0x27b1fdb04752bbc536007a920d24acb045561c26"
.parse::<Address>()
.unwrap();

let chain_id = 2018;
let digest = H256::from([
0x6f, 0xd4, 0x3e, 0x7c, 0xff, 0xc3, 0x1b, 0xb5, 0x81, 0xd7, 0x42, 0x1c, 0x86, 0x98,
0xe2, 0x9a, 0xa2, 0xbd, 0x8e, 0x71, 0x86, 0xa3, 0x94, 0xb8, 0x52, 0x99, 0x90, 0x8b,
0x4e, 0xb9, 0xb1, 0x75,
]);

let response = client
.sign_digest_with_eip155(address, digest, chain_id)
.await
.unwrap();
println!("RESPONSE={:?}", response);
Ok(())
}
}
37 changes: 37 additions & 0 deletions iqkms/tests/ethereum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Ethereum integration tests.
//!
//! Requires running `iqkms` instance. Use `cargo test -- --ignored` to run.
// TODO(tarcieri): start iqkms for proper integration test.

#![cfg(feature = "ethereum")]

use iqkms::{
ethereum::{Address, SignerClient, H256},
StdError,
};

#[ignore]
#[tokio::test]
async fn sign_digest_with_eip155() -> Result<(), StdError> {
let mut client = SignerClient::connect("http://[::1]:27100").await?;

// TODO(tarcieri): real signing key address
let address = "0x27b1fdb04752bbc536007a920d24acb045561c26"
.parse::<Address>()
.unwrap();

let chain_id = 2018;
let digest = H256::from([
0x6f, 0xd4, 0x3e, 0x7c, 0xff, 0xc3, 0x1b, 0xb5, 0x81, 0xd7, 0x42, 0x1c, 0x86, 0x98, 0xe2,
0x9a, 0xa2, 0xbd, 0x8e, 0x71, 0x86, 0xa3, 0x94, 0xb8, 0x52, 0x99, 0x90, 0x8b, 0x4e, 0xb9,
0xb1, 0x75,
]);

let response = client
.sign_digest_with_eip155(address, digest, chain_id)
.await
.unwrap();

println!("RESPONSE={:?}", response);
Ok(())
}

0 comments on commit 8697013

Please sign in to comment.