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 integration tests, fix bugs in rita #34

Merged
merged 40 commits into from
Feb 8, 2018

Conversation

kingoflolz
Copy link
Contributor

(this PR is a superset of #30)

jtremback and others added 30 commits January 24, 2018 22:59
This commit prevents `rita.sh` from doing everything as root by calling
sudo where the actual privilege is needed. Also, it makes the script
fetch network-lab by itself as needed

rita.sh:
* stop requiring root and start using sudo for the operations that
actually need it
* automatically download network-lab and change its path to
"./network-lab/"
* stop running "make install" for Babel

.gitignore:
* update test dependency location
# Conflicts:
#	integration-tests/rita.sh
#	rita/src/main.rs
Copy link
Member

@jkilpatr jkilpatr left a comment

Choose a reason for hiding this comment

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

Looks good, getting way too big though @drozdziak1 @kingoflolz Rita dev priority #0 is getting this rebased and merged. No more dev on side branches until that. Otherwise this is just going to get worse and harder to review. Ping me when it's ready please and I'll take care of it.

Copy link
Contributor

@drozdziak1 drozdziak1 left a comment

Choose a reason for hiding this comment

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

I don't like the fact that this PR introduces a ton of code with very little documentation. IMHO the sooner we focus on documentation and a thorough refactor the better

./rita-deps.sh
sudo python3 rita.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were the test dependencies exported to another file? Can't see a purpose for standalone test-specific provisioning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I'll move it back

@@ -58,6 +67,13 @@ impl fmt::Display for Uint256 {
}
}

impl fmt::Debug for Uint256 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Uint256 {}", self.to_string())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just format it as 33429348759238759u256?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be good. I would personally prefer Uint256(3402342), but that's a matter of taste

Copy link
Contributor Author

Choose a reason for hiding this comment

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

went with Uint256(3402342) as I think its a bit more "rusty"

@@ -162,6 +196,12 @@ impl fmt::Display for Int256 {
}
}

impl fmt::Debug for Int256 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Int256 {}", self.to_string())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just format as e.g. "239487234987i256"?

impl Div for Int256 {
type Output = Int256;
fn div(self, v: Int256) -> Int256 {
let num = self.0 / v.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the zero-division-related panic happen somewhere else? I don't mean the CheckedDiv trait, if we fail to panic on division by zero, the system will probably send us SIGFPE and I'm not sure that the Rust runtime can handle it and panic on it own - this might make debugging more time-consuming as there's a chance of the user not getting a backtrace

Copy link
Contributor

Choose a reason for hiding this comment

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

rust-lang/rfcs#1368
A quote from the issue above:
fwiw, I see no mention here of "thread-directed" signals. IMHO, it's reasonable to not support them as a first pass (they're a totally different thing than process-directed signals), but worth at least being explicit about what's in scope.

As an example of what these are: let's say I do a mmap of a file and try to read from it but another process has truncated the file so the page I'm reading is no longer valid. A SIGBUS is generated and directed to the thread doing the read. It can't be handled by some other thread using signalfd or the like.

Likewise, SIGFPE, SIGSEGV, SIGILL, SIGPIPE, and anything done with pthread_kill/pthread_sigqueue. The last case is sometimes used as a mechanism for CPU / wall clock profiling tools or thread cancellation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bigint, so I think it will panic instead of raising a hardware exception, but I have added div by zero checker

let bounty_url = if cfg!(not(test)) {
format!("http://[{}]:8888/update", "2001::3".parse::<Ipv6Addr>().unwrap())
} else {
String::from("http://127.0.0.1:1234") //TODO: This is mockito::SERVER_URL, but don't want to include the crate in a non-test build just for that string
String::from("http://127.0.0.1:1234/update") //TODO: This is mockito::SERVER_URL, but don't want to include the crate in a non-test build just for that string
Copy link
Contributor

Choose a reason for hiding this comment

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

This todo most likely should've become a GitHub issue

rita/src/main.rs Outdated
}
payment_controller_input1 .send(PaymentControllerMsg::Update);
Copy link
Contributor

Choose a reason for hiding this comment

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

A likely unwanted space after the 1

rita/src/main.rs Outdated
Arc::new(Mutex::new(debt_keeper_input.clone()))
);

let payment_controller_input1 = payment_controller_input.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this variable numbered? If it's got a distinct purpose why doesn't the name express it?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a clone of a channel input. I would be curious what naming scheme you'd prefer. We could name it after what it was intended to be used by, but that might get very long winded.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now, so there's two different components chatting with the payment controller? And shadowing the same variable name would get the borrow checke angry?

Copy link
Contributor

Choose a reason for hiding this comment

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

(or simply overwriting the variable)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it so there is a master, which we clone, and just pass in variables which we just overwrite each time

thread::spawn(move || {
let mut ki = KernelInterface {};
let mut tm = TunnelManager::new();
let mut babel = Babel::new(&"[::1]:8080".parse().unwrap()); //TODO: Do we really want [::1] and not [::0]?
let mut babel = Babel::new(&"[::1]:8080".parse().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does Babel start on 8080? It's a well known port already widely used for user-controlled HTTP servers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, what if someone runs an exit and would like to also put up a status webpage on 80 and some unrelated program's admin panel on 8080?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be fair, I don't really know. That's what @jtremback 's original test script was set to so I just continued using it.

rita/src/main.rs Outdated
let pc = PaymentController::start(&my_ident, m_tx);

let pc1 = pc.clone();
let payment_controller_input2 = payment_controller_input.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

Another numbered thing


for debt_adjustment in rx {
match dk.apply_debt(debt_adjustment.ident, debt_adjustment.amount) {
for msg in debt_keeper_output {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this loop need to constantly roll, wouldn't it be better to block until something actually happens? That way this thread could just go to sleep on the socket within the debt keeper

Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this does block, it is iterating over the channel output

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, okay, my poor knowledge of Rust strikes again

@jtremback jtremback merged commit 5f856be into master Feb 8, 2018
@kingoflolz kingoflolz deleted the improve-integration-tests branch February 27, 2018 14:21
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.

4 participants