Skip to content

Commit

Permalink
chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Aug 26, 2023
1 parent 31bb373 commit 16e661c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 102 deletions.
12 changes: 5 additions & 7 deletions lib/fortuna.ak
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ fn find_first_nonzero_byte(bytes: ByteArray, current_index) -> Int {
}
}

// TODO add some tests for previous 2 functions

fn do_two_exponential(exponent: Int) -> Int {
if exponent <= 0 {
1
Expand Down Expand Up @@ -137,19 +135,19 @@ pub fn get_difficulty_adjustment(total_epoch_time: Int) -> (Int, Int) {
}

test get_difficulty_adjustment_1() {
get_difficulty_adjustment(1209600) == (1209600, 1209600)
get_difficulty_adjustment(1_209_600_000) == (1_209_600_000, 1_209_600_000)
}

test get_difficulty_adjustment_2() {
get_difficulty_adjustment(1200600) == (1200600, 1209600)
get_difficulty_adjustment(1_200_600_000) == (1_200_600_000, 1_209_600_000)
}

test get_difficulty_adjustment_3() {
get_difficulty_adjustment(50000000) == (4, 1)
get_difficulty_adjustment(50_000_000_000) == (4, 1)
}

test get_difficulty_adjustment_4() {
get_difficulty_adjustment(200000) == (1, 4)
get_difficulty_adjustment(200_000_000) == (1, 4)
}

pub fn get_new_difficulty(
Expand Down Expand Up @@ -205,7 +203,7 @@ test get_new_difficulty_6() {
}

test get_new_difficulty_7() {
get_new_difficulty(9000, 60, 1, 3) == (4096, 60)
get_new_difficulty(9000, 62, 1, 3) == (4096, 62)
}

test get_new_difficulty_8() {
Expand Down
2 changes: 1 addition & 1 deletion lib/fortuna/parameters.ak
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub const halving_number = 210000

pub const epoch_number = 2016

pub const epoch_target = 12_096_000_000
pub const epoch_target = 1_209_600_000

pub const initial_payout = 5000000000

Expand Down
89 changes: 0 additions & 89 deletions lib/fortuna/unused_relics.ak

This file was deleted.

2 changes: 1 addition & 1 deletion miner/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const mine = new Command()
if (
state.fields[0] as bigint % 2016n === 0n && state.fields[0] as bigint > 0
) {
const adjustment = getDifficultyAdjustement(epoch_time, 12_096_000_000n);
const adjustment = getDifficultyAdjustement(epoch_time, 1_209_600_000n);

epoch_time = 0n;

Expand Down
Loading

0 comments on commit 16e661c

Please sign in to comment.