Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor wallet issues #220

Merged
merged 21 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6d63e8a
ignore vscode ide/settings
zees-dev Oct 29, 2024
657cf84
added rust toolchain
zees-dev Oct 29, 2024
3fa1b27
fix new_at_index not printing checksum address
zees-dev Oct 29, 2024
35e29d0
wallet existance also checks content; handles the case if it's not a …
zees-dev Oct 29, 2024
9792e74
removed redundant helper functions; replaced with tempfile dep instead
zees-dev Oct 29, 2024
46bfbac
updated create_wallet test helper func to take optional file content
zees-dev Oct 29, 2024
11e0b50
existing unit tests refactored to remove nesting
zees-dev Oct 29, 2024
8fadf3a
new unit tests for ensure_no_wallet_exists
zees-dev Oct 29, 2024
9632374
updated CI toolchain to match rust-toolchain.toml
zees-dev Oct 29, 2024
ab3e98d
github actions checkoutv4 and nodev4
zees-dev Oct 29, 2024
6e6af2e
ci update to use semver rust version
zees-dev Oct 29, 2024
8f9c6d0
fixed CI nightly version for code cov
zees-dev Oct 29, 2024
eaf5301
reverting CI and toolchain to use original nightly version
zees-dev Oct 29, 2024
78511f8
fixed cargo clippy errors
zees-dev Oct 29, 2024
762405c
Revert "reverting CI and toolchain to use original nightly version"
zees-dev Oct 29, 2024
3ac5970
ci: install nightly version for code-cov
kayagokalp Oct 29, 2024
6b82bc4
updated rust toolchain to stable 1.82.0; nightly to nightly-2024-10-2…
zees-dev Oct 29, 2024
0306d83
create_wallet added description
zees-dev Oct 29, 2024
515cb7a
Merge branch 'master' into fix/minor-wallet-issues
zees-dev Oct 29, 2024
f8124e8
create_wallet updated param name; content -> data; updated description
zees-dev Oct 29, 2024
9abc8ad
create_wallet -> serialize_wallet_to_file; using an enum with variant…
zees-dev Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io
RUST_VERSION: 1.80.0
NIGHTLY_RUST_VERSION: nightly-2024-07-21
RUST_VERSION: 1.82.0
NIGHTLY_RUST_VERSION: nightly-2024-10-28

jobs:
cancel-previous-runs:
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
profile = "default" # include rustfmt, clippy
channel = "1.80.0"
channel = "1.82.0"
3 changes: 3 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ mod tests {
fs::remove_file(wallet_path).unwrap();
}
}

/// Create a wallet file with optional wallet content.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I meant, what is content? I can see that it's optional, but I don't understand what content is made up of.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content could be anything, just populates file with data. Doesn't have to be specific format.
P.s. Feel free to suggest a description (or improvement)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like:

/// Represents the possible serialized states of a wallet.
/// Used primarily for simulating wallet creation and serialization processes.
enum WalletSerializedState {
    Empty,
    WithData(String),
}

/// Simulates the serialization of a wallet to a file, optionally including dummy data.
/// Primarily used to test if checks for wallet file existence are functioning correctly.
fn serialize_wallet_to_file(wallet_path: &Path, state: WalletSerializedState) {
    // Create the wallet file if it does not exist.
    if !wallet_path.exists() {
        fs::File::create(wallet_path).unwrap();
    }

    // Write content to the wallet file based on the specified state.
    if let WalletSerializedState::WithData(data) = state {
        fs::write(wallet_path, data).unwrap();
    }
}

Leaving this as a suggestion only maybe Josh has something else in mind

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks; updated: #220

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kaya, that's perfect.

/// Creates empty wallet file if content is None.
fn create_wallet(wallet_path: &Path, content: Option<&str>) {
zees-dev marked this conversation as resolved.
Show resolved Hide resolved
if !wallet_path.exists() {
fs::File::create(wallet_path).unwrap();
Expand Down
Loading