2022-10-11 12:34:32 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-01-12 02:58:21 +00:00
|
|
|
|
2022-10-11 12:34:32 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/models"
|
2023-01-10 17:43:58 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/services"
|
2023-05-20 20:57:32 +00:00
|
|
|
"github.com/ledgerwatch/log/v3"
|
2022-10-11 12:34:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ExecuteAllMethods runs all the simulation tests for erigon devnet
|
2023-05-20 20:57:32 +00:00
|
|
|
func ExecuteAllMethods(logger log.Logger) {
|
2022-10-11 12:34:32 +00:00
|
|
|
// test connection to JSON RPC
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("PINGING JSON RPC...")
|
2023-05-20 20:57:32 +00:00
|
|
|
if err := pingErigonRpc(logger); err != nil {
|
2022-11-03 02:45:36 +00:00
|
|
|
return
|
|
|
|
}
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("")
|
2022-10-11 12:34:32 +00:00
|
|
|
|
|
|
|
// get balance of the receiver's account
|
2023-05-20 20:57:32 +00:00
|
|
|
callGetBalance(addr, models.Latest, 0, logger)
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("")
|
2022-10-11 12:34:32 +00:00
|
|
|
|
2022-10-31 10:46:49 +00:00
|
|
|
// confirm that the txpool is empty
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("CONFIRMING TXPOOL IS EMPTY BEFORE SENDING TRANSACTION...")
|
2023-05-20 20:57:32 +00:00
|
|
|
services.CheckTxPoolContent(0, 0, 0, logger)
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("")
|
2022-10-31 10:46:49 +00:00
|
|
|
|
2022-11-22 13:28:53 +00:00
|
|
|
/*
|
|
|
|
* Cannot run contract tx after running regular tx because contract tx simulates a new backend
|
|
|
|
* and it expects the nonce to be 0.
|
|
|
|
* So it is best to run them separately by commenting and uncommenting the different code blocks.
|
|
|
|
*/
|
|
|
|
|
2022-10-31 10:46:49 +00:00
|
|
|
// send a token from the dev address to the recipient address
|
2023-01-10 17:43:58 +00:00
|
|
|
//_, err := callSendTx(sendValue, recipientAddress, models.DevAddress)
|
2022-11-22 13:28:53 +00:00
|
|
|
//if err != nil {
|
|
|
|
// fmt.Printf("callSendTx error: %v\n", err)
|
|
|
|
// return
|
|
|
|
//}
|
|
|
|
//fmt.Println()
|
|
|
|
|
2023-05-20 20:57:32 +00:00
|
|
|
_, err := callSendTxWithDynamicFee(recipientAddress, models.DevAddress, logger)
|
2022-11-03 02:45:36 +00:00
|
|
|
if err != nil {
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Error("callSendTxWithDynamicFee", "error", err)
|
2022-11-03 02:45:36 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
fmt.Println()
|
2023-01-16 18:59:01 +00:00
|
|
|
|
2023-03-02 10:25:11 +00:00
|
|
|
// initiate a contract transaction
|
|
|
|
//fmt.Println("INITIATING A CONTRACT TRANSACTION...")
|
|
|
|
//_, err := callContractTx()
|
|
|
|
//if err != nil {
|
|
|
|
// fmt.Printf("callContractTx error: %v\n", err)
|
|
|
|
// return
|
|
|
|
//}
|
|
|
|
//fmt.Println()
|
|
|
|
|
2023-05-22 07:46:50 +00:00
|
|
|
logger.Info("SEND SIGNAL TO QUIT ALL RUNNING NODES")
|
2023-01-16 18:59:01 +00:00
|
|
|
models.QuitNodeChan <- true
|
2022-10-11 12:34:32 +00:00
|
|
|
}
|