Skip to content

Commit

Permalink
Add Indy-Besu CI (#9)
Browse files Browse the repository at this point in the history
* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* Bebug

Signed-off-by: toktar <[email protected]>

* added ci for indy-besu

Signed-off-by: DenisRybas <[email protected]>

* run localnet error fix

Signed-off-by: DenisRybas <[email protected]>

* fixed error with cargo fmt

Signed-off-by: DenisRybas <[email protected]>

* removed comments

Signed-off-by: DenisRybas <[email protected]>

* removed styles from scripts

Signed-off-by: DenisRybas <[email protected]>

* removed styles from scripts

Signed-off-by: DenisRybas <[email protected]>

* cleanup

Signed-off-by: DenisRybas <[email protected]>

* removed extra actions

Signed-off-by: DenisRybas <[email protected]>

* test workflow trigger

Signed-off-by: DenisRybas <[email protected]>

* separated tests from lint

Signed-off-by: DenisRybas <[email protected]>

* changed jobs sequence for indy-besu workflow

Signed-off-by: DenisRybas <[email protected]>

* removed updated needs section for tests-vdr

Signed-off-by: DenisRybas <[email protected]>

* added demos run to ci

Signed-off-by: DenisRybas <[email protected]>

* Fixed errors in tests

Signed-off-by: DenisRybas <[email protected]>

* renamed creator, updated docs

Signed-off-by: DenisRybas <[email protected]>

* removed comments

Signed-off-by: DenisRybas <[email protected]>

* fixed linter errors

Signed-off-by: DenisRybas <[email protected]>

* updated post-merge hook

Signed-off-by: DenisRybas <[email protected]>

* workflow trigger test

Signed-off-by: DenisRybas <[email protected]>

* updated design doc

Signed-off-by: DenisRybas <[email protected]>

---------

Signed-off-by: toktar <[email protected]>
Signed-off-by: DenisRybas <[email protected]>
Co-authored-by: DenisRybas <[email protected]>
  • Loading branch information
Toktar and DenisRybas committed Nov 23, 2023
1 parent 7091cf5 commit 9fa68b8
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 25 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/indy-besu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
pull_request:
paths: "indy-besu/**"

workflow_dispatch:

jobs:
lint-contracts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install dependencies
run: yarn install
working-directory: indy-besu/smart_contracts
- name: Lint
run: yarn lint-check
working-directory: indy-besu/smart_contracts

test-contracts:
needs: lint-contracts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install dependencies
run: yarn install
working-directory: indy-besu/smart_contracts
- name: Unit tests
run: yarn test
working-directory: indy-besu/smart_contracts
- name: Run localnet
run: ./network/scripts/run.sh && sleep 40
working-directory: indy-besu
- name: Demos
run: yarn demos
working-directory: indy-besu/smart_contracts

lint-vdr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Lint
run: cargo fmt --check
working-directory: indy-besu/vdr

store-artifacts:
needs: lint-vdr
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install dependencies
run: yarn add hardhat
working-directory: indy-besu/smart_contracts
- name: Compile smart contracts
run: yarn compile
working-directory: indy-besu/smart_contracts
- name: Archive contract artifacts
uses: actions/upload-artifact@v3
with:
name: smart-contracts-artifacts
path: indy-besu/smart_contracts/artifacts/**
retention-days: 3

test-vdr:
needs: store-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Download contract artifcats
uses: actions/download-artifact@v3
with:
name: smart-contracts-artifacts
path: indy-besu/smart_contracts/artifacts
- name: Run localnet
run: ./network/scripts/run.sh && sleep 40
working-directory: indy-besu
- name: Test
run: cargo test --features=ledger_test -- --test-threads=1
working-directory: indy-besu/vdr
4 changes: 4 additions & 0 deletions indy-besu/docs/design/did-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
struct DidMetadata {
address creator;
uint256 created;
uint256 updated;
bool deactivated;
Expand Down Expand Up @@ -69,6 +70,7 @@
"did:indy2:testnet:SEp33q43PsdP7nDATyySSH": {
document: DidDoc,
metadata: {
creator: 0x93917cadbace5dfce132b991732c6cda9bcc5b8a,
created: 1234,
updated: 1234,
deactivated: false
Expand Down Expand Up @@ -184,6 +186,7 @@ Contract name: **DidRegistry**
* Restrictions:
* DID must exist
* DID must be active
* Sender must be DID creator
* Format:
```
DidRegistry.updateDid(
Expand Down Expand Up @@ -220,6 +223,7 @@ Contract name: **DidRegistry**
* Restrictions:
* DID must exist
* DID must be active
* Sender must be DID creator
* Format:
```
DidRegistry.deactivateDid(
Expand Down
4 changes: 0 additions & 4 deletions indy-besu/network/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ if [ "$me" = ".common.sh" ];then
exit 1
fi

# bold and normal text styles
bold=$(tput bold)
normal=$(tput sgr0)

# checks docker installed
hash docker 2>/dev/null || {
echo >&2 "This script requires Docker but it's not installed."
Expand Down
4 changes: 2 additions & 2 deletions indy-besu/network/scripts/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ maxRetryCount=50
HOST=${DOCKER_PORT_2375_TCP_ADDR:-"localhost"}

# Displays links to exposed services
echo "${bold}*************************************"
echo "*************************************"
echo "Localnet "
echo "*************************************${normal}"
echo "*************************************"

echo "----------------------------------"
echo "List endpoints and services"
Expand Down
4 changes: 2 additions & 2 deletions indy-besu/network/scripts/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ removeDockerImage(){
fi
}

echo "${bold}*************************************"
echo "*************************************"
echo "Localnet"
echo "*************************************${normal}"
echo "*************************************"
echo "Stop and remove network..."

docker compose --profile services down -v
Expand Down
4 changes: 2 additions & 2 deletions indy-besu/network/scripts/resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ NO_LOCK_REQUIRED=false
. ./.env
source "$(dirname "$0")/common.sh"

echo "${bold}*************************************"
echo "*************************************"
echo "Localnet"
echo "*************************************${normal}"
echo "*************************************"
echo "Resuming network..."
echo "----------------------------------"

Expand Down
4 changes: 2 additions & 2 deletions indy-besu/network/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ source "$(dirname "$0")/common.sh"
# Build and run containers and network
echo "docker-compose.yml" > ${LOCK_FILE}

echo "${bold}*************************************"
echo "*************************************"
echo "Localnet"
echo "*************************************${normal}"
echo "*************************************"
echo "Start network"
echo "--------------------"

Expand Down
4 changes: 2 additions & 2 deletions indy-besu/network/scripts/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ NO_LOCK_REQUIRED=false
. ./.env
source "$(dirname "$0")/common.sh"

echo "${bold}*************************************"
echo "*************************************"
echo "Localnet"
echo "*************************************${normal}"
echo "*************************************"
echo "Stopping network"
echo "----------------------------------"

Expand Down
9 changes: 9 additions & 0 deletions indy-besu/smart_contracts/.husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

CONTRACTS_DIR="indy-besu/smart_contracts"

# Change to the smart contracts directory
cd "$CONTRACTS_DIR" || exit

# Run yarn compile to compile new smart contracts
yarn compile
2 changes: 1 addition & 1 deletion indy-besu/smart_contracts/.solhintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# generated regex contract
# Generated regex contract.
DidRegex.sol
3 changes: 3 additions & 0 deletions indy-besu/smart_contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"ts-lint": "tslint --fix -p tsconfig.json -c tslint.json",
"solhint": "solhint --fix -f unix -c solhint.json contracts/**/*.sol",
"lint": "yarn ts-lint && yarn solhint",
"ts-lint-check": "tslint -p tsconfig.json -c tslint.json",
"solhint-check": "solhint -c solhint.json contracts/**/*.sol",
"lint-check": "yarn ts-lint-check && yarn solhint-check",
"format": "prettier --write \"contracts/**/*.sol\" \"scripts/**/*.ts\" \"contracts-ts/**/*.ts\" \"demos/**/*.ts\" \"test/**/*.ts\"",
"run-on-besu": "hardhat run --network besu",
"demos": "find demos -name '*.ts' -maxdepth 1 -print0 | xargs -0 -n 1 yarn run-on-besu",
Expand Down
2 changes: 1 addition & 1 deletion indy-besu/vdr/src/contracts/did/types/did_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct DidDocument {

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct DidMetadata {
pub creator_address: Address,
pub creator: Address,
pub created: u128,
pub updated: u128,
pub deactivated: bool,
Expand Down
11 changes: 7 additions & 4 deletions indy-besu/vdr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,9 @@ mod tests {
}

mod validator {
use crate::contracts::network::ValidatorAddresses;
use crate::signer::basic_signer::test::basic_signer;
use crate::{
contracts::network::ValidatorAddresses, signer::basic_signer::test::basic_signer,
};

use super::*;

Expand Down Expand Up @@ -495,7 +496,8 @@ mod tests {
let signer = basic_signer();
let (new_validator_address, _) = signer.create_account(None).unwrap();
let client = client(Some(signer));
role::build_and_submit_assign_role_transaction(&client, &ACCOUNT, &Role::Steward).await;
role::build_and_submit_assign_role_transaction(&client, &TRUSTEE_ACC, &Role::Steward)
.await;

let receipt =
build_and_submit_add_validator_transaction(&client, &new_validator_address).await;
Expand All @@ -522,7 +524,8 @@ mod tests {
let signer = basic_signer();
let (new_validator_address, _) = signer.create_account(None).unwrap();
let client = client(Some(signer));
role::build_and_submit_assign_role_transaction(&client, &ACCOUNT, &Role::Steward).await;
role::build_and_submit_assign_role_transaction(&client, &TRUSTEE_ACC, &Role::Steward)
.await;

ValidatorControl::add_validator(&client, &TRUSTEE_ACC, &new_validator_address)
.await
Expand Down
13 changes: 8 additions & 5 deletions indy-besu/vdr/src/migration/credential_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ impl CredentialDefinitionId {
vdr_error
})?;
let schema_id = parts.get(3).ok_or_else(|| {
let vdr_error = VdrError::CommonInvalidData("Invalid indy cred def schema id".to_string());
let vdr_error =
VdrError::CommonInvalidData("Invalid indy cred def schema id".to_string());

warn!(
"Error: {:?} during converting CredentialDefinitionId from indy format",
Expand All @@ -64,7 +65,8 @@ impl CredentialDefinitionId {

trace!(
"CredentialDefinitionId convert from Indy format: {} has finished. Result: {:?}",
id, cred_def_id
id,
cred_def_id
);

Ok(cred_def_id)
Expand All @@ -85,7 +87,8 @@ impl CredentialDefinition {

trace!(
"CredentialDefinition convert from Indy format: {} has finished. Result: {:?}",
credential_definition, besu_cred_def
credential_definition,
besu_cred_def
);

besu_cred_def
Expand All @@ -104,7 +107,7 @@ impl TryFrom<IndyCredentialDefinitionFormat> for CredentialDefinition {
let parts: Vec<&str> = cred_def.id.split(':').collect();
let id = parts.get(0).ok_or_else(|| {
let vdr_error = VdrError::CommonInvalidData("Invalid indy cred def id".to_string());

warn!("Error: {:?} during converting CredentialDefinition from IndyCredentialDefinitionFormat", vdr_error);

vdr_error
Expand Down Expand Up @@ -145,7 +148,7 @@ impl Into<IndyCredentialDefinitionFormat> for CredentialDefinition {
self
);

let indy_cred_def =IndyCredentialDefinitionFormat {
let indy_cred_def = IndyCredentialDefinitionFormat {
id: format!(
"{}:3:{}:{}:{}",
self.issuer_id.value(),
Expand Down

0 comments on commit 9fa68b8

Please sign in to comment.