Skip to content

Commit

Permalink
chore: rename default to distinguish from Default::default
Browse files Browse the repository at this point in the history
  • Loading branch information
dandanlen committed Feb 15, 2024
1 parent 2978f54 commit 56726f4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion state-chain/cf-integration-tests/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use state_chain_runtime::{Reputation, Runtime, Validator};

#[test]
fn account_deletion_removes_relevant_storage_items() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
let genesis_nodes = Validator::current_authorities();

// Create a single backup node which we will use to test deletion
Expand Down
16 changes: 8 additions & 8 deletions state-chain/cf-integration-tests/src/authorities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn fund_authorities_and_join_auction(
fn authority_rotates_with_correct_sequence() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -154,7 +154,7 @@ fn authorities_earn_rewards_for_authoring_blocks() {
// Reduce our validating set and hence the number of nodes we need to have a backup
// set
const MAX_AUTHORITIES: AuthorityCount = 3;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -198,7 +198,7 @@ fn genesis_nodes_rotated_out_accumulate_rewards_correctly() {
// Reduce our validating set and hence the number of nodes we need to have a backup
// set
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -263,7 +263,7 @@ fn genesis_nodes_rotated_out_accumulate_rewards_correctly() {
fn authority_rotation_can_succeed_after_aborted_by_safe_mode() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -318,7 +318,7 @@ fn authority_rotation_cannot_be_aborted_after_key_handover_and_completes_even_on
{
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -361,7 +361,7 @@ fn authority_rotation_cannot_be_aborted_after_key_handover_and_completes_even_on
fn authority_rotation_can_recover_after_keygen_fails() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -409,7 +409,7 @@ fn authority_rotation_can_recover_after_keygen_fails() {
fn authority_rotation_can_recover_after_key_handover_fails() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -477,7 +477,7 @@ fn authority_rotation_can_recover_after_key_handover_fails() {
fn can_move_through_multiple_epochs() {
const EPOCH_BLOCKS: u32 = 100;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down
2 changes: 1 addition & 1 deletion state-chain/cf-integration-tests/src/broadcasting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use state_chain_runtime::{
fn bitcoin_broadcast_delay_works() {
const EPOCH_BLOCKS: u32 = 200;
const MAX_AUTHORITIES: AuthorityCount = 150;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down
12 changes: 6 additions & 6 deletions state-chain/cf-integration-tests/src/funding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use state_chain_runtime::{
fn cannot_redeem_funds_out_of_redemption_period() {
const EPOCH_BLOCKS: u32 = 100;
const MAX_AUTHORITIES: AuthorityCount = 3;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -124,7 +124,7 @@ fn cannot_redeem_funds_out_of_redemption_period() {
#[test]
fn funded_node_is_added_to_backups() {
const EPOCH_BLOCKS: u32 = 10_000_000;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
// As we run a rotation at genesis we will need accounts to support
// having 5 authorities as the default is 3 (Alice, Bob and Charlie)
Expand All @@ -148,7 +148,7 @@ fn backup_reward_is_calculated_linearly() {
const EPOCH_BLOCKS: u32 = 1_000;
const MAX_AUTHORITIES: u32 = 10;
const NUM_BACKUPS: u32 = 20;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -193,7 +193,7 @@ fn can_calculate_account_apy() {
const EPOCH_BLOCKS: u32 = 1_000;
const MAX_AUTHORITIES: u32 = 10;
const NUM_BACKUPS: u32 = 20;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -245,7 +245,7 @@ fn apy_can_be_above_100_percent() {
const EPOCH_BLOCKS: u32 = 1_000;
const MAX_AUTHORITIES: u32 = 2;
const NUM_BACKUPS: u32 = 2;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -280,7 +280,7 @@ fn backup_rewards_event_gets_emitted_on_heartbeat_interval() {
const EPOCH_BLOCKS: u32 = 1_000;
const NUM_BACKUPS: u32 = 20;
const MAX_AUTHORITIES: u32 = 100;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.accounts(
(0..MAX_AUTHORITIES as u8)
Expand Down
4 changes: 2 additions & 2 deletions state-chain/cf-integration-tests/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const GENESIS_BALANCE: FlipBalance = TOTAL_ISSUANCE / 100;

const BLOCKS_PER_EPOCH: u32 = 1000;

pub fn default() -> ExtBuilder {
pub fn with_test_defaults() -> ExtBuilder {
ExtBuilder::default()
.accounts(vec![
(AccountId::from(ALICE), AccountRole::Validator, GENESIS_BALANCE),
Expand All @@ -30,7 +30,7 @@ pub fn default() -> ExtBuilder {

#[test]
fn state_of_genesis_is_as_expected() {
default().build().execute_with(|| {
with_test_defaults().build().execute_with(|| {
// Confirmation that we have our assumed state at block 1
assert_eq!(Flip::total_issuance(), TOTAL_ISSUANCE, "we have issued the total issuance");

Expand Down
2 changes: 1 addition & 1 deletion state-chain/cf-integration-tests/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use pallet_transaction_payment::OnChargeTransaction;
#[test]
// Governance is allowed to make free calls to governance gated extrinsics.
fn governance_members_pay_no_fees_for_governance_extrinsics() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
let call: state_chain_runtime::RuntimeCall =
frame_system::Call::remark { remark: vec![] }.into();
let gov_call: state_chain_runtime::RuntimeCall =
Expand Down
4 changes: 2 additions & 2 deletions state-chain/cf-integration-tests/src/new_epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use state_chain_runtime::Validator;
#[test]
fn auction_repeats_after_failure_because_of_liveness() {
const EPOCH_BLOCKS: BlockNumber = 1000;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
// As we run a rotation at genesis we will need accounts to support
// having 5 authorities as the default is 3 (Alice, Bob and Charlie)
Expand Down Expand Up @@ -96,7 +96,7 @@ fn auction_repeats_after_failure_because_of_liveness() {
fn epoch_rotates() {
const EPOCH_BLOCKS: BlockNumber = 1000;
const MAX_SET_SIZE: AuthorityCount = 5;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.min_authorities(MAX_SET_SIZE)
.build()
Expand Down
4 changes: 2 additions & 2 deletions state-chain/cf-integration-tests/src/signer_nomination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type RuntimeThresholdSignerNomination =

#[test]
fn threshold_signer_nomination_respects_epoch() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
let genesis_authorities = Validator::current_authorities();
let genesis_epoch = Validator::epoch_index();

Expand Down Expand Up @@ -76,7 +76,7 @@ fn test_not_nominated_for_offence<F: Fn(crate::AccountId)>(penalise: F) {

#[test]
fn nodes_who_failed_to_sign_excluded_from_threshold_nomination() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
test_not_nominated_for_offence(|node_id| {
Reputation::report(PalletOffence::ParticipateSigningFailed, node_id)
});
Expand Down
14 changes: 7 additions & 7 deletions state-chain/cf-integration-tests/src/swapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn get_asset_balance(who: &AccountId, asset: Asset) -> u128 {

#[test]
fn basic_pool_setup_provision_and_swap() {
super::genesis::default()
super::genesis::with_test_defaults()
.with_additional_accounts(&[
(DORIS, AccountRole::LiquidityProvider, 5 * FLIPPERINOS_PER_FLIP),
(ZION, AccountRole::Broker, 5 * FLIPPERINOS_PER_FLIP),
Expand Down Expand Up @@ -317,7 +317,7 @@ fn basic_pool_setup_provision_and_swap() {

#[test]
fn can_process_ccm_via_swap_deposit_address() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
// Setup pool and liquidity
setup_pool_and_accounts(vec![Asset::Eth, Asset::Flip]);

Expand Down Expand Up @@ -425,7 +425,7 @@ fn can_process_ccm_via_swap_deposit_address() {

#[test]
fn can_process_ccm_via_direct_deposit() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
setup_pool_and_accounts(vec![Asset::Eth, Asset::Flip]);

let gas_budget = 100;
Expand Down Expand Up @@ -517,7 +517,7 @@ fn can_process_ccm_via_direct_deposit() {

#[test]
fn failed_swaps_are_rolled_back() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
setup_pool_and_accounts(vec![Asset::Eth, Asset::Btc]);

// Get current pool's liquidity
Expand Down Expand Up @@ -676,7 +676,7 @@ fn failed_swaps_are_rolled_back() {

#[test]
fn ethereum_ccm_can_calculate_gas_limits() {
super::genesis::default().build().execute_with(|| {
super::genesis::with_test_defaults().build().execute_with(|| {
let chain_state = ChainState::<Ethereum> {
block_height: 1,
tracked_data: EthereumTrackedData {
Expand Down Expand Up @@ -745,7 +745,7 @@ fn ethereum_ccm_can_calculate_gas_limits() {
fn can_resign_failed_ccm() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down Expand Up @@ -874,7 +874,7 @@ fn can_resign_failed_ccm() {
fn can_handle_failed_vault_transfer() {
const EPOCH_BLOCKS: u32 = 1000;
const MAX_AUTHORITIES: AuthorityCount = 10;
super::genesis::default()
super::genesis::with_test_defaults()
.blocks_per_epoch(EPOCH_BLOCKS)
.max_authorities(MAX_AUTHORITIES)
.build()
Expand Down

0 comments on commit 56726f4

Please sign in to comment.