Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Apr 1, 2024
1 parent c594b30 commit 2eab00c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion __tests__/asset.test.ts → eosiolib/asset.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { asset, symbol, Asset, asset_to_number } from "..";
import { asset, symbol, Asset, asset_to_number } from "../dist";
import bigInt from "big-integer";

const asset_mask = (bigInt(1).shiftLeft(62)).minus(1);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/eosiolib.test.ts → eosiolib/eosiolib.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { write_decimal } from "..";
import { write_decimal } from "../dist";
import bigInt from "big-integer";

test("eosiolib.write_decimal", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { name, extended_symbol, extended_asset, asset, symbol, ExtendedAsset } from "..";
import { name, extended_symbol, extended_asset, asset, symbol, ExtendedAsset } from "../dist";
import bigInt from "big-integer";

const asset_mask = (bigInt(1).shiftLeft(62)).minus(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { name, symbol, extended_symbol, ExtendedSymbol } from ".."
import { name, symbol, extended_symbol, ExtendedSymbol } from "../dist"
import bigInt from "big-integer";

// const u64min = 0n;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/name.test.ts → eosiolib/name.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { name, Name } from "../";
import { name, Name } from "../dist";
import bigInt from "big-integer";

// const u64min = 0n;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/symbol.test.ts → eosiolib/symbol.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { symbol, symbol_code, Sym } from "..";
import { symbol, symbol_code, Sym } from "../dist";
import bigInt from "big-integer";

// const u64min = 0n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { symbol_code, SymbolCode } from "..";
import { symbol_code, SymbolCode } from "../dist";
import bigInt from "big-integer";

test("symbol_code::from", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils.test.ts → eosiolib/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { number_to_asset, asset_to_number, asset_to_precision, symbol } from "../";
import { number_to_asset, asset_to_number, asset_to_precision, symbol } from "../dist";
import bigInt from "big-integer";

test("utils", () => {
Expand Down
13 changes: 13 additions & 0 deletions eosiolib/voting.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { stake2vote, vote2stake, voteWeightToday } from "../dist";

test("voting", () => {
expect( voteWeightToday() ).toBe(24.326923076923077)
});

test("vote2stake", () => {
expect( vote2stake(1889616753629566208) ).toBe(89792524624.84131)
});

test("stake2vote", () => {
expect( stake2vote(89792524624.84131) ).toBe(1889616753629566200)
});
5 changes: 3 additions & 2 deletions eosiolib/voting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
export function voteWeightToday(): number {
const seconds_per_day = 86400;
const block_timestamp_epoch = new Date(Date.UTC(2000, 0, 1, 0, 0, 0, 0)).getTime();
const block_timestamp_epoch = new Date(Date.UTC(2000, 0, 1, 0, 0, 0, 0)).getTime() / 1000;
const now = Date.now() / 1000;

return Math.floor( (Date.now() - block_timestamp_epoch) / 1000 / (seconds_per_day * 7)) / 52;
return Math.floor((now - block_timestamp_epoch) / (seconds_per_day * 7)) / 52;
}

/**
Expand Down

0 comments on commit 2eab00c

Please sign in to comment.