From 06b09e2dfce695dcef9f300ce6b1840ee2cae787 Mon Sep 17 00:00:00 2001 From: Steven Landers Date: Mon, 6 Oct 2025 14:42:28 -0400 Subject: [PATCH] add check for deploy tx --- generator/scenarios/base.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/generator/scenarios/base.go b/generator/scenarios/base.go index 427da02..3dfe92b 100644 --- a/generator/scenarios/base.go +++ b/generator/scenarios/base.go @@ -1,7 +1,11 @@ package scenarios import ( + "context" + "fmt" + "log" "math/big" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -174,11 +178,29 @@ func (c *ContractScenarioBase[T]) DeployScenario(config *config.LoadConfig, depl } // Deploy using contract-specific logic - address, _, err := c.deployer.DeployContract(auth, client) + address, tx, err := c.deployer.DeployContract(auth, client) if err != nil { panic("Failed to deploy contract: " + err.Error()) } + log.Printf("📤 Deployment transaction sent: %s", tx.Hash().Hex()) + + // Wait for the deployment transaction to be mined + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + receipt, err := bind.WaitMined(ctx, client, tx) + if err != nil { + panic(fmt.Sprintf("Failed to wait for deployment transaction to be mined: %v", err)) + } + + // Check if deployment was successful + if receipt.Status != ethtypes.ReceiptStatusSuccessful { + panic(fmt.Sprintf("Deployment transaction failed with status %d (tx: %s)", receipt.Status, tx.Hash().Hex())) + } + + log.Printf("✅ Deployment successful at block %d (gas used: %d)", receipt.BlockNumber.Uint64(), receipt.GasUsed) + // Bind contract instance using the provided bind function bindFunc := c.deployer.GetBindFunc() contract, err := bindFunc(address, client)