Skip to content

Commit 9c56ed5

Browse files
authored
test(rust/rbac-registration): Fix test data + undefined bug (#168)
* test(rbac-registration): fix test and test data Signed-off-by: bkioshn <[email protected]> * fix(rbac-registration): name txn_index Signed-off-by: bkioshn <[email protected]> * fix(rbac-registration): add more test to registration chain Signed-off-by: bkioshn <[email protected]> * test(rbac-registration): fix conway4 block Signed-off-by: bkioshn <[email protected]> * test(rbac-registration): fix conway4 block Signed-off-by: bkioshn <[email protected]> * fix(rbac-registration): consume undefined cbor Signed-off-by: bkioshn <[email protected]> * fix(rbac-registration): format Signed-off-by: bkioshn <[email protected]> --------- Signed-off-by: bkioshn <[email protected]>
1 parent d5e9e27 commit 9c56ed5

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

rust/rbac-registration/src/cardano/cip509/rbac/certs/c509.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ impl Decode<'_, ProblemReport> for C509Cert {
5353
&mut (),
5454
)?)))
5555
},
56-
minicbor::data::Type::Undefined => Ok(Self::Undefined),
56+
minicbor::data::Type::Undefined => {
57+
d.undefined()?;
58+
Ok(Self::Undefined)
59+
},
5760
_ => Err(decode::Error::message("Invalid datatype for C509Cert")),
5861
}
5962
}

rust/rbac-registration/src/cardano/cip509/rbac/certs/x509.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ impl Decode<'_, ProblemReport> for X509DerCert {
3030
_ => Err(decode::Error::message("Unknown tag for X509DerCert")),
3131
}
3232
},
33-
minicbor::data::Type::Undefined => Ok(Self::Undefined),
33+
minicbor::data::Type::Undefined => {
34+
d.undefined()?;
35+
Ok(Self::Undefined)
36+
},
3437
minicbor::data::Type::Bytes => {
3538
let data = decode_bytes(d, "X509DerCert")?;
3639
let certificate = Certificate::from_der(&data).map_err(|e| {

rust/rbac-registration/src/cardano/cip509/rbac/pub_key.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ impl Decode<'_, ProblemReport> for SimplePublicKeyType {
4545
_ => Err(decode::Error::message("Unknown tag for Self")),
4646
}
4747
},
48-
minicbor::data::Type::Undefined => Ok(Self::Undefined),
48+
minicbor::data::Type::Undefined => {
49+
d.undefined()?;
50+
Ok(Self::Undefined)
51+
},
4952
_ => {
5053
Err(decode::Error::message(
5154
"Invalid datatype for SimplePublicKeyType",

rust/rbac-registration/src/test_data/cardano/conway_4.block

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

rust/rbac-registration/src/utils/test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ pub fn block_3() -> BlockTestData {
141141
}
142142
}
143143

144-
/// Returns the decoded `conway_4.block` block that contains 6 transactions.
145-
/// Slot number: `81_754_705`, Block number: `3_108_476`
146-
/// Tx hash: 0x8149d5cb43d2f57224adb3b916fad1d6a5944eef151baafe43272b3bfb2efe59
144+
/// Returns the decoded `conway_4.block` block that contains 10 transactions.
145+
/// Slot number: `81_845_364`, Block number: `3_112_041`
146+
/// Tx hash: 0x98cf12dc6187626de50b5562ebf1753f1b39e1e568e99d83bfdcfb1713c8f4a4
147147
///
148148
/// CIP509 details (valid data, signing key ref to x509 cert index 1):
149149
/// Role: 4
@@ -155,10 +155,10 @@ pub fn block_4() -> BlockTestData {
155155
let data = hex::decode(include_str!("../test_data/cardano/conway_4.block")).unwrap();
156156
BlockTestData {
157157
block: block(data),
158-
slot: 81_754_705.into(),
158+
slot: 81_845_364.into(),
159159
role: 4.into(),
160160
txn_index: 1.into(),
161-
txn_hash: "8149d5cb43d2f57224adb3b916fad1d6a5944eef151baafe43272b3bfb2efe59"
161+
txn_hash: "98cf12dc6187626de50b5562ebf1753f1b39e1e568e99d83bfdcfb1713c8f4a4"
162162
.parse()
163163
.unwrap(),
164164
prv_hash: Some(block_1().txn_hash),

0 commit comments

Comments
 (0)