@@ -14,7 +14,6 @@ import (
14
14
"github.com/ethereum/go-ethereum/common"
15
15
"github.com/stretchr/testify/require"
16
16
17
- "github.com/ava-labs/avalanchego/tests"
18
17
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
19
18
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
20
19
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
@@ -26,7 +25,8 @@ import (
26
25
// well as its ABI contained in `hashing_contract.go`.
27
26
28
27
var _ = e2e .DescribeCChain ("[Dynamic Fees]" , func () {
29
- require := require .New (ginkgo .GinkgoT ())
28
+ tc := e2e .NewTestContext ()
29
+ require := require .New (tc )
30
30
31
31
// Need a gas limit much larger than the standard 21_000 to enable
32
32
// the contract to induce a gas price increase
@@ -36,24 +36,24 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
36
36
gasTip := big .NewInt (1000 * params .GWei )
37
37
38
38
ginkgo .It ("should ensure that the gas price is affected by load" , func () {
39
- ginkgo .By ("creating a new private network to ensure isolation from other tests" )
39
+ tc .By ("creating a new private network to ensure isolation from other tests" )
40
40
privateNetwork := tmpnet .NewDefaultNetwork ("avalanchego-e2e-dynamic-fees" )
41
- e2e .Env .StartPrivateNetwork (privateNetwork )
41
+ e2e .GetEnv ( tc ) .StartPrivateNetwork (privateNetwork )
42
42
43
- ginkgo .By ("allocating a pre-funded key" )
43
+ tc .By ("allocating a pre-funded key" )
44
44
key := privateNetwork .PreFundedKeys [0 ]
45
45
ethAddress := evm .GetEthAddress (key )
46
46
47
- ginkgo .By ("initializing a coreth client" )
47
+ tc .By ("initializing a coreth client" )
48
48
node := privateNetwork .Nodes [0 ]
49
49
nodeURI := tmpnet.NodeURI {
50
50
NodeID : node .NodeID ,
51
51
URI : node .URI ,
52
52
}
53
- ethClient := e2e .NewEthClient (nodeURI )
53
+ ethClient := e2e .NewEthClient (tc , nodeURI )
54
54
55
- ginkgo .By ("initializing a transaction signer" )
56
- cChainID , err := ethClient .ChainID (e2e .DefaultContext ())
55
+ tc .By ("initializing a transaction signer" )
56
+ cChainID , err := ethClient .ChainID (tc .DefaultContext ())
57
57
require .NoError (err )
58
58
signer := types .NewEIP155Signer (cChainID )
59
59
ecdsaKey := key .ToECDSA ()
@@ -64,9 +64,9 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
64
64
}
65
65
66
66
var contractAddress common.Address
67
- ginkgo .By ("deploying an expensive contract" , func () {
67
+ tc .By ("deploying an expensive contract" , func () {
68
68
// Create transaction
69
- nonce , err := ethClient .AcceptedNonceAt (e2e .DefaultContext (), ethAddress )
69
+ nonce , err := ethClient .AcceptedNonceAt (tc .DefaultContext (), ethAddress )
70
70
require .NoError (err )
71
71
compiledContract := common .Hex2Bytes (hashingCompiledContract )
72
72
tx := types .NewTx (& types.LegacyTx {
@@ -79,36 +79,36 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
79
79
80
80
// Send the transaction and wait for acceptance
81
81
signedTx := sign (tx )
82
- receipt := e2e .SendEthTransaction (ethClient , signedTx )
82
+ receipt := e2e .SendEthTransaction (tc , ethClient , signedTx )
83
83
84
84
contractAddress = receipt .ContractAddress
85
85
})
86
86
87
87
var gasPrice * big.Int
88
- ginkgo .By ("calling the expensive contract repeatedly until a gas price increase is detected" , func () {
88
+ tc .By ("calling the expensive contract repeatedly until a gas price increase is detected" , func () {
89
89
// Evaluate the bytes representation of the contract
90
90
hashingABI , err := abi .JSON (strings .NewReader (hashingABIJson ))
91
91
require .NoError (err )
92
92
contractData , err := hashingABI .Pack ("hashIt" )
93
93
require .NoError (err )
94
94
95
95
var initialGasPrice * big.Int
96
- e2e .Eventually (func () bool {
96
+ tc .Eventually (func () bool {
97
97
// Check the gas price
98
98
var err error
99
- gasPrice , err = ethClient .SuggestGasPrice (e2e .DefaultContext ())
99
+ gasPrice , err = ethClient .SuggestGasPrice (tc .DefaultContext ())
100
100
require .NoError (err )
101
101
if initialGasPrice == nil {
102
102
initialGasPrice = gasPrice
103
- tests .Outf ("{{blue}}initial gas price is %v{{/}}\n " , initialGasPrice )
103
+ tc .Outf ("{{blue}}initial gas price is %v{{/}}\n " , initialGasPrice )
104
104
} else if gasPrice .Cmp (initialGasPrice ) > 0 {
105
105
// Gas price has increased
106
- tests .Outf ("{{blue}}gas price has increased to %v{{/}}\n " , gasPrice )
106
+ tc .Outf ("{{blue}}gas price has increased to %v{{/}}\n " , gasPrice )
107
107
return true
108
108
}
109
109
110
110
// Create the transaction
111
- nonce , err := ethClient .AcceptedNonceAt (e2e .DefaultContext (), ethAddress )
111
+ nonce , err := ethClient .AcceptedNonceAt (tc .DefaultContext (), ethAddress )
112
112
require .NoError (err )
113
113
tx := types .NewTx (& types.LegacyTx {
114
114
Nonce : nonce ,
@@ -121,33 +121,33 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
121
121
122
122
// Send the transaction and wait for acceptance
123
123
signedTx := sign (tx )
124
- _ = e2e .SendEthTransaction (ethClient , signedTx )
124
+ _ = e2e .SendEthTransaction (tc , ethClient , signedTx )
125
125
126
126
// The gas price will be checked at the start of the next iteration
127
127
return false
128
128
}, e2e .DefaultTimeout , e2e .DefaultPollingInterval , "failed to see gas price increase before timeout" )
129
129
})
130
130
131
- ginkgo .By ("waiting for the gas price to decrease..." , func () {
131
+ tc .By ("waiting for the gas price to decrease..." , func () {
132
132
initialGasPrice := gasPrice
133
- e2e .Eventually (func () bool {
133
+ tc .Eventually (func () bool {
134
134
var err error
135
- gasPrice , err = ethClient .SuggestGasPrice (e2e .DefaultContext ())
135
+ gasPrice , err = ethClient .SuggestGasPrice (tc .DefaultContext ())
136
136
require .NoError (err )
137
- tests .Outf ("{{blue}}.{{/}}" )
137
+ tc .Outf ("{{blue}}.{{/}}" )
138
138
return initialGasPrice .Cmp (gasPrice ) > 0
139
139
}, e2e .DefaultTimeout , e2e .DefaultPollingInterval , "failed to see gas price decrease before timeout" )
140
- tests .Outf ("\n {{blue}}gas price has decreased to %v{{/}}\n " , gasPrice )
140
+ tc .Outf ("\n {{blue}}gas price has decreased to %v{{/}}\n " , gasPrice )
141
141
})
142
142
143
- ginkgo .By ("sending funds at the current gas price" , func () {
143
+ tc .By ("sending funds at the current gas price" , func () {
144
144
// Create a recipient address
145
145
recipientKey , err := secp256k1 .NewPrivateKey ()
146
146
require .NoError (err )
147
147
recipientEthAddress := evm .GetEthAddress (recipientKey )
148
148
149
149
// Create transaction
150
- nonce , err := ethClient .AcceptedNonceAt (e2e .DefaultContext (), ethAddress )
150
+ nonce , err := ethClient .AcceptedNonceAt (tc .DefaultContext (), ethAddress )
151
151
require .NoError (err )
152
152
tx := types .NewTx (& types.LegacyTx {
153
153
Nonce : nonce ,
@@ -159,9 +159,9 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
159
159
160
160
// Send the transaction and wait for acceptance
161
161
signedTx := sign (tx )
162
- _ = e2e .SendEthTransaction (ethClient , signedTx )
162
+ _ = e2e .SendEthTransaction (tc , ethClient , signedTx )
163
163
})
164
164
165
- _ = e2e .CheckBootstrapIsPossible (privateNetwork )
165
+ _ = e2e .CheckBootstrapIsPossible (tc , privateNetwork )
166
166
})
167
167
})
0 commit comments