8000 chore: add timer utils by suraneti · Pull Request #143 · maticnetwork/matic-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: add timer utils #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/express-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import { cleanup } from './express/commands/cleanup'
import { setupDatadog } from './express/commands/setup-datadog'
import { chaos } from './express/commands/chaos'
import { checkDir } from './express/common/files-utils'
import { timer } from './express/common/time-utils'
import { program } from 'commander'
import pkg from '../package.json'
import { testEip1559 } from '../tests/test-eip-1559'
import { stopInstances } from './express/commands/instances-stop'
import { startInstances } from './express/commands/instances-start'

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

program
.option('-i, --init', 'Initiate the terraform setup')
.option('-s, --start', 'Start the setup')
Expand Down
4 changes: 2 additions & 2 deletions src/express/commands/chaos.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable dot-notation */
import { loadDevnetConfig, splitToArray } from '../common/config-utils'
import { timer } from '../common/time-utils'

const {
runScpCommand,
runSshCommand,
maxRetries,
runSshCommandWithoutExit
} = require('../common/remote-worker')

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

async function removeAllPeers(ip, staticNodes) {
let command = 'mv ~/.bor/static-nodes.json ~/.bor/static-nodes.json_bkp'
try {
Expand Down
3 changes: 1 addition & 2 deletions src/express/commands/cleanup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { loadDevnetConfig, splitToArray } from '../common/config-utils'
import { maxRetries, runSshCommand } from '../common/remote-worker'

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
import { timer } from '../common/time-utils'

export async function cleanup() {
require('dotenv').config({ path: `${process.cwd()}/.env` })
Expand Down
3 changes: 1 addition & 2 deletions src/express/commands/instances-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import { loadDevnetConfig } from '../common/config-utils'
import { restartAll } from './restart'
import { maxRetries, runSshCommand } from '../common/remote-worker'
import { timer } from '../common/time-utils'

const shell = require('shelljs')

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

async function startGanache(doc) {
const ip = `${doc.ethHostUser}@${doc.devnetBorHosts[0]}`
console.log('📍Running ganache in machine ' + ip + ' ...')
Expand Down
3 changes: 1 addition & 2 deletions src/express/commands/instances-stop.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// noinspection JSUnresolvedFunction

import { loadDevnetConfig } from '../common/config-utils'
import { timer } from '../common/time-utils'

const shell = require('shelljs')

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

export async function stopInstances() {
console.log('📍Stopping instances...')
require('dotenv').config({ path: `${process.cwd()}/.env` })
Expand Down
2 changes: 1 addition & 1 deletion 2 src/express/commands/monitor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// noinspection JSCheckFunctionSignatures,JSUnresolvedFunction,JSUnresolvedVariable

import { loadDevnetConfig } from '../common/config-utils'
import { timer } from '../common/time-utils'

const fetch = require('node-fetch')
const Web3 = require('web3')
const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
const { runScpCommand, maxRetries } = require('../common/remote-worker')

const lastStateIdABI = [
Expand Down
3 changes: 1 addition & 2 deletions src/express/commands/setup-datadog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// noinspection JSCheckFunctionSignatures,JSUnresolvedVariable

import { loadDevnetConfig, splitToArray } from '../common/config-utils'
import { timer } from '../common/time-utils'

const {
runScpCommand,
Expand All @@ -12,8 +13,6 @@ const { installDocker } = require('./start.js')
const yaml = require('js-yaml')
const fs = require('fs')

const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

export async function setDatadogAPIKey(value, doc) {
if (value !== undefined) {
doc.exporters.datadog.api.key = value
Expand Down
2 changes: 1 addition & 1 deletion src/express/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
runScpCommand,
runSshCommand
} from '../common/remote-worker'
import { timer } from '../common/time-utils'
import yaml from 'js-yaml'
import fs from 'fs'

const shell = require('shelljs')
const timer = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

async function terraformApply(devnetId) {
console.log('📍Executing terraform apply...')
Expand Down
3 changes: 3 additions & 0 deletions src/express/common/time-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function timer(ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
0