Skip to content

Commit

Permalink
Add json output to test CLI command output (#1164)
Browse files Browse the repository at this point in the history
* Add json output

* Fix empty responses

* Small fixes to test-cli

* Only display Failed message is json option is false

* Explose clap Parser trait

* Dont expose Parser trait

* Small fix to displaying verifying key
  • Loading branch information
ameba23 authored Nov 14, 2024
1 parent 6e556fd commit 9e76bc6
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 100 deletions.
38 changes: 20 additions & 18 deletions Cargo.lock

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

15 changes: 14 additions & 1 deletion crates/protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::{

use blake2::{Blake2s256, Digest};
use errors::{ProtocolExecutionErr, VerifyingKeyError};
use serde::{Deserialize, Serialize};
use serde::{ser::SerializeStruct, Deserialize, Serialize, Serializer};
use sp_core::{sr25519, Pair};
use subxt::utils::AccountId32;
use synedrion::{
Expand Down Expand Up @@ -148,6 +148,19 @@ pub struct RecoverableSignature {
pub recovery_id: RecoveryId,
}

// This cannot be derived because [RecoveryId] does not implement Serialize
impl Serialize for RecoverableSignature {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("RecoverableSignature", 2)?;
state.serialize_field("signature", &self.signature)?;
state.serialize_field("recovery_id", &self.recovery_id.to_byte())?;
state.end()
}
}

impl RecoverableSignature {
pub fn to_rsv_bytes(&self) -> [u8; 65] {
let mut res = [0u8; 65];
Expand Down
2 changes: 2 additions & 0 deletions crates/test-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ bincode ="1.3.3"
x25519-dalek ="2.0.1"
sp-runtime ={ version="32.0.0", default-features=false }
entropy-shared={ version="0.3.0", path="../shared" }
serde_json ="1.0.132"
serde ={ version="1.0.215", features=["derive"] }
Loading

0 comments on commit 9e76bc6

Please sign in to comment.