Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json output to test CLI command output #1164

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading