@@ -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+ defaultGiveTxFunc := 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 : defaultGiveTxFunc ,
78+ },
79+ {
80+ name : "successful confirmation with custom WaitMined ticker" ,
81+ confirmerOpts : []func (* confirmFuncGeth ){WithTickInterval (10 * time .Millisecond )},
82+ giveTx : defaultGiveTxFunc ,
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 )
0 commit comments