Skip to content

Commit

Permalink
final minor nits PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Dec 24, 2019
1 parent ce92b8c commit 95137e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions go/registry/api/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ func (rtg *RuntimeGenesis) SanityCheck(isGenesis bool) error {
}
for _, sr := range rtg.StorageReceipts {
if !sr.PublicKey.IsValid() {
return fmt.Errorf("runtimegenesis: sanity check failed: when State is empty either all StorageReceipts must be valid or StateRoot must be empty. (public_key %s)", sr.PublicKey)
return fmt.Errorf("runtimegenesis: sanity check failed: when State is empty either all StorageReceipts must be valid or StateRoot must be empty (public_key %s)", sr.PublicKey)
}

// TODO: Even if Verify below succeeds, runtime registration should still be rejected until oasis-core#1686 is solved!
if !sr.Verify(storage.ReceiptSignatureContext, rtg.StateRoot[:]) {
return fmt.Errorf("runtimegenesis: sanity check failed: StorageReceipt verification on StateRoot failed. (public_key %s)", sr.PublicKey)
return fmt.Errorf("runtimegenesis: sanity check failed: StorageReceipt verification on StateRoot failed (public_key %s)", sr.PublicKey)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion go/roothash/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func SanityCheckBlocks(blocks map[signature.PublicKey]*block.Block) error {
}

// SanityCheck does basic sanity checking on the genesis state.
// isGenesis is true, if it is called during the Tendermint's InitChain.
func (g *Genesis) SanityCheck() error {
// Check blocks.
for _, rtg := range g.RuntimeStates {
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/common/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ macro_rules! impl_bytes {
where
E: ::serde::de::Error,
{
if data.len()!=$size {
if data.len() != $size {
return Err(::serde::de::Error::invalid_length(data.len(), &self));
}
let mut array = [0; $size];
Expand Down Expand Up @@ -246,14 +246,14 @@ mod tests {
"\"xnK40e9W7Sirh8NiLFEUBpvdOte4+XN0mNDAHs7wlno=\""
);

// Deserialize
// Deserialize.
let new_test_key: TestKey = serde_json::from_str(&test_key_str).unwrap();
assert_eq!(new_test_key, test_key);
}

#[test]
fn test_serde_cbor() {
// Serialize
// Serialize.
impl_bytes!(TestKey, 32, "test key");

let test_key = TestKey(TEST_KEY_BYTES);
Expand All @@ -264,7 +264,7 @@ mod tests {
expected_test_key_vec.extend_from_slice(&TEST_KEY_BYTES);
assert_eq!(test_key_vec, expected_test_key_vec);

// Deserialize
// Deserialize.
let new_test_key: TestKey = serde_cbor::from_slice(&test_key_vec).unwrap();
assert_eq!(new_test_key, test_key);
}
Expand Down

0 comments on commit 95137e2

Please sign in to comment.