Skip to content

Commit

Permalink
patch issues with smoke test initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Oct 26, 2023
1 parent 850c22d commit 2c5e0ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions framework/libra-framework/sources/ol_sources/libra_coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ module ol_framework::gas_coin {
/// FOR TESTS ONLY
/// Can only called during genesis to initialize the Diem coin.
public(friend) fun initialize_for_core(diem_framework: &signer):
(BurnCapability<LibraCoin>, MintCapability<LibraCoin>) {
(BurnCapability<LibraCoin>, MintCapability<LibraCoin>) acquires FinalMint {
system_addresses::assert_diem_framework(diem_framework);

let (burn_cap, freeze_cap, mint_cap) = coin::initialize_with_parallelizable_supply<LibraCoin>(
Expand All @@ -196,6 +196,9 @@ module ol_framework::gas_coin {

coin::destroy_freeze_cap(freeze_cap);

genesis_set_final_supply(diem_framework, 100); // TODO: set this number
// in testnets

(burn_cap, mint_cap)
}

Expand Down Expand Up @@ -254,7 +257,17 @@ module ol_framework::gas_coin {
public fun supply(): u64 {
let supply_opt = coin::supply<LibraCoin>();
if (option::is_some(&supply_opt)) {
return (*option::borrow(&supply_opt) as u64)
let value = *option::borrow(&supply_opt);
if (value == 0) return 0u64;
return (value as u64)
};
0
}

public fun supply_128(): u128 {
let supply_opt = coin::supply<LibraCoin>();
if (option::is_some(&supply_opt)) {
return *option::borrow(&supply_opt)
};
0
}
Expand Down Expand Up @@ -330,6 +343,9 @@ module ol_framework::gas_coin {
let mint_cap = &borrow_global<MintCapStore>(account_addr).mint_cap;
let coins_minted = coin::mint<LibraCoin>(amount, mint_cap);
coin::deposit<LibraCoin>(dst_addr, coins_minted);

// TODO: update the final supply for tests
// genesis_set_final_supply(root, supply());
}

#[test_only]
Expand Down
Binary file modified framework/releases/head.mrb
Binary file not shown.
4 changes: 2 additions & 2 deletions smoke-tests/src/libra_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ impl LibraSmoke {
// the genesis does NOT mint by default to genesis validators
// 10,000 coins with 6 decimals precision
let mut pub_info = swarm.diem_public_info();
helpers::mint_libra(&mut pub_info, addr, 100_000_000_000).await?;
helpers::mint_libra(&mut pub_info, addr, 100_000_000_000).await.context("could not mint to account")?;

helpers::unlock_libra(&mut pub_info, addr, 100_000_000_000).await?;
helpers::unlock_libra(&mut pub_info, addr, 100_000_000_000).await.context("could not unlock coins")?;

Ok(Self {
swarm,
Expand Down
Binary file modified tools/genesis/tests/fixtures/genesis.blob
Binary file not shown.

0 comments on commit 2c5e0ba

Please sign in to comment.