Skip to content

Commit 646d436

Browse files
committed
Add tests
1 parent 88ffd67 commit 646d436

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ink/ir/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ impl-serde = { workspace = true }
2727
ink_prelude = { workspace = true }
2828
sha3 = { workspace = true }
2929

30+
[dev-dependencies]
31+
hex-literal = "1"
32+
3033
[features]
3134
default = [ "std" ]
3235
std = [

crates/ink/ir/src/ir/selector.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,22 @@ mod tests {
319319
]
320320
)
321321
}
322+
323+
#[test]
324+
fn selector_sol_works() {
325+
use quote::quote;
326+
let sel = SelectorMacro::<crate::marker::SelectorBytes>::try_from(quote! {
327+
Abi::Sol, "ownCodeHash()"
328+
}).unwrap();
329+
assert_eq!(sel.selector.bytes, [219u8, 107, 220, 138]);
330+
}
331+
332+
#[test]
333+
fn selector_ink_works() {
334+
use quote::quote;
335+
let sel = SelectorMacro::<crate::marker::SelectorBytes>::try_from(quote! {
336+
Abi::Ink, "flip"
337+
}).unwrap();
338+
assert_eq!(sel.selector.bytes, hex_literal::hex!("633aa551"));
339+
}
322340
}

crates/ink/ir/src/ir/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::{
2323
MetaValue,
2424
},
2525
error::ExtError as _,
26-
format_err,
2726
};
2827
use proc_macro2::Span;
2928
use std::collections::HashMap;

0 commit comments

Comments
 (0)