Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Problem: (CRO-494) not possible to create unjail transaction in client-cli#556

Merged
bors[bot] merged 1 commit intocrypto-com:masterfrom
leejw51crypto:cro-494
Nov 7, 2019
Merged

Problem: (CRO-494) not possible to create unjail transaction in client-cli#556
bors[bot] merged 1 commit intocrypto-com:masterfrom
leejw51crypto:cro-494

Conversation

@leejw51
Copy link
Copy Markdown
Contributor

@leejw51 leejw51 commented Nov 5, 2019

Solution: call unjail in cli
increase coverage

fix sync

fix save public, private key

@leejw51crypto
Copy link
Copy Markdown
Collaborator

fixed viewkey

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 5, 2019

Codecov Report

Merging #556 into master will decrease coverage by 0.03%.
The diff coverage is 50%.

@@            Coverage Diff             @@
##           master     #556      +/-   ##
==========================================
- Coverage   67.58%   67.54%   -0.04%     
==========================================
  Files         124      124              
  Lines       14320    14332      +12     
==========================================
+ Hits         9678     9681       +3     
- Misses       4642     4651       +9
Impacted Files Coverage Δ
client-cli/src/main.rs 54.02% <ø> (ø) ⬆️
client-cli/src/command/transaction_command.rs 0% <0%> (ø) ⬆️
client-core/src/wallet/default_wallet_client.rs 59.76% <100%> (+0.63%) ⬆️
chain-core/src/tx/fee/mod.rs 87.68% <0%> (-0.5%) ⬇️

Copy link
Copy Markdown
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

looks ok, but can be simplified:

  1. feature guards in cli don't seem to help with testing cli-related functionality (as the actual functionality is skipped) -- it'd be preferable not to have them... a separate PR could improve testing of cli by replacing stdin/stdout in tests with custom streams

  2. HD wallet syncing is a different problem, so that fix should go to a different PR

//! CLI for interacting with Crypto.com Chain
mod command;

#[allow(unused_imports)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

prefer not to have this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok

Comment on lines +63 to +69
#[cfg(not(test))]
pub(crate) fn ask_passphrase(message: Option<&str>) -> Result<SecUtf8> {
ask(message.unwrap_or("Enter passphrase: "));
password()
.map(Into::into)
.chain(|| (ErrorKind::IoError, "Unable to read password"))
}

#[cfg(test)]
pub(crate) fn ask_passphrase(_message: Option<&str>) -> Result<SecUtf8> {
Ok(SecUtf8::from("123456"))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this helps with testing, as it'll skip the actual code to be tested and have a replacement -- most things in client are tested in isolation.
For cli testing, it's a bit tricky, but ideally it'd be done with passing in custom streams instead of using stdin/stdout

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you make entering value via stream as separate issue?
so we can unit-test for those functions.

.expect("get staked address"),
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again not sure if this helps much with testing -- left a more detailed comment below

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's for coverage failure.
i'll find other way

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

coverage is just for reference -- no need to "hack" it in this way; better to do proper tests

self.key_service
.add_keypair(&private_key, &public_key, passphrase)?;

self.wallet_service.create(name, passphrase, public_key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this appears to solve a different problem than stated in this PR -- I guess it's "Problem: syncing doesn't work with HD wallets", please open a separate PR for it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i'll make separate PR

name,
&TransactionType::Unjail,
)
.is_ok());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This formatting seems a bit odd to me.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you can use .is_err() for !xxx.is_ok()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Forget about the format, actually it is normal

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

because it's for coverage failure, i'll remove this for now.
will test via stream.

}

#[test]
fn check_unjail_tx() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps to give more details about this test to make the test more self-explanatory.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok

@leejw51crypto
Copy link
Copy Markdown
Collaborator

i'll fix

@leejw51crypto leejw51crypto force-pushed the cro-494 branch 2 times, most recently from 0ff5604 to 6c358dc Compare November 7, 2019 03:10
…t-cli

Solution: call unjail in cli
increase coverage


fix sync


fix save public, private key


remove un-necessary unit-test


restore wallet code


reformat
Copy link
Copy Markdown
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot added a commit that referenced this pull request Nov 7, 2019
556: Problem: (CRO-494) not possible to create unjail transaction in client-cli r=tomtau a=leejw51

Solution: call unjail in cli
increase coverage


fix sync


fix save public, private key



561: Problem: new drone pipeline not authorized r=tomtau a=tomtau

Solution: updated the signature

Co-authored-by: Jongwhan Lee <jonghwan@crypto.com>
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Nov 7, 2019

Build failed (retrying...)

@tomtau
Copy link
Copy Markdown
Contributor

tomtau commented Nov 7, 2019

bors r+

bors bot added a commit that referenced this pull request Nov 7, 2019
538: Problem:(CRO-521) unbonded from custom time is ignored in genesis initconfig r=tomtau a=linfeng-crypto

Solution: 
change the parameters of `new_init`: change `genesis_time` from `Timespec` into `Option<Timespec>`, remove the `bool` type parameter `bonded`, add a `&StakedStateDestination` type parameter.

556: Problem: (CRO-494) not possible to create unjail transaction in client-cli r=tomtau a=leejw51

Solution: call unjail in cli
increase coverage


fix sync


fix save public, private key



558: Problem: Inefficient binary encoding of Merkle tree path (CRO-149) r=tomtau a=yihuang

I've refactored the ``Path`` representation with ``Vec``, which makes it both more correct and more compact serialization (Old representation allows some illegal path state).
With the current implementation, the gain of further optimizing the serialization with ``BitVec`` is small, I guess it doesn't worth the trouble anymore.

Co-authored-by: linfeng <linfeng@crypto.com>
Co-authored-by: Jongwhan Lee <jonghwan@crypto.com>
Co-authored-by: yihuang <huang@crypto.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Nov 7, 2019

Canceled (will resume)

bors bot added a commit that referenced this pull request Nov 7, 2019
538: Problem:(CRO-521) unbonded from custom time is ignored in genesis initconfig r=tomtau a=linfeng-crypto

Solution: 
change the parameters of `new_init`: change `genesis_time` from `Timespec` into `Option<Timespec>`, remove the `bool` type parameter `bonded`, add a `&StakedStateDestination` type parameter.

556: Problem: (CRO-494) not possible to create unjail transaction in client-cli r=tomtau a=leejw51

Solution: call unjail in cli
increase coverage


fix sync


fix save public, private key



Co-authored-by: linfeng <linfeng@crypto.com>
Co-authored-by: Jongwhan Lee <jonghwan@crypto.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Nov 7, 2019

Build failed (retrying...)

bors bot added a commit that referenced this pull request Nov 7, 2019
556: Problem: (CRO-494) not possible to create unjail transaction in client-cli r=tomtau a=leejw51

Solution: call unjail in cli
increase coverage


fix sync


fix save public, private key



Co-authored-by: Jongwhan Lee <jonghwan@crypto.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Nov 7, 2019

@bors bors bot merged commit c639b64 into crypto-com:master Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants