Skip to content

Commit

Permalink
Doc: test functions with simulated block time
Browse files Browse the repository at this point in the history
  • Loading branch information
polarker committed Jan 26, 2024
1 parent 30d4730 commit 31a09c9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/dapps/dapp-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ const subscription = tokenFaucet.subscribeWithdrawEvent(options, fromEventCount)
subscription.unsubscribe()
```

### Test functions with simulated block time

It's possible to test functions with simulated block time in unit tests. For integration tests based on testnet or devnet, there is no way to change the block time though.

Here is a simple example:

```typescript
import { TokenFaucet } from 'artifacts/ts'

const result = await TokenFaucet.tests.withdraw({
blockTimeStamp: 1706284941000, // the unit is millisecond
address: ...,
initialFields: ...,
...
})
```

## Transaction

### Query transaction status
Expand Down

0 comments on commit 31a09c9

Please sign in to comment.