Skip to content

Commit 2eab00c

Browse files
committedApr 1, 2024·
update tests
1 parent c594b30 commit 2eab00c

10 files changed

+24
-10
lines changed
 

‎__tests__/asset.test.ts ‎eosiolib/asset.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { asset, symbol, Asset, asset_to_number } from "..";
1+
import { asset, symbol, Asset, asset_to_number } from "../dist";
22
import bigInt from "big-integer";
33

44
const asset_mask = (bigInt(1).shiftLeft(62)).minus(1);

‎__tests__/eosiolib.test.ts ‎eosiolib/eosiolib.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { write_decimal } from "..";
1+
import { write_decimal } from "../dist";
22
import bigInt from "big-integer";
33

44
test("eosiolib.write_decimal", () => {

‎__tests__/extended_asset.test.ts ‎eosiolib/extended_asset.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { name, extended_symbol, extended_asset, asset, symbol, ExtendedAsset } from "..";
1+
import { name, extended_symbol, extended_asset, asset, symbol, ExtendedAsset } from "../dist";
22
import bigInt from "big-integer";
33

44
const asset_mask = (bigInt(1).shiftLeft(62)).minus(1);

‎__tests__/extended_symbol.test.ts ‎eosiolib/extended_symbol.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { name, symbol, extended_symbol, ExtendedSymbol } from ".."
1+
import { name, symbol, extended_symbol, ExtendedSymbol } from "../dist"
22
import bigInt from "big-integer";
33

44
// const u64min = 0n;

‎__tests__/name.test.ts ‎eosiolib/name.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { name, Name } from "../";
1+
import { name, Name } from "../dist";
22
import bigInt from "big-integer";
33

44
// const u64min = 0n;

‎__tests__/symbol.test.ts ‎eosiolib/symbol.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { symbol, symbol_code, Sym } from "..";
1+
import { symbol, symbol_code, Sym } from "../dist";
22
import bigInt from "big-integer";
33

44
// const u64min = 0n;

‎__tests__/symbol_code.test.ts ‎eosiolib/symbol_code.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { symbol_code, SymbolCode } from "..";
1+
import { symbol_code, SymbolCode } from "../dist";
22
import bigInt from "big-integer";
33

44
test("symbol_code::from", () => {

‎__tests__/utils.test.ts ‎eosiolib/utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { number_to_asset, asset_to_number, asset_to_precision, symbol } from "../";
1+
import { number_to_asset, asset_to_number, asset_to_precision, symbol } from "../dist";
22
import bigInt from "big-integer";
33

44
test("utils", () => {

‎eosiolib/voting.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { stake2vote, vote2stake, voteWeightToday } from "../dist";
2+
3+
test("voting", () => {
4+
expect( voteWeightToday() ).toBe(24.326923076923077)
5+
});
6+
7+
test("vote2stake", () => {
8+
expect( vote2stake(1889616753629566208) ).toBe(89792524624.84131)
9+
});
10+
11+
test("stake2vote", () => {
12+
expect( stake2vote(89792524624.84131) ).toBe(1889616753629566200)
13+
});

‎eosiolib/voting.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
*/
44
export function voteWeightToday(): number {
55
const seconds_per_day = 86400;
6-
const block_timestamp_epoch = new Date(Date.UTC(2000, 0, 1, 0, 0, 0, 0)).getTime();
6+
const block_timestamp_epoch = new Date(Date.UTC(2000, 0, 1, 0, 0, 0, 0)).getTime() / 1000;
7+
const now = Date.now() / 1000;
78

8-
return Math.floor( (Date.now() - block_timestamp_epoch) / 1000 / (seconds_per_day * 7)) / 52;
9+
return Math.floor((now - block_timestamp_epoch) / (seconds_per_day * 7)) / 52;
910
}
1011

1112
/**

0 commit comments

Comments
 (0)
Please sign in to comment.