Skip to content

Commit aff3672

Browse files
committed
more tests, fix lint
1 parent de1595a commit aff3672

4 files changed

Lines changed: 42 additions & 31 deletions

File tree

chain/evm/provider/confirm_functor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func ConfirmFuncGeth(waitMinedTimeout time.Duration, opts ...func(*confirmFuncGe
3434
for _, o := range opts {
3535
o(cf)
3636
}
37+
3738
return cf
3839
}
3940

chain/evm/provider/confirm_functor_test.go

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,47 @@ func Test_ConfirmFuncGeth_ConfirmFunc(t *testing.T) {
3939
adminTransactor.From: {Balance: prefundAmountWei},
4040
}
4141

42-
tests := []struct {
43-
name string
44-
giveTx func(*testing.T, *SimClient) *types.Transaction
45-
wantErr string
46-
}{
47-
{
48-
name: "successful confirmation",
49-
giveTx: func(t *testing.T, client *SimClient) *types.Transaction {
50-
t.Helper()
42+
defaultConfirmFunc := func(t *testing.T, client *SimClient) *types.Transaction {
43+
t.Helper()
5144

52-
// Get the nonce
53-
nonce, err := client.PendingNonceAt(t.Context(), adminTransactor.From)
54-
require.NoError(t, err)
45+
// Get the nonce
46+
nonce, err := client.PendingNonceAt(t.Context(), adminTransactor.From)
47+
require.NoError(t, err)
5548

56-
gasPrice, err := client.SuggestGasPrice(t.Context())
57-
require.NoError(t, err)
49+
gasPrice, err := client.SuggestGasPrice(t.Context())
50+
require.NoError(t, err)
5851

59-
// Create a transaction to send tokens. This will be used to test the confirmation function.
60-
tx := types.NewTransaction(
61-
nonce, userTransactor.From, big.NewInt(10000000000000000), 21000, gasPrice, nil,
62-
)
52+
// Create a transaction to send tokens. This will be used to test the confirmation function.
53+
tx := types.NewTransaction(
54+
nonce, userTransactor.From, big.NewInt(10000000000000000), 21000, gasPrice, nil,
55+
)
6356

64-
signedTx, err := types.SignTx(tx, types.NewCancunSigner(simChainID), adminKey)
65-
require.NoError(t, err, "failed to sign transaction")
57+
signedTx, err := types.SignTx(tx, types.NewCancunSigner(simChainID), adminKey)
58+
require.NoError(t, err, "failed to sign transaction")
6659

67-
// Send the transaction
68-
err = client.SendTransaction(t.Context(), signedTx)
69-
require.NoError(t, err)
60+
// Send the transaction
61+
err = client.SendTransaction(t.Context(), signedTx)
62+
require.NoError(t, err)
7063

71-
client.Commit() // Commit the transaction to the simulated backend
64+
client.Commit() // Commit the transaction to the simulated backend
7265

73-
return signedTx
74-
},
66+
return signedTx
67+
}
68+
69+
tests := []struct {
70+
name string
71+
giveTx func(*testing.T, *SimClient) *types.Transaction
72+
confirmerOpts []func(*confirmFuncGeth)
73+
wantErr string
74+
}{
75+
{
76+
name: "successful confirmation",
77+
giveTx: defaultConfirmFunc,
78+
},
79+
{
80+
name: "successful confirmation with custom WaitMined ticker",
81+
confirmerOpts: []func(*confirmFuncGeth){WithTickInterval(10 * time.Millisecond)},
82+
giveTx: defaultConfirmFunc,
7583
},
7684
{
7785
name: "failed with nil tx",
@@ -121,7 +129,7 @@ func Test_ConfirmFuncGeth_ConfirmFunc(t *testing.T) {
121129
tx := tt.giveTx(t, client)
122130

123131
// Generate the confirm function
124-
functor := ConfirmFuncGeth(1 * time.Second)
132+
functor := ConfirmFuncGeth(1*time.Second, tt.confirmerOpts...)
125133
confirmFunc, err := functor.Generate(
126134
t.Context(), chainsel.TEST_1000.Selector, client, adminTransactor.From,
127135
)

chain/evm/provider/ctf_anvil_provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,15 @@ func TestCTFAnvilChainProvider_InitializeErrors(t *testing.T) {
295295

296296
func TestCTFAnvilChainProvider_SignerIntegration(t *testing.T) {
297297
t.Parallel()
298-
298+
299299
t.Run("custom tick interval", func(t *testing.T) {
300300
t.Parallel()
301301
customKey := "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
302302

303303
var once sync.Once
304304
config := CTFAnvilChainProviderConfig{
305305
Once: &once,
306-
ConfirmFunctor: ConfirmFuncGeth(2 * time.Minute, WithTickInterval(100*time.Millisecond)),
306+
ConfirmFunctor: ConfirmFuncGeth(2*time.Minute, WithTickInterval(100*time.Millisecond)),
307307
DeployerTransactorGen: TransactorFromRaw(customKey),
308308
T: t,
309309
}

engine/cld/legacy/cli/commands/template_input.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ changesets:
3131
`, envKey, domainName)
3232

3333
// Generate each changeset section
34+
var yamlTemplateSb34 strings.Builder
3435
for i, changesetName := range changesetNames {
3536
if changesetName == "" {
3637
continue
3738
}
3839

3940
// Add separator between changesets
4041
if i > 0 {
41-
yamlTemplate += "\n # ----------------------------------------\n"
42+
yamlTemplateSb34.WriteString("\n # ----------------------------------------\n")
4243
}
4344

4445
// Get changeset configuration
@@ -53,8 +54,9 @@ changesets:
5354
return "", fmt.Errorf("generate section for changeset %s: %w", changesetName, err)
5455
}
5556

56-
yamlTemplate += changesetSection
57+
yamlTemplateSb34.WriteString(changesetSection)
5758
}
59+
yamlTemplate += yamlTemplateSb34.String()
5860

5961
return yamlTemplate, nil
6062
}

0 commit comments

Comments
 (0)