1
- import anyTest , { TestFn } from 'ava' ;
2
- import { NearAccount , Worker , getNetworkFromEnv } from '../packages/js ' ;
1
+ import anyTest , { type TestFn } from 'ava' ;
2
+ import { type NearAccount , Worker , getNetworkFromEnv } from 'near-workspaces ' ;
3
3
4
4
// The contract provided contains only one view call, returning the
5
5
// block_timestamp and epoch_height of the current block as a tuple.
6
6
// Source is here <https://github.com/near/near-workspaces-rs/blob/main/examples/simple-contract/src/lib.rs>
7
7
const contract_wasm = '__tests__/build/debug/simple_contract.wasm' ;
8
8
9
9
// Represents the timestamp and epoch_height result from the view call.
10
- type EnvData = [ number , number ] ;
10
+ type EnvironmentData = [ number , number ] ;
11
11
12
12
if ( getNetworkFromEnv ( ) === 'sandbox' ) {
13
13
const test = anyTest as TestFn < {
@@ -25,15 +25,15 @@ if (getNetworkFromEnv() === 'sandbox') {
25
25
} ) ;
26
26
27
27
test . afterEach . always ( async t => {
28
- await t . context . worker . tearDown ( ) . catch ( error => {
28
+ await t . context . worker . tearDown ( ) . catch ( ( error : unknown ) => {
29
29
console . log ( 'Failed to tear down the worker:' , error ) ;
30
30
} ) ;
31
31
} ) ;
32
32
33
33
test ( 'Fast Forward' , async t => {
34
34
const before = await t . context . contract . view ( 'current_env_data' ) ;
35
- const env_before = before as EnvData ;
36
- console . log ( `Before: timestamp = ${ env_before [ 0 ] } , epoch_height = ${ env_before [ 1 ] } ` ) ;
35
+ const environmentBefore = before as EnvironmentData ;
36
+ console . log ( `Before: timestamp = ${ environmentBefore [ 0 ] } , epoch_height = ${ environmentBefore [ 1 ] } ` ) ;
37
37
38
38
const forward_height = 10_000 ;
39
39
@@ -42,8 +42,8 @@ if (getNetworkFromEnv() === 'sandbox') {
42
42
await t . context . worker . provider . fastForward ( forward_height ) ;
43
43
44
44
const after = await t . context . contract . view ( 'current_env_data' ) ;
45
- const env_after = after as EnvData ;
46
- console . log ( `After: timestamp = ${ env_after [ 0 ] } , epoch_height = ${ env_after [ 1 ] } ` ) ;
45
+ const environmentAfter = after as EnvironmentData ;
46
+ console . log ( `After: timestamp = ${ environmentAfter [ 0 ] } , epoch_height = ${ environmentAfter [ 1 ] } ` ) ;
47
47
48
48
const block = await t . context . worker . provider . block ( { finality : 'final' } ) ;
49
49
0 commit comments