diff --git a/substrate/wasm-runtime/polkadot/src/codec/endiansensitive.rs b/substrate/wasm-runtime/polkadot/src/codec/endiansensitive.rs index 03dfbf8823..ec9be8e465 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/endiansensitive.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/endiansensitive.rs @@ -45,9 +45,7 @@ macro_rules! impl_non_endians { )* } } -// TODO: this is fine as long as bool is one byte. it'll break if llvm tries to use more. happily, -// this isn't an issue for the forseeable future. if it ever happens, then it should be implemented -// as endian sensitive. +// NOTE: See test to ensure correctness. impl EndianSensitive for bool {} impl_endians!(u16, u32, u64, usize, i16, i32, i64, isize); @@ -70,4 +68,12 @@ mod tests { fn _takes_static() { } fn _takes_endian_sensitive() { _takes_static::() } } + + #[test] + fn bool_is_not_endian_sensitive() { + let b = true; + assert_eq!(b.to_be(), b.to_le()); + let b = false; + assert_eq!(b.to_be(), b.to_le()); + } }