Skip to content

Commit

Permalink
Get CI Working (#10)
Browse files Browse the repository at this point in the history
* fix linting

* Fix lint errors

* Add simple github actions file to run rust tests

* Update toolchain

* Rename tests
  • Loading branch information
ryardley authored Aug 22, 2024
1 parent 54fda0f commit db7064e
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "CI"
name: "EVM"

env:
HARDHAT_VAR_MNEMONIC: "test test test test test test test test test test test junk"
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rust

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install latest stable Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Run tests
run: |
cd ./packages/ciphernode/
cargo test
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"recommendations": ["esbenp.prettier-vscode", "NomicFoundation.hardhat-solidity"]
"recommendations": [
"esbenp.prettier-vscode",
"NomicFoundation.hardhat-solidity"
]
}
328 changes: 164 additions & 164 deletions LICENSE.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"evm:test": "cd packages/evm && yarn test",
"evm:coverage": "cd packages/evm && yarn coverage",
"preinstall": "yarn evm:install"
}
},
"dependencies": {}
}
11 changes: 4 additions & 7 deletions packages/ciphernode/p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::hash::{Hash, Hasher};
use std::time::Duration;
use tokio::{io, io::AsyncBufReadExt, select};
use tracing_subscriber::EnvFilter;
use bfv::EnclaveBFV;

#[derive(NetworkBehaviour)]
struct MyBehaviour {
Expand Down Expand Up @@ -48,7 +47,7 @@ impl EnclaveRouter {
self.identity = Some(keypair);
}

pub fn connect_swarm(&mut self, discovery_type: String) -> Result<(&Self), Box<dyn Error>> {
pub fn connect_swarm(&mut self, discovery_type: String) -> Result<&Self, Box<dyn Error>> {
match discovery_type.as_str() {
"mdns" => {
let _ = tracing_subscriber::fmt()
Expand Down Expand Up @@ -80,14 +79,14 @@ impl EnclaveRouter {
},
_ => println!("Defaulting to MDNS discovery"),
}
Ok((self))
Ok(self)
}

pub fn join_topic(&mut self, topic_name: &str) -> Result<(&Self), Box<dyn Error>> {
pub fn join_topic(&mut self, topic_name: &str) -> Result<&Self, Box<dyn Error>> {
let topic = gossipsub::IdentTopic::new(topic_name);
self.topic = Some(topic.clone());
self.swarm.as_mut().unwrap().behaviour_mut().gossipsub.subscribe(&topic)?;
Ok((self))
Ok(self)
}

pub async fn start(&mut self) -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -138,8 +137,6 @@ impl EnclaveRouter {
}
}
}

Ok(())
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/evm/contracts/test/MockCyphernodeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract MockCyphernodeRegistry is ICyphernodeRegistry {
uint256,
bytes calldata,
bytes calldata
) external {}
) external {} // solhint-disable-line no-empty-blocks

function committeePublicKey(
uint256 e3Id
Expand Down Expand Up @@ -54,7 +54,7 @@ contract MockCyphernodeRegistryEmptyKey is ICyphernodeRegistry {
uint256,
bytes calldata,
bytes calldata
) external {}
) external {} // solhint-disable-line no-empty-blocks

function committeePublicKey(uint256) external pure returns (bytes memory) {
return hex"";
Expand Down
14 changes: 7 additions & 7 deletions packages/evm/test/Enclave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ describe("Enclave", function () {
{ value: 10 },
);

mine(1, { interval: 1000 });
const _ = mine(1, { interval: 1000 });

await expect(enclave.activate(0)).to.be.revertedWithCustomError(
enclave,
Expand Down Expand Up @@ -746,7 +746,7 @@ describe("Enclave", function () {
{ value: 10 },
);

mine(1, { interval: 1000 });
const _ = mine(1, { interval: 1000 });

await expect(enclave.activate(0)).to.be.revertedWithCustomError(
enclave,
Expand Down Expand Up @@ -954,10 +954,10 @@ describe("Enclave", function () {

await enclave.activate(0);

expect(await enclave.publishInput(0, inputData)).to.not.be.reverted;
await expect(await enclave.publishInput(0, inputData)).to.not.be.reverted;
let e3 = await enclave.getE3(0);
expect(e3.inputs[0]).to.equal(inputData);
expect(await enclave.publishInput(0, inputData)).to.not.be.reverted;
await expect(await enclave.publishInput(0, inputData)).to.not.be.reverted;
e3 = await enclave.getE3(0);
expect(e3.inputs[1]).to.equal(inputData);
});
Expand Down Expand Up @@ -1011,7 +1011,7 @@ describe("Enclave", function () {

describe("publishCiphertextOutput()", function () {
it("reverts if E3 does not exist", async function () {
const { enclave, request } = await loadFixture(setup);
const { enclave } = await loadFixture(setup);

await expect(enclave.publishCiphertextOutput(0, "0x"))
.to.be.revertedWithCustomError(enclave, "E3DoesNotExist")
Expand Down Expand Up @@ -1173,7 +1173,7 @@ describe("Enclave", function () {

describe("publishPlaintextOutput()", function () {
it("reverts if E3 does not exist", async function () {
const { enclave, request } = await loadFixture(setup);
const { enclave } = await loadFixture(setup);
const e3Id = 0;

await expect(enclave.publishPlaintextOutput(e3Id, "0x"))
Expand Down Expand Up @@ -1330,7 +1330,7 @@ describe("Enclave", function () {
await enclave.activate(e3Id);
await mine(2, { interval: request.duration });
await enclave.publishCiphertextOutput(e3Id, "0x1337");
expect(await enclave.publishPlaintextOutput(e3Id, "0x1337"))
await expect(await enclave.publishPlaintextOutput(e3Id, "0x1337"))
.to.emit(enclave, "PlaintextOutputPublished")
.withArgs(e3Id, "0x1337");
});
Expand Down

0 comments on commit db7064e

Please sign in to comment.