Skip to content

Commit 693699a

Browse files
Add check for deploy tx (#24)
- if deploys of the test contract don't work, please don't just march forward
1 parent a840c77 commit 693699a

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

generator/scenarios/base.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package scenarios
22

33
import (
4+
"context"
5+
"fmt"
6+
"log"
47
"math/big"
8+
"time"
59

610
"github.com/ethereum/go-ethereum/accounts/abi/bind"
711
"github.com/ethereum/go-ethereum/common"
@@ -174,11 +178,29 @@ func (c *ContractScenarioBase[T]) DeployScenario(config *config.LoadConfig, depl
174178
}
175179

176180
// Deploy using contract-specific logic
177-
address, _, err := c.deployer.DeployContract(auth, client)
181+
address, tx, err := c.deployer.DeployContract(auth, client)
178182
if err != nil {
179183
panic("Failed to deploy contract: " + err.Error())
180184
}
181185

186+
log.Printf("📤 Deployment transaction sent: %s", tx.Hash().Hex())
187+
188+
// Wait for the deployment transaction to be mined
189+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
190+
defer cancel()
191+
192+
receipt, err := bind.WaitMined(ctx, client, tx)
193+
if err != nil {
194+
panic(fmt.Sprintf("Failed to wait for deployment transaction to be mined: %v", err))
195+
}
196+
197+
// Check if deployment was successful
198+
if receipt.Status != ethtypes.ReceiptStatusSuccessful {
199+
panic(fmt.Sprintf("Deployment transaction failed with status %d (tx: %s)", receipt.Status, tx.Hash().Hex()))
200+
}
201+
202+
log.Printf("✅ Deployment successful at block %d (gas used: %d)", receipt.BlockNumber.Uint64(), receipt.GasUsed)
203+
182204
// Bind contract instance using the provided bind function
183205
bindFunc := c.deployer.GetBindFunc()
184206
contract, err := bindFunc(address, client)

0 commit comments

Comments
 (0)