Skip to content

Commit

Permalink
all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Sep 30, 2024
1 parent 520957c commit f136275
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ module ol_framework::proof_of_fee {
// TODO: make this it's own function so it can be publicly callable, it's useful generally, and for debugging.

let valid = secret_bid::has_valid_bid(val);

if (!valid) vector::push_back(&mut errors, EBID_EXPIRED); // 16
// skip the user if they don't have sufficient UNLOCKED funds
// or if the bid expired.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module ol_framework::test_pof {
use diem_framework::chain_id;
use std::vector;

use diem_std::debug::print;
// use diem_std::debug::print;

const Alice: address = @0x1000a;
const Bob: address = @0x1000b;
Expand Down Expand Up @@ -299,19 +299,21 @@ module ol_framework::test_pof {
let set = mock::genesis_n_vals(&root, 4);
mock::ol_initialize_coin_and_fund_vals(&root, 10000, true);

let alice_sig = account::create_signer_for_test(@0x10001);
let alice_addr = *vector::borrow(&set, 0);
let alice_sig = account::create_signer_for_test(alice_addr);
secret_bid::mock_revealed_bid(&root, &alice_sig, 55, 10);
print(&secret_bid::has_valid_bid(@0x10001));
assert!(secret_bid::has_valid_bid(alice_addr) == false, 7357001);

// Get all vals but don't filter the ones that have passing bids
// Get all bidders, but don't run audit
let sorted = proof_of_fee::get_bidders(false);
let bids_len = vector::length(&sorted);
assert!(bids_len == vector::length(&set), 1000);

// now filter for expired bids, should have one missing
let sorted_audit = proof_of_fee::get_bidders(true);

let sorted_two = proof_of_fee::get_bidders(true);
assert!(vector::length(&sorted_two) != vector::length(&set), 1004);
assert!(vector::length(&sorted_two) == vector::length(&set) - 1, 1005);
assert!(vector::length(&sorted_audit) != vector::length(&set), 1004);
assert!(vector::length(&sorted_audit) == vector::length(&set) - 1, 1005);
}

// We can send the fill seats function a list of validators, and the list of performing validators, and it will return the winning bidders and the bid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module ol_framework::test_reconfiguration {
use ol_framework::epoch_helper;
use ol_framework::ol_account;

use diem_std::debug::print;
// use diem_std::debug::print;

// Scenario: all genesis validators make it to next epoch
#[test(root = @ol_framework)]
Expand Down Expand Up @@ -51,44 +51,37 @@ module ol_framework::test_reconfiguration {

#[test(root = @ol_framework)]
fun drop_non_performing(root: signer) {
let _vals = mock::genesis_n_vals(&root, 5);
mock::pof_default(&root);
let vals = mock::genesis_n_vals(&root, 5);
let alice = *vector::borrow(&vals, 0);

assert!(libra_coin::balance(@0x1000a) == 0, 7357000);
assert!(libra_coin::balance(alice) == 0, 7357000);

// NOTE: epoch 0 and 1 are a special case, we don't run performance grades on that one. Need to move two epochs ahead
reconfiguration::test_helper_increment_epoch_dont_reconfigure(1);
reconfiguration::test_helper_increment_epoch_dont_reconfigure(1);

// epoch changed, need new valid bids
mock::pof_default(&root);

assert!(epoch_helper::get_current_epoch() == 2, 7357001);

let vals = stake::get_current_validators();
assert!(vector::length(&vals) == 5, 7357002);

// all vals compliant
mock::mock_all_vals_good_performance(&root);

// make alice non performant
mock::mock_case_4(&root, @0x1000a);

let (reward, _, _, _ ) = proof_of_fee::get_consensus_reward();
mock::mock_case_4(&root, alice);

// run ol reconfiguration
mock::trigger_epoch(&root);

let vals = stake::get_current_validators();

// one validator missing.
print(&vector::length(&vals));
let vals = stake::get_current_validators();
assert!(vector::length(&vals) == 4, 7357003);
assert!(!vector::contains(&vals, &@0x1000a), 7357004);

let (_, entry_fee, _, _ ) = proof_of_fee::get_consensus_reward();
assert!(!vector::contains(&vals, &alice), 7357004);

// alice doesn't get paid
assert!(libra_coin::balance(@0x1000a) == 0, 7357005);
// bob does
assert!(libra_coin::balance(@0x1000b) == (reward - entry_fee), 7357006);
}


Expand Down

0 comments on commit f136275

Please sign in to comment.