Skip to content

Commit

Permalink
fix(geometric_example_test): start anvil container
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Jul 15, 2024
1 parent 60ca447 commit cd72d9b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions chainio/txmgr/geometric_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,35 @@ import (
"github.com/Layr-Labs/eigensdk-go/chainio/gasoracle"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/signerv2"
"github.com/Layr-Labs/eigensdk-go/testutils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/prometheus/client_golang/prometheus"
)

var (
rpcUrl = "http://localhost:8545"
chainid = big.NewInt(31337)
)

func ExampleGeometricTxManager() {
anvilC, err := testutils.StartAnvilContainer("")
if err != nil {
panic(err)
}
anvilUrl, err := anvilC.Endpoint(context.TODO(), "http")
if err != nil {
panic(err)
}

ecdsaPrivateKey, err := crypto.HexToECDSA("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
if err != nil {
panic(err)
}
pk := ecdsaPrivateKey.PublicKey
address := crypto.PubkeyToAddress(pk)

client, txmgr := createTxMgr(ecdsaPrivateKey)
client, txmgr := createTxMgr(anvilUrl, ecdsaPrivateKey)

tx := createTx(client, address)
_, err = txmgr.Send(context.TODO(), tx)
Expand All @@ -56,7 +65,7 @@ func createTx(client eth.Client, address common.Address) *types.Transaction {
})
}

func createTxMgr(ecdsaPrivateKey *ecdsa.PrivateKey) (eth.Client, *GeometricTxManager) {
func createTxMgr(rpcUrl string, ecdsaPrivateKey *ecdsa.PrivateKey) (eth.Client, *GeometricTxManager) {
logger := logging.NewTextSLogger(os.Stdout, &logging.SLoggerOptions{})
client, err := eth.NewClient(rpcUrl)
if err != nil {
Expand Down

0 comments on commit cd72d9b

Please sign in to comment.