-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add option to time-travel to a specific timestamp (#114)
* add option to time-travel to a specific timestamp
- Loading branch information
1 parent
38dc60a
commit 3910af5
Showing
11 changed files
with
167 additions
and
67 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
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
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 { chain, setupApi, ws } from './helper' | ||
import { describe, expect, it } from 'vitest' | ||
import { getCurrentTimestamp, getSlotDuration, timeTravel } from '../src/utils/time-travel' | ||
|
||
describe.each([ | ||
{ | ||
chain: 'Polkadot', | ||
endpoint: 'wss://rpc.polkadot.io', | ||
blockHash: '0xb7fb7cfe79142652036e73f8044e0efbbbe7d3fb71cabc212efd5968c9041950', | ||
}, | ||
{ | ||
chain: 'Acala', | ||
endpoint: 'wss://acala-rpc-1.aca-api.network', | ||
blockHash: '0x1d9223c88161b512ebaac53c2c7df6dc6bd2731b12273b898f582af929cc5331', | ||
}, | ||
])('Can time-travel on $chain', async ({ endpoint, blockHash }) => { | ||
setupApi({ endpoint, blockHash }) | ||
|
||
it.each(['Nov 30, 2022', 'Dec 22, 2022', 'Jan 1, 2024'])('%s', async (date) => { | ||
const timestamp = Date.parse(date) | ||
|
||
await timeTravel(chain, timestamp) | ||
|
||
expect(await getCurrentTimestamp(chain)).eq(timestamp) | ||
|
||
// can build block successfully | ||
await ws.send('dev_newBlock', []) | ||
|
||
expect(await getCurrentTimestamp(chain)).eq(timestamp + (await getSlotDuration(chain))) | ||
}) | ||
}) |
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
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
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
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
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
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
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
Oops, something went wrong.