|
1 | | -use alexandria_bytes::BytesTrait; |
2 | | -use contracts::interfaces::{IAggregationDispatcherTrait, ModuleType}; |
| 1 | +use alexandria_bytes::{Bytes, BytesTrait}; |
| 2 | +use contracts::interfaces::{ |
| 3 | + IAggregationDispatcher, IAggregationDispatcherTrait, IInterchainSecurityModuleDispatcher, |
| 4 | + IInterchainSecurityModuleDispatcherTrait, IValidatorConfigurationDispatcher, |
| 5 | + IValidatorConfigurationDispatcherTrait, ModuleType, |
| 6 | +}; |
3 | 7 | use contracts::isms::aggregation::aggregation; |
4 | 8 | use contracts::libs::message::{HYPERLANE_VERSION, Message}; |
5 | 9 | use contracts::utils::utils::U256TryIntoContractAddress; |
6 | 10 |
|
7 | | -use openzeppelin::access::ownable::interface::IOwnableDispatcher; |
8 | | -use snforge_std::{CheatSpan, cheat_caller_address}; |
| 11 | +use openzeppelin::access::ownable::interface::{IOwnableDispatcher, IOwnableDispatcherTrait}; |
| 12 | +use snforge_std::{ |
| 13 | + CheatSpan, ContractClassTrait, DeclareResultTrait, EventSpy, cheat_caller_address, |
| 14 | + cheatcodes::contract_class::ContractClass, declare, spy_events, |
| 15 | +}; |
| 16 | + |
| 17 | + |
| 18 | +use starknet::ContractAddress; |
9 | 19 | use super::super::setup::{ |
10 | 20 | CONTRACT_MODULES, DESTINATION_DOMAIN, LOCAL_DOMAIN, MODULES, OWNER, VALID_OWNER, |
11 | 21 | VALID_RECIPIENT, build_messageid_metadata, get_message_and_signature, setup_aggregation, |
@@ -104,3 +114,65 @@ fn test_aggregation_verify() { |
104 | 114 | assert(aggregation.verify(concat_metadata, message), 'Aggregation: verify failed'); |
105 | 115 | } |
106 | 116 |
|
| 117 | + |
| 118 | +#[test] |
| 119 | +fn test_aggregation_verify_e2e() { |
| 120 | + let aggregation_threshold = 1; |
| 121 | + |
| 122 | + // MESSAGEID |
| 123 | + let message_body = BytesTrait::new(11, array![0x68656C6C6F20776F726C640000000000]); |
| 124 | + let metadata = BytesTrait::new( |
| 125 | + 144, |
| 126 | + array![ |
| 127 | + 0x000000080000008d071e1b5e54086bbd, |
| 128 | + 0xe2b7a131a2c913f442485974c32df56e, |
| 129 | + 0xe47f9456b3270daebe22faba5bc0223a, |
| 130 | + 0x7e3077adcd04391f2ccdd2b2ad2eac2d, |
| 131 | + 0x71c3f04755d5d95d000000015dcbf07f, |
| 132 | + 0xa1898b0d8b64991f099e8478268fb36e, |
| 133 | + 0x0e5fe7832aa345da8b8888645622786d, |
| 134 | + 0x53d898c95d75d37a582de78deda23497, |
| 135 | + 0x7d806349eac6653e9190d11a1c000000, |
| 136 | + ], |
| 137 | + ); |
| 138 | + let message = Message { |
| 139 | + version: HYPERLANE_VERSION, |
| 140 | + nonce: 0, |
| 141 | + origin: 23448593, |
| 142 | + sender: 0x00b3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca, |
| 143 | + destination: 23448594, |
| 144 | + recipient: 0x0777c88c0822f31828c97688a219af6b6689cae7bc90a7aa71437956dfed16a1, |
| 145 | + body: message_body.clone(), |
| 146 | + }; |
| 147 | + |
| 148 | + let multisig_threshold = 1; |
| 149 | + let validators_array: Array<felt252> = array![ |
| 150 | + 0x15d34aaf54267db7d7c367839aaf71a00a2c6a65.try_into().unwrap(), |
| 151 | + ]; |
| 152 | + |
| 153 | + // Deploy the messageid contract at a specific address |
| 154 | + let specific_address: ContractAddress = |
| 155 | + 0x045133e4b0a40aa7992bfb5d7f552b767be1b070af81f0313adf8e01cf3ab32c |
| 156 | + .try_into() |
| 157 | + .unwrap(); |
| 158 | + let messageid_class = declare("messageid_multisig_ism").unwrap().contract_class(); |
| 159 | + let mut parameters = Default::default(); |
| 160 | + let owner: felt252 = 0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca |
| 161 | + .try_into() |
| 162 | + .unwrap(); |
| 163 | + Serde::serialize(@owner, ref parameters); |
| 164 | + Serde::serialize(@validators_array.span(), ref parameters); |
| 165 | + Serde::serialize(@multisig_threshold, ref parameters); |
| 166 | + messageid_class.deploy_at(@parameters, specific_address); |
| 167 | + |
| 168 | + let messageid_ism = IInterchainSecurityModuleDispatcher { contract_address: specific_address }; |
| 169 | + // println!("E2E test messageid_ism: {}", messageid_ism.contract_address()); |
| 170 | + |
| 171 | + let aggregation = setup_aggregation( |
| 172 | + array![messageid_ism.contract_address.into()].span(), |
| 173 | + aggregation_threshold.try_into().unwrap(), |
| 174 | + ); |
| 175 | + |
| 176 | + assert(aggregation.verify(metadata, message), 'Aggregation: verify failed'); |
| 177 | +} |
| 178 | + |
0 commit comments