-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36f2cf6
commit 5226842
Showing
2 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import anyTest from '@endo/ses-ava/prepare-endo.js'; | ||
import type { TestFn } from 'ava'; | ||
import { getTimeout } from '../../tools/ibc-transfer.js'; | ||
import { | ||
NANOSECONDS_PER_MILLISECOND, | ||
SECONDS_PER_MINUTE, | ||
MILLISECONDS_PER_SECOND, | ||
} from '@agoric/orchestration/src/utils/time.js'; | ||
|
||
const test = anyTest as TestFn<Record<string, never>>; | ||
|
||
const minutesInFuture = (now: bigint, minutes = 5n) => | ||
now + minutes * SECONDS_PER_MINUTE * MILLISECONDS_PER_SECOND; | ||
|
||
test('getTimeout returns nanoseconds 5 minutes in the future', async t => { | ||
const now = Date.now(); | ||
const fiveMinutesInFuture = minutesInFuture(BigInt(now)); | ||
|
||
const timeout = getTimeout(now); | ||
const timeoutInMS = timeout / NANOSECONDS_PER_MILLISECOND; | ||
t.is(fiveMinutesInFuture, timeoutInMS); | ||
}); | ||
|
||
test('getTimeout accepts minutes in future for 2nd arg', async t => { | ||
const now = Date.now(); | ||
const twoMinutesInFuture = minutesInFuture(BigInt(now), 2n); | ||
|
||
const timeout = getTimeout(now, 2n); | ||
const timeoutInMS = timeout / NANOSECONDS_PER_MILLISECOND; | ||
t.is(twoMinutesInFuture, timeoutInMS); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters