Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX committed Nov 29, 2024
1 parent e49f2d1 commit 146fd13
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ debug = true

[workspace.dependencies]
thiserror = "2.0.3"
sargon = { git = "https://github.com/radixdlt/sargon", branch = "main" }
sargon = { git = "https://github.com/radixdlt/sargon", tag = "1.1.70" }
4 changes: 2 additions & 2 deletions crates/rules-uniffi/src/unneeded_when_moved_to_sargon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rules::SampleValues;
pub enum FactorSourceKind {
Device,
LedgerHQHardwareWallet,
Passphrase,
Password,
OffDeviceMnemonic,
TrustedContact,
SecurityQuestions,
Expand All @@ -20,7 +20,7 @@ impl From<FactorSourceKind> for sargon::FactorSourceKind {
FactorSourceKind::LedgerHQHardwareWallet => {
sargon::FactorSourceKind::LedgerHQHardwareWallet
}
FactorSourceKind::Passphrase => sargon::FactorSourceKind::Passphrase,
FactorSourceKind::Password => sargon::FactorSourceKind::Password,
FactorSourceKind::OffDeviceMnemonic => sargon::FactorSourceKind::OffDeviceMnemonic,
FactorSourceKind::TrustedContact => sargon::FactorSourceKind::TrustedContact,
FactorSourceKind::SecurityQuestions => sargon::FactorSourceKind::SecurityQuestions,
Expand Down
2 changes: 1 addition & 1 deletion crates/rules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod security_structure_of_factors;

pub mod prelude {
pub(crate) use sargon::{
BIP39Passphrase, BaseIsFactorSource, CommonError, DerivationPreset, DisplayName,
BIP39Passphrase, BaseBaseIsFactorSource, CommonError, DerivationPreset, DisplayName,
FactorInstance, FactorInstances, FactorSource, FactorSourceID, FactorSourceIDFromHash,
FactorSourceKind, FactorSources, HasRoleKindObjectSafe, HasSampleValues,
HierarchicalDeterministicFactorInstance, Identifiable, IndexMap, IndexSet,
Expand Down
12 changes: 6 additions & 6 deletions crates/rules/src/matrices/builder/matrix_builder_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ mod validation_of_addition_of_kind {
test(FactorSourceKind::LedgerHQHardwareWallet, true);
test(FactorSourceKind::ArculusCard, true);
test(FactorSourceKind::SecurityQuestions, false);
test(FactorSourceKind::Passphrase, false);
test(FactorSourceKind::Password, false);
test(FactorSourceKind::OffDeviceMnemonic, true);
test(FactorSourceKind::TrustedContact, true);
}
Expand All @@ -813,7 +813,7 @@ mod validation_of_addition_of_kind {
test(FactorSourceKind::LedgerHQHardwareWallet, true);
test(FactorSourceKind::ArculusCard, true);
test(FactorSourceKind::SecurityQuestions, false);
test(FactorSourceKind::Passphrase, false);
test(FactorSourceKind::Password, false);
test(FactorSourceKind::OffDeviceMnemonic, true);
test(FactorSourceKind::TrustedContact, true);
}
Expand All @@ -835,7 +835,7 @@ mod validation_of_addition_of_kind {
test(FactorSourceKind::LedgerHQHardwareWallet, true);
test(FactorSourceKind::ArculusCard, true);
test(FactorSourceKind::SecurityQuestions, true);
test(FactorSourceKind::Passphrase, true);
test(FactorSourceKind::Password, true);
test(FactorSourceKind::OffDeviceMnemonic, true);
test(FactorSourceKind::TrustedContact, false);
}
Expand All @@ -856,7 +856,7 @@ mod validation_of_addition_of_kind {
test(FactorSourceKind::LedgerHQHardwareWallet, true);
test(FactorSourceKind::ArculusCard, true);
test(FactorSourceKind::SecurityQuestions, true);
test(FactorSourceKind::Passphrase, true);
test(FactorSourceKind::Password, true);
test(FactorSourceKind::OffDeviceMnemonic, true);
test(FactorSourceKind::TrustedContact, false);
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ mod validation_of_addition_of_kind {

// ASSERT
let res = sut.validation_for_addition_of_factor_source_of_kind_to_primary_threshold(
FactorSourceKind::Passphrase,
FactorSourceKind::Password,
);
assert!(res.is_err());
}
Expand All @@ -1103,7 +1103,7 @@ mod validation_of_addition_of_kind {

// ASSERT
let res = sut.validation_for_addition_of_factor_source_of_kind_to_primary_threshold(
FactorSourceKind::Passphrase,
FactorSourceKind::Password,
);
assert!(res.is_ok());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rules/src/matrices/matrix_of_factor_instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ mod tests {
"factorSourceID": {
"discriminator": "fromHash",
"fromHash": {
"kind": "passphrase",
"kind": "password",
"body": "181ab662e19fac3ad9f08d5c673b286d4a5ed9cd3762356dc9831dc42427c1b9"
}
},
Expand Down
5 changes: 3 additions & 2 deletions crates/rules/src/matrices/matrix_of_factor_source_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,11 @@ mod tests {
#[test]
fn assert_json_sample() {
let sut = SUT::sample();

assert_eq_after_json_roundtrip(
&sut,
r#"
{
{
"primaryRole": {
"threshold": 2,
"thresholdFactors": [
Expand Down Expand Up @@ -665,7 +666,7 @@ mod tests {
{
"discriminator": "fromHash",
"fromHash": {
"kind": "passphrase",
"kind": "password",
"body": "181ab662e19fac3ad9f08d5c673b286d4a5ed9cd3762356dc9831dc42427c1b9"
}
}
Expand Down
33 changes: 16 additions & 17 deletions crates/rules/src/move_to_sargon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ impl SampleValues for FactorSourceID {
FactorSourceIDFromHash::sample_arculus_other().into()
}

/// Matt calls `passphrase` "password"
fn sample_password() -> Self {
FactorSourceIDFromHash::sample_passphrase().into()
FactorSourceIDFromHash::sample_password().into()
}
/// Matt calls `passphrase` "password"

fn sample_password_other() -> Self {
FactorSourceIDFromHash::sample_passphrase_other().into()
FactorSourceIDFromHash::sample_password_other().into()
}

/// Matt calls `off_device_mnemonic` "passphrase"
Expand Down Expand Up @@ -289,9 +288,9 @@ pub trait MnemonicWithPassphraseSamples: Sized {

fn sample_security_questions_other() -> Self;

fn sample_passphrase() -> Self;
fn sample_password() -> Self;

fn sample_passphrase_other() -> Self;
fn sample_password_other() -> Self;

fn all_samples() -> Vec<Self> {
vec![
Expand All @@ -307,8 +306,8 @@ pub trait MnemonicWithPassphraseSamples: Sized {
Self::sample_arculus_other(),
Self::sample_security_questions(),
Self::sample_security_questions_other(),
Self::sample_passphrase(),
Self::sample_passphrase_other(),
Self::sample_password(),
Self::sample_password_other(),
]
}

Expand Down Expand Up @@ -397,12 +396,12 @@ pub(crate) static MNEMONIC_BY_ID_MAP: Lazy<
MnemonicWithPassphrase::sample_arculus_other(),
),
(
FactorSourceIDFromHash::sample_passphrase(),
MnemonicWithPassphrase::sample_passphrase(),
FactorSourceIDFromHash::sample_password(),
MnemonicWithPassphrase::sample_password(),
),
(
FactorSourceIDFromHash::sample_passphrase_other(),
MnemonicWithPassphrase::sample_passphrase_other(),
FactorSourceIDFromHash::sample_off_device(),
MnemonicWithPassphrase::sample_off_device_other(),
),
(
FactorSourceIDFromHash::sample_off_device(),
Expand Down Expand Up @@ -515,14 +514,14 @@ impl MnemonicWithPassphraseSamples for MnemonicWithPassphrase {
)
}

fn sample_passphrase() -> Self {
Self::with_passphrase(Mnemonic::sample_passphrase(), BIP39Passphrase::default())
fn sample_password() -> Self {
Self::with_passphrase(Mnemonic::sample_password(), BIP39Passphrase::default())
}

fn sample_passphrase_other() -> Self {
fn sample_password_other() -> Self {
Self::with_passphrase(
Mnemonic::sample_security_questions_other(),
BIP39Passphrase::new("Pass phrase"),
Mnemonic::sample_password_other(),
BIP39Passphrase::default(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn validation_for_addition_of_factor_source_of_kind_to_list() {
ok(LedgerHQHardwareWallet);
ok(ArculusCard);
ok(SecurityQuestions);
ok(Passphrase);
ok(Password);
ok(OffDeviceMnemonic);
not_ok(TrustedContact);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ mod password {
sut.add_factor_source_to_threshold(FactorSourceID::sample_ledger())
.unwrap();
});
ok_with(Passphrase, |sut| {
ok_with(Password, |sut| {
sut.add_factor_source_to_threshold(FactorSourceID::sample_device())
.unwrap();
_ = sut.set_threshold(2);
Expand Down Expand Up @@ -550,7 +550,7 @@ mod password {
.unwrap();
});

not_ok(Passphrase);
not_ok(Password);

not_ok(SecurityQuestions);
not_ok(TrustedContact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn validation_for_addition_of_factor_source_of_kind_to_list() {
ok(TrustedContact);
ok(OffDeviceMnemonic);

not_ok(Passphrase);
not_ok(Password);
not_ok(SecurityQuestions);
}

Expand Down
8 changes: 4 additions & 4 deletions crates/rules/src/roles/builder/roles_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ impl<const R: u8> RoleBuilder<R> {
factor_list_kind: FactorListKind,
) -> RoleBuilderMutateResult {
match factor_source_kind {
FactorSourceKind::Passphrase => {
FactorSourceKind::Password => {
return self.validation_for_addition_of_password_to_primary(factor_list_kind)
}
FactorSourceKind::SecurityQuestions => {
Expand Down Expand Up @@ -579,7 +579,7 @@ impl<const R: u8> RoleBuilder<R> {
FactorSourceKind::Device
| FactorSourceKind::LedgerHQHardwareWallet
| FactorSourceKind::ArculusCard
| FactorSourceKind::Passphrase
| FactorSourceKind::Password
| FactorSourceKind::OffDeviceMnemonic
| FactorSourceKind::SecurityQuestions => Ok(()),
FactorSourceKind::TrustedContact => {
Expand All @@ -603,7 +603,7 @@ impl<const R: u8> RoleBuilder<R> {
FactorSourceKind::SecurityQuestions => {
RoleBuilderMutateResult::forever_invalid(RecoveryRoleSecurityQuestionsNotSupported)
}
FactorSourceKind::Passphrase => {
FactorSourceKind::Password => {
RoleBuilderMutateResult::forever_invalid(RecoveryRolePasswordNotSupported)
}
}
Expand All @@ -619,7 +619,7 @@ impl<const R: u8> RoleBuilder<R> {
factor_list_kind: FactorListKind,
) -> RoleBuilderMutateResult {
assert_eq!(self.role(), RoleKind::Primary);
let factor_source_kind = FactorSourceKind::Passphrase;
let factor_source_kind = FactorSourceKind::Password;
match factor_list_kind {
Threshold => {

Check warning on line 624 in crates/rules/src/roles/builder/roles_builder.rs

View check run for this annotation

Codecov / codecov/patch

crates/rules/src/roles/builder/roles_builder.rs#L624

Added line #L624 was not covered by tests
let is_alone = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
{
"discriminator": "fromHash",
"fromHash": {
"kind": "passphrase",
"kind": "password",
"body": "181ab662e19fac3ad9f08d5c673b286d4a5ed9cd3762356dc9831dc42427c1b9"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod tests {
{
"discriminator": "fromHash",
"fromHash": {
"kind": "passphrase",
"kind": "password",
"body": "181ab662e19fac3ad9f08d5c673b286d4a5ed9cd3762356dc9831dc42427c1b9"
}
}
Expand Down

0 comments on commit 146fd13

Please sign in to comment.