Skip to content

Commit 5571d1a

Browse files
committed
fix: test data
Signed-off-by: bkioshn <[email protected]>
1 parent 7583aec commit 5571d1a

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

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

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(crate) fn validate_stake_public_key(
149149
Ok(addr) => addr,
150150
Err(e) => {
151151
validation_report.push(format!(
152-
"{function_name}, Failed to decode UTF-8 string for context-specific primitive type with raw tag 134: {e}",
152+
"{function_name}, Failed to decode UTF-8 string for context-specific primitive type with raw tag 134: {e}",
153153
),
154154
);
155155
return None;
@@ -454,10 +454,7 @@ pub(crate) fn validate_role_singing_key(
454454

455455
// If signing key exist, it should not contain public key
456456
if let Some(local_ref) = &role_data.role_signing_key {
457-
if local_ref
458-
.iter()
459-
.any(|k| k.local_ref == LocalRefInt::PubKeys)
460-
{
457+
if local_ref.local_ref == LocalRefInt::PubKeys {
461458
validation_report.push(format!(
462459
"{function_name}, Role signing key should reference certificate, not public key",
463460
));
@@ -521,12 +518,11 @@ mod tests {
521518
.expect("Failed to decode MultiEraBlock");
522519

523520
let transactions = multi_era_block.txs();
524-
// Forth transaction of this test data contains the CIP509 auxiliary data
521+
// Second transaction of this test data contains the CIP509 auxiliary data
525522
let tx = transactions
526-
.get(3)
523+
.get(1)
527524
.expect("Failed to get transaction index");
528525
let aux_data = cip_509_aux_data(tx);
529-
530526
let mut decoder = Decoder::new(aux_data.as_slice());
531527
let cip509 = Cip509::decode(&mut decoder, &mut ()).expect("Failed to decode Cip509");
532528
assert!(validate_txn_inputs_hash(&cip509, tx, &mut validation_report).unwrap());
@@ -540,15 +536,11 @@ mod tests {
540536
.expect("Failed to decode MultiEraBlock");
541537

542538
let transactions = multi_era_block.txs();
543-
// Forth transaction of this test data contains the CIP509 auxiliary data
539+
// Second transaction of this test data contains the CIP509 auxiliary data
544540
let tx = transactions
545-
.get(3)
541+
.get(1)
546542
.expect("Failed to get transaction index");
547543

548-
// let aux_data = cip_509_aux_data(tx);
549-
550-
// let mut decoder = Decoder::new(aux_data.as_slice());
551-
// let cip509 = Cip509::decode(&mut decoder, &mut ()).expect("Failed to decode Cip509");
552544
validate_aux(tx, &mut validation_report);
553545
assert!(validate_aux(tx, &mut validation_report).unwrap());
554546
}
@@ -561,29 +553,30 @@ mod tests {
561553
.expect("Failed to decode MultiEraBlock");
562554

563555
let transactions = multi_era_block.txs();
564-
// Forth transaction of this test data contains the CIP509 auxiliary data
556+
// Second transaction of this test data contains the CIP509 auxiliary data
565557
let tx = transactions
566-
.get(3)
558+
.get(1)
567559
.expect("Failed to get transaction index");
568560

569561
let aux_data = cip_509_aux_data(tx);
570562

571563
let mut decoder = Decoder::new(aux_data.as_slice());
572564
let cip509 = Cip509::decode(&mut decoder, &mut ()).expect("Failed to decode Cip509");
565+
validate_stake_public_key(&cip509, tx, 0, &mut validation_report);
573566
assert!(validate_stake_public_key(&cip509, tx, 0, &mut validation_report).unwrap());
574567
}
575568

576569
#[test]
577-
fn test_validate_payment_key_success_positive_ref() {
570+
fn test_validate_payment_key_success_negative_ref() {
578571
let mut validation_report = Vec::new();
579572
let conway_block_data = conway_1();
580573
let multi_era_block = pallas::ledger::traverse::MultiEraBlock::decode(&conway_block_data)
581574
.expect("Failed to decode MultiEraBlock");
582575

583576
let transactions = multi_era_block.txs();
584-
// Forth transaction of this test data contains the CIP509 auxiliary data
577+
// Second transaction of this test data contains the CIP509 auxiliary data
585578
let tx = transactions
586-
.get(3)
579+
.get(1)
587580
.expect("Failed to get transaction index");
588581

589582
let aux_data = cip_509_aux_data(tx);
@@ -594,14 +587,17 @@ mod tests {
594587
if let Some(role_set) = &cip509.x509_chunks.0.role_set {
595588
for role in role_set {
596589
if role.role_number == 0 {
597-
assert!(validate_payment_key(tx, 0, role, &mut validation_report,).unwrap());
590+
println!(
591+
"{:?}",
592+
validate_payment_key(tx, 0, role, &mut validation_report,)
593+
);
598594
}
599595
}
600596
}
601597
}
602598

603599
#[test]
604-
fn test_validate_payment_key_success_negative_ref() {
600+
fn test_validate_payment_key_success_positive_ref() {
605601
let mut validation_report = Vec::new();
606602
let conway_block_data = conway_3();
607603
let multi_era_block = pallas::ledger::traverse::MultiEraBlock::decode(&conway_block_data)
@@ -621,10 +617,7 @@ mod tests {
621617
if let Some(role_set) = &cip509.x509_chunks.0.role_set {
622618
for role in role_set {
623619
if role.role_number == 0 {
624-
println!(
625-
"{:?}",
626-
validate_payment_key(tx, 0, role, &mut validation_report,)
627-
);
620+
assert!(validate_payment_key(tx, 0, role, &mut validation_report,).unwrap());
628621
}
629622
}
630623
}
@@ -638,9 +631,9 @@ mod tests {
638631
.expect("Failed to decode MultiEraBlock");
639632

640633
let transactions = multi_era_block.txs();
641-
// Forth transaction of this test data contains the CIP509 auxiliary data
634+
// First transaction of this test data contains the CIP509 auxiliary data
642635
let tx = transactions
643-
.get(3)
636+
.first()
644637
.expect("Failed to get transaction index");
645638

646639
let aux_data = cip_509_aux_data(tx);

0 commit comments

Comments
 (0)