File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ import { Kintsugi } from '@interlay/monetary-js' ;
3+ import { Keyring } from '@polkadot/api' ;
4+ import { createSubstrateAPI , FaucetClient } from '../src' ;
5+
6+ const PARACHAIN_ENDPOINT = "wss://api-kusama.interlay.io/parachain" ;
7+ const FAUCET_URL = "http://localhost:3033" ;
8+
9+ // The script throws an error but does what it should
10+ main ( ) . catch ( ( err ) => {
11+ console . log ( "Error thrown by script:" ) ;
12+ console . log ( err ) ;
13+ } ) ;
14+
15+ /**
16+ * Flood the faucet with `users` requests to see if it breaks
17+ */
18+ async function main ( ) {
19+ const keyring = new Keyring ( { type : "sr25519" } ) ;
20+ const api = await createSubstrateAPI ( PARACHAIN_ENDPOINT ) ;
21+ const faucet = new FaucetClient ( api , FAUCET_URL ) ;
22+ const salt = Math . random ( ) . toString ( ) ;
23+ const users = 100 ;
24+ const promises = [ ] ;
25+ for ( let i = 0 ; i < users ; i ++ ) {
26+ const account = keyring . addFromUri ( `//${ salt + i . toString ( ) } ` ) ;
27+ console . log ( account . address ) ;
28+ const accountId = api . createType ( "AccountId" , account . address ) ;
29+ promises . push (
30+ faucet . fundAccount ( accountId , Kintsugi )
31+ ) ;
32+ }
33+ console . log ( `Making ${ users } simulatenous faucet requests...` ) ;
34+ await Promise . all ( promises ) ;
35+ console . log ( "Finished" ) ;
36+ }
You can’t perform that action at this time.
0 commit comments