Add a re-entrancy guard to Router.execute

This commit is contained in:
Luke Parker
2024-11-02 20:12:48 -04:00
parent 26230377b0
commit 2920987173
3 changed files with 47 additions and 0 deletions

View File

@@ -22,6 +22,18 @@ use ethereum_deployer::Deployer;
use crate::{Coin, OutInstructions, Router};
#[test]
fn execute_reentrancy_guard() {
let hash = alloy_core::primitives::keccak256(b"ReentrancyGuard Router.execute");
assert_eq!(
alloy_core::primitives::hex::encode(
(U256::from_be_slice(hash.as_ref()) - U256::from(1u8)).to_be_bytes::<32>()
),
// Constant from the Router contract
"cf124a063de1614fedbd6b47187f98bf8873a1ae83da5c179a5881162f5b2401",
);
}
#[test]
fn selector_collisions() {
assert_eq!(
@@ -32,6 +44,10 @@ fn selector_collisions() {
crate::_irouter_abi::IRouter::updateSeraiKeyCall::SELECTOR,
crate::_router_abi::Router::updateSeraiKey5A8542A2Call::SELECTOR
);
assert_eq!(
crate::_irouter_abi::IRouter::escapeHatchCall::SELECTOR,
crate::_router_abi::Router::escapeHatchDCDD91CCCall::SELECTOR
);
}
pub(crate) fn test_key() -> (Scalar, PublicKey) {