Skip to content

Commit

Permalink
change(fc-pallet-pass): add test to assert non-trivial `verify_creden…
Browse files Browse the repository at this point in the history
…tial` case
  • Loading branch information
pandres95 committed Oct 13, 2024
1 parent f588a50 commit 7ea6ae7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pallets/pass/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,44 @@ mod authenticate {
);
});
}

#[test]
fn verify_credential_works() {
new_test_ext().execute_with(|| {
assert_ok!(Balances::mint_into(&SIGNER, 2));

assert_ok!(Pass::register(
RuntimeOrigin::signed(SIGNER),
AccountNameA::get(),
PassDeviceAttestation::AuthenticatorB(authenticator_b::DeviceAttestation {
device_id: THE_DEVICE,
challenge: AuthenticatorB::generate(&THE_DEVICE),
}),
));

assert_ok!(Pass::authenticate(
RuntimeOrigin::signed(SIGNER),
THE_DEVICE,
PassCredential::AuthenticatorB(
authenticator_b::Credential::new(
AccountNameA::get(),
AuthenticatorB::generate(&AccountNameA::get())
)
.sign(&THE_DEVICE)
),
Some(DURATION),
));

let block_number = System::block_number();
System::assert_has_event(
Event::<Test>::SessionCreated {
session_key: SIGNER,
until: block_number + DURATION,
}
.into(),
);
});
}
}

mod add_device {
Expand Down

0 comments on commit 7ea6ae7

Please sign in to comment.