remove legacy release_delay and add block_distance for maximum block range for the eth_getLogs

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch
2025-06-18 18:53:19 +03:00
parent 39a6192d28
commit 671196ebac
5 changed files with 227 additions and 196 deletions

View File

@@ -12,7 +12,7 @@ fn prepare_network_data() -> (u32, NetworkData) {
chain_name: "Ethereum".into(),
default_endpoint: "https:://some-endpoint.my-server.com/v1/my-super-secret-key".into(),
finality_delay: Some(69),
release_delay: Some(69),
block_distance: 69,
network_type: NetworkType::Evm,
gatekeeper: b"0x1234567891234567891234567891234567891234".to_vec(),
topic_name: b"0x12345678912345678912345678912345678912345678912345678912345678".to_vec(),
@@ -137,21 +137,21 @@ fn could_update_network_finality_delay_from_authority_account() {
}
#[test]
fn could_update_network_release_delay_from_authority_account() {
fn could_update_network_block_distance_from_authority_account() {
ExtBuilder::build()
.execute_with(|| {
let new_release_delay = Some(1337);
let new_block_distance = 1337;
let (chain_id, network) = prepare_network_data();
register_and_check_network(chain_id, network.clone());
assert_ok!(GhostNetworks::update_network_release_delay(
assert_ok!(GhostNetworks::update_network_block_distance(
RuntimeOrigin::signed(UpdaterAccount::get()),
chain_id, new_release_delay));
chain_id, new_block_distance));
System::assert_last_event(RuntimeEvent::GhostNetworks(
crate::Event::NetworkReleaseDelayUpdated {
crate::Event::NetworkBlockDistanceUpdated {
chain_id,
release_delay: new_release_delay }));
block_distance: new_block_distance }));
let mut final_network = network.clone();
final_network.release_delay = new_release_delay;
final_network.block_distance = new_block_distance;
assert_eq!(Networks::<Test>::get(chain_id), Some(final_network.clone()));
assert_ne!(network, final_network);
});
@@ -333,18 +333,19 @@ fn could_not_update_network_release_delay_from_random_account() {
ExtBuilder::build()
.execute_with(|| {
let (chain_id, network) = prepare_network_data();
let block_distance = 1337;
register_and_check_network(chain_id, network.clone());
assert_err!(GhostNetworks::update_network_release_delay(
assert_err!(GhostNetworks::update_network_block_distance(
RuntimeOrigin::signed(RegistererAccount::get()),
chain_id, Some(1337)),
chain_id, block_distance),
DispatchError::BadOrigin);
assert_err!(GhostNetworks::update_network_release_delay(
assert_err!(GhostNetworks::update_network_block_distance(
RuntimeOrigin::signed(RemoverAccount::get()),
chain_id, Some(1337)),
chain_id, block_distance),
DispatchError::BadOrigin);
assert_err!(GhostNetworks::update_network_release_delay(
assert_err!(GhostNetworks::update_network_block_distance(
RuntimeOrigin::signed(RandomAccount::get()),
chain_id, Some(1337)),
chain_id, block_distance),
DispatchError::BadOrigin);
assert_eq!(Networks::<Test>::get(chain_id), Some(network));
});
@@ -508,9 +509,9 @@ fn could_not_update_release_delay_for_non_existent_network() {
.execute_with(|| {
let chain_id: u32 = 1;
assert_eq!(Networks::<Test>::get(chain_id), None);
assert_err!(GhostNetworks::update_network_release_delay(
assert_err!(GhostNetworks::update_network_block_distance(
RuntimeOrigin::signed(UpdaterAccount::get()),
chain_id, Some(1337)),
chain_id, 1337),
crate::Error::<Test>::NetworkDoesNotExist);
assert_eq!(Networks::<Test>::get(chain_id), None);
});