openethereum/util/bloomable/tests/test.rs

28 lines
1.4 KiB
Rust
Raw Normal View History

2017-11-10 19:04:55 +01:00
extern crate keccak_hash as hash;
extern crate ethereum_types;
2017-07-29 17:12:07 +02:00
extern crate bloomable;
use ethereum_types::{H160, H256, H2048};
2017-07-29 17:12:07 +02:00
use bloomable::Bloomable;
use hash::keccak;
2017-07-29 17:12:07 +02:00
#[test]
fn shift_bloomed() {
let bloom: H2048 = "00000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000008000000001000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into();
let address: H160 = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
let topic: H256 = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".into();
let mut my_bloom = H2048::default();
assert!(!my_bloom.contains_bloomed(&keccak(&address)));
assert!(!my_bloom.contains_bloomed(&keccak(&topic)));
2017-07-29 17:12:07 +02:00
my_bloom.shift_bloomed(&keccak(&address));
assert!(my_bloom.contains_bloomed(&keccak(&address)));
assert!(!my_bloom.contains_bloomed(&keccak(&topic)));
2017-07-29 17:12:07 +02:00
my_bloom.shift_bloomed(&keccak(&topic));
2017-07-29 17:12:07 +02:00
assert_eq!(my_bloom, bloom);
assert!(my_bloom.contains_bloomed(&keccak(&address)));
assert!(my_bloom.contains_bloomed(&keccak(&topic)));
2017-07-29 17:12:07 +02:00
}