Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 71fee78

Browse files
committedMay 24, 2024
feat: add ui test for filtering singular queries in smart contracts
Signed-off-by: Nikita Strygin <[email protected]>
1 parent b70f293 commit 71fee78

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed
 

‎Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎smart_contract/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ webassembly-test = "0.1.0"
3232
# Not used directly but required for compilation
3333
getrandom = { version = "0.2", features = ["custom"] }
3434

35+
trybuild = { workspace = true }

‎smart_contract/tests/ui.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![cfg(not(coverage))]
2+
use trybuild::TestCases;
3+
4+
#[cfg(not(target_arch = "wasm32"))]
5+
#[test]
6+
fn ui() {
7+
let test_cases = TestCases::new();
8+
test_cases.compile_fail("tests/ui_fail/*.rs");
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use iroha_smart_contract::{
2+
data_model::query::predicate::{string::StringPredicate, value::QueryOutputPredicate},
3+
prelude::*,
4+
};
5+
6+
fn main() {
7+
FindPermissionSchema
8+
.filter(QueryOutputPredicate::Identifiable(
9+
StringPredicate::starts_with("xor_"),
10+
))
11+
.execute()
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0599]: the method `filter` exists for struct `FindPermissionSchema`, but its trait bounds were not satisfied
2+
--> tests/ui_fail/cant_filter_singular_query.rs:8:10
3+
|
4+
7 | / FindPermissionSchema
5+
8 | | .filter(QueryOutputPredicate::Identifiable(
6+
| | -^^^^^^ method cannot be called on `FindPermissionSchema` due to unsatisfied trait bounds
7+
| |_________|
8+
|
9+
|
10+
::: $WORKSPACE/data_model/src/query/mod.rs
11+
|
12+
| / queries! {
13+
| | /// Finds all registered permission tokens
14+
| | #[derive(Copy, Display)]
15+
| | #[ffi_type]
16+
... |
17+
| | }
18+
| | }
19+
| |_____- doesn't satisfy `_: ExecuteIterableQueryOnHost`, `_: IterableQuery` or `_: Iterator`
20+
|
21+
= note: the following trait bounds were not satisfied:
22+
`iroha_smart_contract::prelude::FindPermissionSchema: IterableQuery`
23+
which is required by `iroha_smart_contract::prelude::FindPermissionSchema: iroha_smart_contract::ExecuteIterableQueryOnHost`
24+
`iroha_smart_contract::prelude::FindPermissionSchema: Iterator`
25+
which is required by `&mut iroha_smart_contract::prelude::FindPermissionSchema: Iterator`

0 commit comments

Comments
 (0)
Please sign in to comment.