-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
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
There was a problem hiding this 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.
There was a problem hiding this 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
integration-tests/rita.sh
Outdated
./rita-deps.sh | ||
sudo python3 rita.py |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
num256/src/lib.rs
Outdated
@@ -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()) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
num256/src/lib.rs
Outdated
@@ -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()) |
There was a problem hiding this comment.
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"?
num256/src/lib.rs
Outdated
impl Div for Int256 { | ||
type Output = Int256; | ||
fn div(self, v: Int256) -> Int256 { | ||
let num = self.0 / v.0; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
(this PR is a superset of #30)