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

Improve stakeNeuron test coverage #743

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Improve stakeNeuron test coverage #743

merged 1 commit into from
Oct 30, 2024

Conversation

dskloetd
Copy link
Collaborator

Motivation

I want to refactor the memo to neuron (sub)account calculation to make it available to clients.
But currently the calculated account identifier is not tested.
So before I start changing that code I want to make sure it's tested.

Changes

  1. Mock the randomly generated memo.
  2. Expect specific values in the calls to transfer and manage_neuron.

Tests

PR is test-only. Tests pass.

Todos

  • Add entry to changelog (if necessary).
    not necessary

@dskloetd dskloetd marked this pull request as ready for review October 30, 2024 09:50
@dskloetd dskloetd requested review from a team as code owners October 30, 2024 09:50
@dskloetd dskloetd enabled auto-merge (squash) October 30, 2024 09:51
Copy link
Contributor

size-limit report 📦

Path Size
@dfinity/ckbtc 8.02 KB (0%)
@dfinity/cketh 3.57 KB (0%)
@dfinity/cmc 1.4 KB (0%)
@dfinity/ledger-icrc 4.17 KB (0%)
@dfinity/ledger-icp 15.43 KB (0%)
@dfinity/nns 36.27 KB (0%)
@dfinity/nns-proto 140.98 KB (0%)
@dfinity/sns 16.19 KB (0%)
@dfinity/utils 4.64 KB (0%)
@dfinity/ic-management 3.01 KB (0%)

@dskloetd dskloetd merged commit ed81d22 into main Oct 30, 2024
11 checks passed
@dskloetd dskloetd deleted the kloet/memo-test branch October 30, 2024 10:01
dskloetd added a commit that referenced this pull request Nov 1, 2024
# Motivation

We want to be able to claim a neuron from NNS dapp if the stake process
was interrupted after the transfer but before the claim.
For this we need to be able to calculate the neuron account identifier
to confirm that a transaction was made for the purpose of staking.
So we would like to reuse the code that calculates the account
identifier of the neuron from a memo.

# Changes

Extract the code to calculate a neuron account identifier from
`packages/nns/src/governance.canister.ts` and export it from
`packages/nns/src/utils/neurons.utils.ts`.

# Tests

1. Added some "change detector" unit tests.
2. The original code is covered by test coverage added in
#743

# Todos

- [x] Add entry to changelog (if necessary).

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants