Skip to content

Commit abb7cbd

Browse files
authored
refactor(tests): Remove TestEndpoint::addr (#666)
## Description The RoutingTable is in charge of which addresses a TestEndpoint has. So now all decisions are made there remove the addr field and clean up any remaining usages. This should avoid confusion in the future. ## Breaking Changes n/a ## Notes & open questions Maybe I'm finally done with cleaning up existing test infra. I'm medium enthusiastic about this whole thing. I think it's an improvement but there's definitely some things that look more complex now. And some of the tests still do just plain weird stuff. Like when opening a 2nd path we should now probably have a router that has a 2nd path. But it was originally written without any router so cheated by disconnecting the first path and relying on not reaching the keep-alive interval or idle-timeout of the first path. So those are still further improvements. But I need to work towards writing my test, so I'll stop here. ## Change checklist - [x] Self-review. - [ ] Tests if relevant.
1 parent a635174 commit abb7cbd

4 files changed

Lines changed: 193 additions & 109 deletions

File tree

noq-proto/src/tests/mod.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@ fn zero_rtt_happypath() {
558558
.close(pair.time, VarInt(0), [][..].into());
559559
pair.drive();
560560

561-
pair.client.addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
562-
assert_ne!(pair.client.addr, Pair::CLIENT_ADDR);
563-
assert_ne!(pair.client.addr, Pair::SERVER_ADDR);
561+
let new_addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
562+
assert_ne!(new_addr, Pair::CLIENT_ADDR);
563+
assert_ne!(new_addr, Pair::SERVER_ADDR);
564+
pair.routes.as_basic_mut().client_addr = new_addr;
564565
info!("resuming session");
565566
let client_ch = pair.begin_connect(config);
566567
assert!(pair.client_conn_mut(client_ch).has_0rtt());
@@ -738,9 +739,10 @@ fn test_zero_rtt_incoming_limit<F: FnOnce(&mut ServerConfig)>(configure_server:
738739
.close(pair.time, VarInt(0), [][..].into());
739740
pair.drive();
740741

741-
pair.client.addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
742-
assert_ne!(pair.client.addr, Pair::CLIENT_ADDR);
743-
assert_ne!(pair.client.addr, Pair::SERVER_ADDR);
742+
let new_addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
743+
assert_ne!(new_addr, Pair::CLIENT_ADDR);
744+
assert_ne!(new_addr, Pair::SERVER_ADDR);
745+
pair.routes.as_basic_mut().client_addr = new_addr;
744746
info!("resuming session");
745747
pair.server.handle_incoming = Box::new(|_| IncomingConnectionBehavior::Wait);
746748
let client_ch = pair.begin_connect(config);
@@ -3714,7 +3716,7 @@ fn address_discovery() {
37143716
pair.drive();
37153717

37163718
// check that the client received the correct address
3717-
let expected_addr = pair.client.addr;
3719+
let expected_addr = pair.routes.as_basic().client_addr;
37183720
let conn = pair.client_conn_mut(conn_handle);
37193721
assert_matches!(conn.poll(), Some(Event::HandshakeDataReady));
37203722
assert_matches!(conn.poll(), Some(Event::Connected));
@@ -3724,7 +3726,7 @@ fn address_discovery() {
37243726

37253727
// check that the server received the correct address
37263728
let conn_handle = pair.server.assert_accept();
3727-
let expected_addr = pair.server.addr;
3729+
let expected_addr = pair.routes.as_basic().server_addr;
37283730
let conn = pair.server_conn_mut(conn_handle);
37293731
assert_matches!(conn.poll(), Some(Event::HandshakeDataReady));
37303732
assert_matches!(conn.poll(), Some(Event::HandshakeConfirmed));
@@ -3776,9 +3778,10 @@ fn address_discovery_zero_rtt_accepted() {
37763778
.close(pair.time, VarInt(0), [][..].into());
37773779
pair.drive();
37783780

3779-
pair.client.addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
3780-
assert_ne!(pair.client.addr, Pair::CLIENT_ADDR);
3781-
assert_ne!(pair.client.addr, Pair::SERVER_ADDR);
3781+
let new_addr = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 1);
3782+
assert_ne!(new_addr, Pair::CLIENT_ADDR);
3783+
assert_ne!(new_addr, Pair::SERVER_ADDR);
3784+
pair.routes.as_basic_mut().client_addr = new_addr;
37823785
info!("resuming session");
37833786
let client_ch = pair.begin_connect(alt_client_cfg);
37843787
assert!(pair.client_conn_mut(client_ch).has_0rtt());
@@ -3929,7 +3932,11 @@ fn address_discovery_retransmission() {
39293932
pair.drive();
39303933
let conn = pair.client_conn_mut(client_ch);
39313934
assert_matches!(conn.poll(), Some(Event::HandshakeConfirmed));
3932-
assert_matches!(conn.poll(), Some(Event::Path(PathEvent::ObservedAddr{id: PathId::ZERO, addr})) if addr == pair.client.addr);
3935+
assert_matches!(
3936+
conn.poll(),
3937+
Some(Event::Path(PathEvent::ObservedAddr{id: PathId::ZERO, addr}))
3938+
if addr == pair.routes.as_basic().client_addr
3939+
);
39333940
}
39343941

39353942
#[test]

0 commit comments

Comments
 (0)