Skip to content

Commit

Permalink
chore: improve naming (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 committed Nov 16, 2023
1 parent bade1a8 commit a2e7057
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -18,7 +18,7 @@ type DepositArgs = record {
memo : opt vec nat8;
};
type DepositResult = record { balance : nat; txid : nat };
type DepositResult = record { balance : nat; block_index : nat };
deposit : (DepositArgs) -> (DepositResult);
```
Expand Down
2 changes: 1 addition & 1 deletion cycles-ledger/cycles-ledger.did
Expand Up @@ -27,7 +27,7 @@ type DepositArgs = record {
to : Account;
memo : opt vec nat8;
};
type DepositResult = record { balance : nat; txid : nat };
type DepositResult = record { balance : nat; block_index : BlockIndex };
type RejectionCode = variant {
NoError;
CanisterError;
Expand Down
2 changes: 1 addition & 1 deletion cycles-ledger/src/endpoints.rs
Expand Up @@ -50,7 +50,7 @@ pub struct DepositArg {

#[derive(CandidType, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct DepositResult {
pub txid: Nat,
pub block_index: Nat,
pub balance: Nat,
}

Expand Down
2 changes: 1 addition & 1 deletion cycles-ledger/src/storage.rs
Expand Up @@ -670,7 +670,7 @@ pub fn deposit(
prune(now);

Ok(DepositResult {
txid: Nat::from(block_index),
block_index: Nat::from(block_index),
balance: Nat::from(balance_of(&to)),
})
}
Expand Down
12 changes: 6 additions & 6 deletions cycles-ledger/tests/tests.rs
Expand Up @@ -158,7 +158,7 @@ fn test_deposit_flow() {

// Make the first deposit to the user and check the result.
let deposit_res = deposit(env, depositor_id, user, 1_000_000_000);
assert_eq!(deposit_res.txid, Nat::from(0));
assert_eq!(deposit_res.block_index, Nat::from(0));
assert_eq!(deposit_res.balance, Nat::from(1_000_000_000));

// Check that the right amount of tokens have been minted
Expand All @@ -169,7 +169,7 @@ fn test_deposit_flow() {

// Make another deposit to the user and check the result.
let deposit_res = deposit(env, depositor_id, user, 500_000_000);
assert_eq!(deposit_res.txid, Nat::from(1));
assert_eq!(deposit_res.block_index, Nat::from(1));
assert_eq!(deposit_res.balance, Nat::from(1_500_000_000));

// Check that the right amount of tokens have been minted
Expand Down Expand Up @@ -225,7 +225,7 @@ fn test_send_flow() {

// make deposits to the user and check the result
let deposit_res = deposit(env, depositor_id, user_main_account, 1_000_000_000);
assert_eq!(deposit_res.txid, 0);
assert_eq!(deposit_res.block_index, 0);
assert_eq!(deposit_res.balance, 1_000_000_000);
deposit(env, depositor_id, user_subaccount_1, 1_000_000_000);
deposit(env, depositor_id, user_subaccount_2, 1_000_000_000);
Expand Down Expand Up @@ -330,7 +330,7 @@ fn test_send_fails() {

// make the first deposit to the user and check the result
let deposit_res = deposit(env, depositor_id, user, 1_000_000_000_000);
assert_eq!(deposit_res.txid, Nat::from(0));
assert_eq!(deposit_res.block_index, Nat::from(0));
assert_eq!(deposit_res.balance, 1_000_000_000_000_u128);

// send more than available
Expand Down Expand Up @@ -1681,7 +1681,7 @@ fn test_icrc1_test_suite() {

// make the first deposit to the user and check the result
let deposit_res = deposit(&env, depositor_id, user, 1_000_000_000_000_000);
assert_eq!(deposit_res.txid, Nat::from(0));
assert_eq!(deposit_res.block_index, Nat::from(0));
assert_eq!(deposit_res.balance, 1_000_000_000_000_000_u128);
assert_eq!(1_000_000_000_000_000, balance_of(&env, ledger_id, user));

Expand Down Expand Up @@ -1713,7 +1713,7 @@ fn test_create_canister() {

// make the first deposit to the user and check the result
let deposit_res = deposit(&env, depositor_id, user, expected_balance);
assert_eq!(deposit_res.txid, Nat::from(0));
assert_eq!(deposit_res.block_index, Nat::from(0));
assert_eq!(deposit_res.balance, expected_balance);
assert_eq!(expected_balance, balance_of(&env, ledger_id, user));

Expand Down

0 comments on commit a2e7057

Please sign in to comment.