mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 11:19:57 +00:00
additional network field, that represents default rate limit measured in blocks
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
@@ -12,6 +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: 69,
|
||||
rate_limit_delay: 69,
|
||||
block_distance: 69,
|
||||
network_type: NetworkType::Evm,
|
||||
gatekeeper: b"0x1234567891234567891234567891234567891234".to_vec(),
|
||||
@@ -136,6 +137,27 @@ fn could_update_network_finality_delay_from_authority_account() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_update_network_rate_limit_delay_from_authority_account() {
|
||||
ExtBuilder::build()
|
||||
.execute_with(|| {
|
||||
let new_rate_limit_delay = 1337;
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_ok!(GhostNetworks::update_network_rate_limit_delay(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id, new_rate_limit_delay));
|
||||
System::assert_last_event(RuntimeEvent::GhostNetworks(
|
||||
crate::Event::NetworkRateLimitDelayUpdated {
|
||||
chain_id,
|
||||
rate_limit_delay: new_rate_limit_delay }));
|
||||
let mut final_network = network.clone();
|
||||
final_network.rate_limit_delay = new_rate_limit_delay;
|
||||
assert_eq!(Networks::<Test>::get(chain_id), Some(final_network.clone()));
|
||||
assert_ne!(network, final_network);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_update_network_block_distance_from_authority_account() {
|
||||
ExtBuilder::build()
|
||||
@@ -329,6 +351,29 @@ fn could_not_update_network_finality_delay_from_random_account() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_update_network_rate_limit_delay_from_random_account() {
|
||||
ExtBuilder::build()
|
||||
.execute_with(|| {
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
let rate_limit_delay = 1337;
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_err!(GhostNetworks::update_network_rate_limit_delay(
|
||||
RuntimeOrigin::signed(RegistererAccount::get()),
|
||||
chain_id, rate_limit_delay),
|
||||
DispatchError::BadOrigin);
|
||||
assert_err!(GhostNetworks::update_network_rate_limit_delay(
|
||||
RuntimeOrigin::signed(RemoverAccount::get()),
|
||||
chain_id, rate_limit_delay),
|
||||
DispatchError::BadOrigin);
|
||||
assert_err!(GhostNetworks::update_network_rate_limit_delay(
|
||||
RuntimeOrigin::signed(RandomAccount::get()),
|
||||
chain_id, rate_limit_delay),
|
||||
DispatchError::BadOrigin);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), Some(network));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_update_network_release_delay_from_random_account() {
|
||||
ExtBuilder::build()
|
||||
@@ -504,6 +549,20 @@ fn could_not_update_finality_delay_for_non_existent_network() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_update_rate_limit_delay_for_non_existent_network() {
|
||||
ExtBuilder::build()
|
||||
.execute_with(|| {
|
||||
let chain_id: u32 = 1;
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
assert_err!(GhostNetworks::update_network_rate_limit_delay(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id, 1337),
|
||||
crate::Error::<Test>::NetworkDoesNotExist);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_update_release_delay_for_non_existent_network() {
|
||||
ExtBuilder::build()
|
||||
|
||||
Reference in New Issue
Block a user