Skip to content

Commit 401eac6

Browse files
committed
Merge branch 'tiago/router-no-pat-match' (#2739)
* origin/tiago/router-no-pat-match: Changelog for #2739 Add router regression test Avoid looping indefinitely when sub-router doesn't match
2 parents f96503b + 23901a3 commit 401eac6

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Bail from router if a nester router segment is not matched.
2+
([\#2739](https://github.com/anoma/namada/pull/2739))

crates/sdk/src/queries/router.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ macro_rules! try_match_segments {
126126
);
127127
}
128128
)*
129+
130+
return Err(
131+
$crate::queries::router::Error::WrongPath($request.path.clone()))
132+
.into_storage_result();
129133
};
130134

131135
// Terminal tail call, invoked after when all the args in the current
@@ -1040,6 +1044,25 @@ mod test {
10401044
let result = TEST_RPC.handle(ctx, &request);
10411045
assert!(result.is_err());
10421046

1047+
// Test request with another invalid path.
1048+
// The key difference here is that we are testing
1049+
// an invalid path in a nested segment.
1050+
let request = RequestQuery {
1051+
path: "/b/4".to_owned(),
1052+
data: Default::default(),
1053+
height: block::Height::from(0_u32),
1054+
prove: Default::default(),
1055+
};
1056+
let ctx = RequestCtx {
1057+
event_log: &client.event_log,
1058+
state: &client.state,
1059+
vp_wasm_cache: (),
1060+
tx_wasm_cache: (),
1061+
storage_read_past_height_limit: None,
1062+
};
1063+
let result = TEST_RPC.handle(ctx, &request);
1064+
assert!(result.is_err());
1065+
10431066
// Test request with a non-ascii path
10441067
let request = RequestQuery {
10451068
path: "ÀÁõö÷øùúûüýþÿ".to_owned(),

crates/tests/src/e2e/ibc_tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,15 @@ fn check_shielded_balances_after_back(
20622062
// Check the balance on Chain B
20632063
std::env::set_var(ENV_VAR_CHAIN_ID, test_b.net.chain_id.to_string());
20642064
let rpc_b = get_actor_rpc(test_b, Who::Validator(0));
2065+
let tx_args = vec![
2066+
"shielded-sync",
2067+
"--viewing-keys",
2068+
AB_VIEWING_KEY,
2069+
"--node",
2070+
&rpc_b,
2071+
];
2072+
let mut client = run!(test_b, Bin::Client, tx_args, Some(120))?;
2073+
client.assert_success();
20652074
let ibc_denom = format!("{src_port_id}/{src_channel_id}/btc");
20662075
let query_args = vec![
20672076
"balance",
@@ -2081,6 +2090,15 @@ fn check_shielded_balances_after_back(
20812090
// Check the balance on Chain A
20822091
std::env::set_var(ENV_VAR_CHAIN_ID, test_a.net.chain_id.to_string());
20832092
let rpc_a = get_actor_rpc(test_a, Who::Validator(0));
2093+
let tx_args = vec![
2094+
"shielded-sync",
2095+
"--viewing-keys",
2096+
AA_VIEWING_KEY,
2097+
"--node",
2098+
&rpc_a,
2099+
];
2100+
let mut client = run!(test_a, Bin::Client, tx_args, Some(120))?;
2101+
client.assert_success();
20842102
let query_args = vec![
20852103
"balance",
20862104
"--owner",

0 commit comments

Comments
 (0)