Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const ACCOUNT_2_BONDED_AMOUNT: u64 = 2_000_000;
const ACCOUNT_1_BALANCE: u64 = 1_000_000_000;
const ACCOUNT_2_BALANCE: u64 = 2_000_000_000;

const ACCOUNT_3_BONDED_AMOUNT: u64 = 3_000_000;

const ACCOUNT_3_BALANCE: u64 = 3_000_000_000;

static ACCOUNT_1_PUBLIC_KEY: Lazy<PublicKey> = Lazy::new(|| {
let secret_key = SecretKey::ed25519_from_bytes([42; SecretKey::ED25519_LENGTH]).unwrap();
PublicKey::from(&secret_key)
Expand All @@ -31,6 +35,11 @@ static ACCOUNT_2_PUBLIC_KEY: Lazy<PublicKey> = Lazy::new(|| {
});
static ACCOUNT_2_ADDR: Lazy<AccountHash> = Lazy::new(|| AccountHash::from(&*ACCOUNT_2_PUBLIC_KEY));

static ACCOUNT_3_PUBLIC_KEY: Lazy<PublicKey> = Lazy::new(|| {
let secret_key = SecretKey::ed25519_from_bytes([45; SecretKey::ED25519_LENGTH]).unwrap();
PublicKey::from(&secret_key)
});

static GENESIS_CUSTOM_ACCOUNTS: Lazy<Vec<GenesisAccount>> = Lazy::new(|| {
let account_1 = {
let account_1_balance = Motes::new(ACCOUNT_1_BALANCE);
Expand All @@ -56,7 +65,18 @@ static GENESIS_CUSTOM_ACCOUNTS: Lazy<Vec<GenesisAccount>> = Lazy::new(|| {
)),
)
};
vec![account_1, account_2]
let account_3 = {
let account_3_balance = Motes::new(ACCOUNT_3_BALANCE);
let account_3_bonded_amount = Motes::new(ACCOUNT_3_BONDED_AMOUNT);
GenesisAccount::Delegator {
validator_public_key: ACCOUNT_1_PUBLIC_KEY.clone(),
delegator_public_key: ACCOUNT_3_PUBLIC_KEY.clone(),
balance: account_3_balance,
delegated_amount: account_3_bonded_amount,
}
};

vec![account_1, account_2, account_3]
});

#[ignore]
Expand Down Expand Up @@ -118,6 +138,16 @@ fn should_run_genesis() {
#[ignore]
#[test]
fn should_track_total_token_supply_in_mint() {
should_track_total_token(false)
}

#[ignore]
#[test]
fn should_track_total_token_supply_in_mint_with_enable_addressable_entity() {
should_track_total_token(true)
}

fn should_track_total_token(enable_ae: bool) {
let accounts = GENESIS_CUSTOM_ACCOUNTS.clone();
let wasm_config = *DEFAULT_WASM_CONFIG;
let system_config = *DEFAULT_SYSTEM_CONFIG;
Expand All @@ -139,6 +169,7 @@ fn should_track_total_token_supply_in_mint() {
.with_unbonding_delay(unbonding_delay)
.with_genesis_timestamp_millis(genesis_timestamp)
.with_storage_costs(*DEFAULT_STORAGE_COSTS)
.with_enable_addressable_entity(enable_ae)
.build();

let genesis_request = GenesisRequest::new(
Expand All @@ -148,7 +179,9 @@ fn should_track_total_token_supply_in_mint() {
DEFAULT_CHAINSPEC_REGISTRY.clone(),
);

let mut builder = LmdbWasmTestBuilder::default();
let chainspec_config = ChainspecConfig::default().with_enable_addressable_entity(enable_ae);

let mut builder = LmdbWasmTestBuilder::new_temporary_with_config(chainspec_config);

builder.run_genesis(genesis_request);

Expand Down
2 changes: 2 additions & 0 deletions storage/src/system/genesis/account_contract_installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ where
) in genesis_delegators.iter()
{
if (*validator_public_key).clone() == public_key.clone() {
total_staked_amount += delegator_delegated_amount.value();

let purse_uref =
self.create_purse(delegator_delegated_amount.value())?;

Expand Down
1 change: 1 addition & 0 deletions storage/src/system/genesis/entity_installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ where
) in genesis_delegators.iter()
{
if (*validator_public_key).clone() == public_key.clone() {
total_staked_amount += delegator_delegated_amount.value();
let purse_uref =
self.create_purse(delegator_delegated_amount.value())?;

Expand Down