mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-09 04:21:20 +00:00
3102a04d7f
* Draft PR for the devnet automation * Committing to save for later edit * Finished creating shells, to test * Changes: * Added a shell for picking eth commands * Implemented erigon node running with the --http flag to save processes * Shell commands for get-balance and send-tx implemented TODO: * Make UX more friendly by adding start, stop and exit commands * Add progress bar to show wait in progress * Add flag or input to enable mining option for erigon node * Implemented stress tests for other eth methods * Experimenting * little clean up * lint * Transitioned to static runs and tests from shell * Finished stress test methods * Rendering fixes * save * Cleanup * Fixed lint * Still fixing lint * Removed args append ineffect * Removed println in genesis init.go * Removed println in genesis init.go Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Enrique Avila <eavilaasapche@gmail.com>
76 lines
1.9 KiB
Go
76 lines
1.9 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
|
|
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
|
|
"github.com/ledgerwatch/erigon/common"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const (
|
|
devAddress = "0x67b1d87101671b127f5f8714789C7192f7ad340e"
|
|
blockNum = "latest"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(getBalanceCmd)
|
|
rootCmd.AddCommand(getTransactionCountCmd)
|
|
}
|
|
|
|
var getBalanceCmd = &cobra.Command{
|
|
Use: "get-balance",
|
|
Short: fmt.Sprintf("Checks balance for the address: %q", devAddress),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if clearDev {
|
|
defer services.ClearDevDB()
|
|
}
|
|
callGetBalance(devAddress, blockNum, 0)
|
|
},
|
|
}
|
|
|
|
var getTransactionCountCmd = &cobra.Command{
|
|
Use: "get-transaction-count",
|
|
Short: fmt.Sprintf("Gets nonce for the address: %q", devAddress),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if clearDev {
|
|
defer services.ClearDevDB()
|
|
}
|
|
callGetTransactionCount(devAddress, blockNum, 0)
|
|
},
|
|
}
|
|
|
|
func callGetBalance(addr, blockNum string, checkBal uint64) {
|
|
fmt.Printf("Getting balance for address: %q...\n", addr)
|
|
address := common.HexToAddress(addr)
|
|
bal, err := requests.GetBalance(reqId, address, blockNum)
|
|
if err != nil {
|
|
fmt.Printf("FAILURE => %v\n", err)
|
|
return
|
|
}
|
|
|
|
if checkBal > 0 && checkBal != bal {
|
|
fmt.Printf("FAILURE => Balance should be %d, got %d\n", checkBal, bal)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("SUCCESS => Balance: %d\n", bal)
|
|
}
|
|
|
|
func callGetTransactionCount(addr, blockNum string, checkNonce uint64) {
|
|
fmt.Printf("Getting nonce for address: %q...\n", addr)
|
|
address := common.HexToAddress(addr)
|
|
nonce, err := requests.GetTransactionCountCmd(reqId, address, blockNum)
|
|
if err != nil {
|
|
fmt.Printf("FAILURE => %v\n", err)
|
|
return
|
|
}
|
|
|
|
if checkNonce > 0 && checkNonce != nonce {
|
|
fmt.Printf("FAILURE => Nonce should be %d, got %d\n", checkNonce, nonce)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("SUCCESS => Nonce: %d\n", nonce)
|
|
}
|