Skip to content

Conversation

@mojoX911
Copy link

Fixes #205

Adds other auxiliary changes as needed.

@mojoX911 mojoX911 mentioned this pull request Nov 24, 2024
@codecov
Copy link

codecov bot commented Nov 24, 2024

Codecov Report

Attention: Patch coverage is 7.14286% with 39 lines in your changes missing coverage. Please review.

Project coverage is 73.73%. Comparing base (4747c6f) to head (f4ca389).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/maker/rpc/server.rs 0.00% 19 Missing ⚠️
src/maker/rpc/messages.rs 0.00% 16 Missing ⚠️
src/bin/maker-cli.rs 0.00% 2 Missing ⚠️
src/maker/api.rs 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #311      +/-   ##
==========================================
- Coverage   78.26%   73.73%   -4.53%     
==========================================
  Files          32       33       +1     
  Lines        4840     4063     -777     
==========================================
- Hits         3788     2996     -792     
- Misses       1052     1067      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mojoX911 mojoX911 force-pushed the maker-cli branch 2 times, most recently from 70bcf0e to 4e0365f Compare December 5, 2024 11:30
refactor test_framework mod.rs to expose some common functions.

some other changes in maker to make things consistent.
Copy link

@KnowWhoami KnowWhoami left a comment

Choose a reason for hiding this comment

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

ACK
Here are some enhancements, nits, probable bugs , I have mentioned.
I have some ideas regarding better handling our threads in dns & maker-cli -> but I need some more time on that , so will mentioned about them in next round of review.

send_rpc_req(&RpcMsgReq::NewAddress)?;
}
Commands::Stop => {
send_rpc_req(&RpcMsgReq::Stop)?;

Choose a reason for hiding this comment

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

Improvements in send_rpc_req api:

  • It could take the ownership of the req instead of taking its reference -> as the passed RpcMsgReq variant is not used after calling this api.
  • We must not hardcode the rpc_port of makerd i.e 127.0.0.1:6103 otherwise the maker-cli cannot connect to makerd in case the maker changes its rpc_port.
    So IMO, create a new argument as maker_rpc_port with default set as 127.0.0.1:6103.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed..

Arc::new(
Maker::init(
Some(temp_dir.clone()),
Some(temp_dir.join(port.0.to_string()).clone()),

Choose a reason for hiding this comment

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

  • Cloning is not required.
Suggested change
Some(temp_dir.join(port.0.to_string()).clone()),
Some(temp_dir.join(port.0.to_string())),
  • Also Currently generate_blocks and send_to_address are methods of test_framework but now we have certain IT like cli-app tests which do not use TestFramework struct and thus they are not able to use these api's and have to write seperate api which are exactly same to these one.

So IMO, make these two api general purpose by modifying their function signature:

pub fn generate_blocks(&bitcoind, n: u64)

Similarly for send_to_address too.

Choose a reason for hiding this comment

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

Done...

};

fn get_random_tmp_dir() -> PathBuf {
pub fn get_random_tmp_dir() -> PathBuf {

Choose a reason for hiding this comment

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

We don't require this api becuase:

  • Can directly use temp_dir().join(".coinswap") to get the temp coinswap directory.
  • Here , a random alphanumeric chars are appended to get a unique temp coinswap directory which is not required as the contents of temp dir is removed if it already contains some data , thus ensuring that test often start with a empty temp dir.

/// Gets a new address
NewAddress,
// Send to an external wallet address.
// Send to an external address and returns the transaction hex.

Choose a reason for hiding this comment

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

cli nit:

Suggested change
// Send to an external address and returns the transaction hex.
/// Send to an external address and returns the transaction hex.

Otherwise this description will not appear while running the app.

Choose a reason for hiding this comment

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

Done..

/// Is setup complete
pub is_setup_complete: AtomicBool,
/// Path for the data directory.
pub data_dir: PathBuf,

Choose a reason for hiding this comment

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

What should we do?

Approach 1:

make this data_dir field as public and then we don't require to have get_data_dir api.

Approach 2:

make it private and have get_data_dir api.

I feel, 2nd approach will be better.
what's your opinion?

Copy link
Author

Choose a reason for hiding this comment

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

I forgot why I added the getter. If not required it can be removed. If we make this private all other fields should be private too. That is the right approach. But can be done later. Not a big need.

Choose a reason for hiding this comment

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

Ok, will take care of it in future.

min_size: 10_000,
socks_port: 19050,
directory_server_address: "directoryhiddenserviceaddress.onion:8080".to_string(),
directory_server_address: "127.0.0.1:8080".to_string(),

Choose a reason for hiding this comment

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

any reason for this change?

Copy link
Author

Choose a reason for hiding this comment

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

because clearnet connection won't work without setting the maker config DNS address. At least this will make default config work for local clearnet. For tor default value doesn't make sense anyway.

Comment on lines -39 to +42
GetDataDirResp(String),
GetDataDirResp(PathBuf),

Choose a reason for hiding this comment

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

Any reason changing the type to PathBuf ?
I don't see any extra benefits on using PathBuf.

Copy link
Author

Choose a reason for hiding this comment

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

yeah doesn't matter. could be string as well. I would still like PathBuf as it tells its a path info, not any random string.

#[clap(long, short = 'n', default_value = "clearnet", possible_values = &["tor", "clearnet"])]
#[clap(long, short = 'n', default_value = "tor", possible_values = &["tor", "clearnet"])]
network: String,
/// Optional DNS data directory. Default value : "~/.coinswap/directory"

Choose a reason for hiding this comment

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

change default directory from ~/.coinswap/directory to ~/.coinswap/dns.
as we always create default dir as ~/.coinswap/dns.

Choose a reason for hiding this comment

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

Done..

Copy link
Author

Choose a reason for hiding this comment

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

Ack..

Comment on lines +270 to +272
assert_eq!(seed_balance, "1000000 sats");
assert_eq!(swap_balance, "0 sats");
assert_eq!(fidelity_balance, "5000000 sats");

Choose a reason for hiding this comment

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

Inside the start_makerd api -> we fund the maker wallet with 0.1 BTC -> then we spent 0.05 BTC for Fidelity Bonds + 1000 sats for miner fees -> then how we can get the seed-balance equals to the amount we fund the wallet.
I guess, there is some syncing problem.

Choose a reason for hiding this comment

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

solved.

Copy link
Author

Choose a reason for hiding this comment

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

yes.. that should not happen.. worth looking into it..

Comment on lines +100 to +104
// TODO: Test Coverage
Commands::GetTorAddress => {
send_rpc_req(&RpcMsgReq::GetTorAddress)?;
}
// TODO: Test Coverage

Choose a reason for hiding this comment

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

It's been covered in maker-cli test -> can remove them.

Choose a reason for hiding this comment

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

Done..

@KnowWhoami KnowWhoami mentioned this pull request Dec 19, 2024
@KnowWhoami
Copy link

Closing this pr as we now have #326 to extend it's work.

@KnowWhoami KnowWhoami closed this Dec 19, 2024
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.

Implement Integration Test for Maker's RPC

2 participants