Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
test: add byte equality test between ethers-rs / web3.js signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Sep 30, 2020
1 parent 8b66c71 commit e6d6f37
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions ethers-core/src/types/crypto/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,13 @@ mod tests {
.parse()
.unwrap();
let address = Address::from(&key);
let our_signature = key.sign("Some data");
let signature = Signature::from_str(
"b91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c"
).expect("could not parse signature");

// recover the address from the above signature
let recovered = signature.recover("Some data").unwrap();
assert_eq!(
format!("{:?}", recovered),
"0x2c7536e3605d9c16a7a3d7b1898e529396a65c23"
);

assert_eq!(recovered, address);
assert_eq!(our_signature.recover("Some data").unwrap(), address,);
assert_eq!(signature.recover("Some data").unwrap(), address);
assert_eq!(our_signature, signature);
}

#[test]
Expand Down

0 comments on commit e6d6f37

Please sign in to comment.